+ Start a Discussion

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..


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




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


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 );