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
Swamy PSwamy P 

How to fetch a value from a particular row&column in an excel sheet by parsing Excel Sheet file

Hello Everyone,

I was working on Parsing Excel File by Apex but unfortunately i was not able to get specific row and specific column value. By using Parsing, i was able to fetch  all of the columns but i wanted to get specific row also. Below is the code which I've used for Columns:
         string  csvAsString = csvFileBody.toString();
           String[] csvFileLines = csvAsString.split('\n');             
           for(Integer i=1;i<csvFileLines.size();i++){
               Contact accObj = new Contact() ;
               string[] csvRecordData = csvFileLines[i].split(','); //In this i was able to fetch Columns, from this i wanted to get Row Value
 Help me on getting the specific Row&Column value from an excel.
Thanks in advance!!!              
Rajneesh Ranjan 23Rajneesh Ranjan 23
Hi Swamy P,

I think you are almost there. If you are able to split the column data then use that array to populate column values in a loop. I assume you need always a fixed coumn value. 

Below is the code that I tried, see if it helps.
string  csvAsString = 'aaa,bbb,cccc,ddd,eee,fff';
string[] csvRecordData = csvAsString.split(','); //In this i was able to fetch Columns, from this i wanted to get Row Value

for (Integer i=1; i<csvRecordData.size(); i++) {
    system.debug('Column'+i+': ' + csvRecordData[i]);
Happy Coding.