Monday, 27 October 2014

Read Excel File Using Java in peoplecode


I have placed the jxl.jar file here "C:\PT8.53\appserv\classes" ,  here is the code



Local JavaObject &workbook = GetJavaClass("jxl.Workbook");
Local Sting &sFilePath = "C:\Users\Administrator\Desktop\munib\Book1.xls";


Local string &FILE_NAME = &sFilePath;
Local JavaObject &file = CreateJavaObject("java.io.File", &FILE_NAME);
Local JavaObject &WB = &workbook.getWorkbook(&file);
Local JavaObject &sheet = &WB.getSheet(0);

For &i = 0 To &sheet.getRows() - 1
   try
      MessageBox(0, "", 0, 0, "" | &sheet.getCell(0, &i).getContents());
   
   
   
   catch Exception &e
      MessageBox(0, "Excep-----", 0, 0, &e.ToString());
   end-try;
 
End-For;

No comments:

Post a Comment