+ Start a Discussion
RamboRambo 

Importing values from Excel sheet into Salesforce

Hi All,

            It would be helpful if you could let me know on how to import data from excel into Salesforce programatically (Visual Force & Apex).

I am required to create a button which would attach an excel sheet. Once the excel sheet is attached, records for the Custom object should be created automatically based on the values in the excel sheet..

 

Thanks in advance..



ngabraningabrani

You can parse the csv file that user will provide using Apex. Sample code is attached in this blog.

 

http://blog.nicocrm.com/2011/03/06/parse-csv-file-in-salesforce-apex/

 

Once you have parsed the csv, you can create custom objects, and perform an upsert on them.

RamboRambo

Allrite.... Currently I am trying to add the excel sheet as an attachment and then trying to convert the Blob file to String and was trying to play with the string. When I try to convert the Bolb to String using toString() it throws an error saying that "Blob is not in UTF-8 format".

 

All I wanna know is, how to tackle this issue.. Or is der a proper way of achieving this requirement.

 

Jia HuJia Hu
String strBody = EncodingUtil.base64Encode( binary_body );