Search This Blog

Wednesday, January 6, 2010

Excel file using peoplecode

/* Set up the Excel COM objects and open the template file */

Local object &oWorkApp, &oWorkBook;

&oWorkApp = CreateObject("COM", "Excel.Application");

&oWorkApp.DisplayAlerts = "False";

&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");

&oWorkBook.Open("C:\some_path_to\template.xls");

&oWorkSheet = &oWorkApp.Worksheets("Sheet1");

&oWorkApp.ActiveWorkBook.SaveAs("C:\your_output_file.xls");

/* Changing the properties of the cell */

&oWorkSheet.Cells(1, 1).Value = "I'm adding stuff to be bolded";

&oWorkSheet.Cells(1, 1).Font.Bold = True;

/* Save Excel file and quit */

&oWorkApp.ActiveWorkBook.Save();

&oWorkApp.ActiveWorkBook.Close();

&oWorkApp.DisplayAlerts = "True";

&oWorkApp.Quit();

Source: peoplesoft wikidot

No comments:

Post a Comment