I managed to work recently on many sites that required importing Data into Sitecore from an Excel Sheet. These Data might be from Sharepoint, xml, Migrated data, actually any kind of data that you managed to store in Excel and need to import into Sitecore.
Below, a number of code snippets that allows you to do so by using CSharpJExcel.Jxl library to read Excel sheets.
Create a method to that takes the destination path (where the new Item would be stored in Sitecore tree), Item name and the template ID from which the new Item would be created.
Once the Sitecore item is created, you can loop through all the item fields to update the Sitecore Item field with the new value. This method takes a Sitecore item, Sitecore field and the new value to update the field.
The last step would be to read the Excel sheet, loop through the entire sheet and create a new Sitecore item at each row. Once an item has been created, we would update fields based on columns values. In this case, I had a dictionary that maps these column names in the Excel sheet with the Sitecore fields. Another approach would be saving data into the Excel sheet with same name of the Sitecore fields id you already know the template otherwise, you need to create a mapping file (xml for example), that directs the mapping between the Excel sheet columns and Sitecore fields.
That’s it, you can create another method to validate the Item name and put these all together in a simple import page with a button.