Showing posts with label AE Peoplecode.Reading excel from peoplecode.. Show all posts
Showing posts with label AE Peoplecode.Reading excel from peoplecode.. Show all posts

Jan 31, 2013

PeopleSoft : AE Peoplecode to read data from excel

Local array of string &a;
&sFilePath = "C:\temp\template.xls";
&oWorkApp = CreateObject("COM", "Excel.Application");
ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open(&sFilePath);
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
&rowcount = &oWorkSheet.Usedrange.rows.count;
&cellcount = &oWorkSheet.Usedrange.cells.count;
&columncount = &oWorkSheet.Usedrange.columns.count;
MessageBox(0, "", 0, 0, "RowCount:" | &rowcount);
MessageBox(0, "", 0, 0, "CellCount:" | &cellcount);
MessageBox(0, "", 0, 0, "ColumnsCount:" | &columncount);
For &i = 1 To &rowcount
   rem  &a = CreateArray("");
   For &j = 1 To &columncount
      &data = &oWorkSheet.Cells(&i, &j).Value;
      rem &a.Push(&data);
      MessageBox(0, "", 0, 0, "data in" | &i | " row " | &j | " column :" | &data);
   End-For;
End-For;
&oWorkApp.ActiveWorkBook.Close();
&oWorkApp.DisplayAlerts = "True";
&oWorkApp.Quit();