SHARE
TWEET

Untitled

a guest Jun 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ImportExcel {  
  2.     public String fileName{get; set;}
  3.     public Blob contentFile{get;set;}
  4.     public String[] csvFileLines{get;set;}
  5.     public List<String> acclist{get;set;}
  6.     public String[] data{get;set;}
  7.     public ImportExcel(){
  8.         csvFileLines = new String[]{};
  9.         acclist = New List<String>();
  10.     }
  11. public void readFile(){
  12.         try
  13.         {
  14.             fileName=contentFile.toString();
  15.         }catch(Exception e){
  16.         ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL,'Please upload a valid CSV document');
  17.         ApexPages.addMessage(myMsg);
  18.             return ;
  19.         }
  20.         csvFileLines=fileName.split('n');
  21.         system.debug(csvFileLines);
  22.         for(Integer i=0;i<csvFileLines.size();i++){
  23.             data=csvFileLines[i].split(',');
  24.             acclist.add(data[i]);
  25.         }
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top