You need to sign in to do that
Don't have an account?
salesuseto
Read and Write CSV file using Apex code
Hello Everyone,
I am very new to Salesforce.com, I need to read and write a CSV file using Apex code.
Functionality wants to implement : Read some records using query and write into a excel file and
read a CSV file and insert records into database.
this should be using apex code.
Please help me :)
Thanks
I am very new to Salesforce.com, I need to read and write a CSV file using Apex code.
Functionality wants to implement : Read some records using query and write into a excel file and
read a CSV file and insert records into database.
this should be using apex code.
Please help me :)
Thanks
Thanks for reply.
I want to develop a application which remove duplicates with selection control and write into CSV file which will store on client
desktop. Mainly using a Apex code.
If any idea about it, please reply.
Thanks
Hi,
I am also held at the same point. Hope by now you could have solved the issue. Can you help me?
Thanks
Hi All,
I am also struck with same senariao , can u any one help me
here I want When I click a button ,I want 2 enter bulk of data in a Excell sheet or CSV and
After click Submit button it will store which ever data enter in Excell, the same into SF
Vasu
Hi,
Did u manage to implement this ? If so could u pls share the code,would be really helpful.
Hi,
If any body is having the apex code bolck kindly share it...
Thnaks
Tonnistha
<apex:page controller="Test_ReadExcel_Cls">
<apex:form >
<apex:inputFile value="{!contentFile}" filename="{!nameFile}" />
<apex:commandButton action="{!ReadFile}" value="Read File" id="theButton"/>
</apex:form>
</apex:page>
/////Test_ReadExcel_Cls
public class Test_ReadExcel_Cls
{
public string nameFile{get;set;}
public Blob contentFile{get;set;}
public Test_ReadExcel_Cls()
{
}
public Pagereference ReadFile()
{
nameFile=contentFile.toString();
return null;
}
}
Try this
<apex:page controller="Test_ReadExcel_Cls">
<apex:form >
<apex:inputFile value="{!contentFile}" filename="{!nameFile}" />
<apex:commandButton action="{!ReadFile}" value="Read File" id="theButton"/>
</apex:form>
</apex:page>
/////Test_ReadExcel_Cls
public class Test_ReadExcel_Cls
{
public string nameFile{get;set;}
public Blob contentFile{get;set;}
public Test_ReadExcel_Cls()
{
}
public Pagereference ReadFile()
{
nameFile=contentFile.toString();
return null;
}
}
Here is a post on the subject of parsing CSV text in Apex that might save you a bit of time if you are implementing such a parser:
Parsing CSV while staying within the “total number of executed script statements” governor limit
Keith
Hi
i have same problem.
but some thing different i,e i need to read header column of excel file and those fileds i have to display in vf page
and those filed i shuld be map with the salesforce object after mapping insert the excel data into object
can u please share me sample code how to create excel data and insert into salesforce object
Thank you
Hi,
Try this code,,
http://www.forcetree.com/2010/08/read-and-insert-records-from-csv-file.html
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Chamil's Blog
Hi cantchanand,
I am using the same code and that is working fine,
but i want to display namefile's data in a visualforce page (for pdf).
How to do this,
Thank you
Amit Singh
@Amit Singh1989 create the regular visual force page and user the render as PDF option in Apex:Page tag.
e.g.
<apex:page standardController="Custom_Contacts__c" extensions="CustomContactsController" renderAs="PDF">
Thanks,
Ankur
Hi cantchanand,
I have the same kind of requirement to read a CSV file and by clicking Readfile button I want ajax loading functionality
when i click on Read file button i just want ajax loading functionality Ex : procesing ....
I'm not able to get that requirement , can anyone help me out.
Regards,
Praveen.
For Ajax you can use <apex:actionsupport> component.please refer to component reference for futher examples.
You can also use <apex:actionregion>.
Please let me know the scenario in which u wana use it.
I can help u futher.
Can anyone help me in providing a link to a document or a sample code which explains on how to read csv files stored on s3 bucket from salesforce?
Thanks!
If any body is having the apex code bolck kindly share it. Wanted to implement it in test suite to load data from a json file.