Quantcast
Channel: Instantiating an Excel Object from Peoplesoft page
Viewing all articles
Browse latest Browse all 62

(no title)

$
0
0

I have an App engine peoplecode that reads a table and write in excel. If there is any reason the AE errors out, we have some instances of excel left open on the server. Is there a sureshot way of killing these excel instances or make sure they always close?

Following is the code:

PSHome = GetEnv("PS_HOME");

/* 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");

REM LOCAL &oWorkBook.open("C:\temp\template.xlsx");
&TemplateFileName = &PSHome | "\….\….\ReportTemplate.xlsx";
&oWorkBook.open(&TemplateFileName);

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

&ReportFile = %FilePath | "EEReport.xlsx";
&oWorkApp.ActiveWorkBook.SaveAs(&ReportFile);

/* Begin writing the worksheet data */
&Row = 1;
&Col = 1;
If N_EE_RPT_AET.N_PROFILE_TYPE = "S" Then
&Title = Profile Data";
Else
&Title = "Review Data";
End-If;

&oWorkSheet.Cells(&Row, &Col).Value = &Title;
&oWorkSheet.Cells(&Row, &Col).Font.Bold = True;

&EEReport = CreateRecord(Record.N_EE_REPORT);
&EEReportSel = CreateSQL("%SelectAll(:1) WHERE PROCESS_INSTANCE = :2 ORDER BY EMPLID, SEQNBR");
&EEReportSel.Execute(&EEReport, N_EE_RPT_AET.PROCESS_INSTANCE);

&Row = 2;

/* Col A */
&Col = 1;
&oWorkSheet.Cells(&Row, &Col).Value = "Emplid";

/* Col B */
&Col = &Col + 1;
&oWorkSheet.Cells(&Row, &Col).Value = "Employee Name";
…..
…..
…..
…..

While &EEReportSel.Fetch(&EEReport);
&Col = 0;

&Row = &Row + 1;
&Col = &Col + 1;
&oWorkSheet.Cells(&Row, &Col).Value = &EEReport.EMPLID.value;

&Col = &Col + 1;
&oWorkSheet.Cells(&Row, &Col).Value = &EEReport.EMPL_NAME.value;

…..
…..
…..
…..

End-While;

/* Save Excel file and quit */
&oWorkApp.ActiveWorkBook.Save();
&oWorkApp.ActiveWorkBook.Close();
&oWorkApp.DisplayAlerts = "True";
&oWorkBook.Close();
&oWorkApp.Quit();


Viewing all articles
Browse latest Browse all 62

Latest Images

Trending Articles



Latest Images