function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VSK98VSK98 

How can we import the csv file which is having multiple sheets in a csv file using Apex

Hi All,

I have a requirement like a User has entered the Account & Contacts details in different sheets in a single excel. Once entered the user will save into the Csv File & upload the file from VisualForce Page. Once Uploaded, the Accounts & contacts should be stored in SFDC.

Adv Thanks !!!!!!!!!!

Regards,
VSK98
NagendraNagendra (Salesforce Developers) 
Hi,

You can use this js plugin https://github.com/SheetJS/js-xlsx which will convert your file to CSV format for multiple sheets, then you can use this code which will import data from CSV format.  https://github.com/SheetJS/js-xlsx/blob/master/index.html this is the link to the index.html page in which process_wb method is doing the job of giving u CSV files format string as per the number of sheets present in excel file. just go through flow. it is easy. and then u can use 
http://www.sfdcpoint.com/salesforce/import-csv-file-using-apex-visualforce/  (http://www.sfdcpoint.com/salesforce/import-csv-file-using-apex-visualforce/ )this to create a record in SF org.

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
VSK98VSK98
Hi Nagendra,

Thanks for your quick response!!

I tried with your above link, it's reading only single sheet but I have two multiple sheets in the excel. The SheetJS not reading the two sheets within an excel sheet.

Regards,
VSK98