Adding Progress bar in form or report in axapta

Adding Progress bar in form or report in axapta is not so tough I just try this code.
SysOperationProgress progress,progressexcel;
str tmpb,tmpogroup,tmpo,tmpb;
;

progressexcel = new SysOperationProgress();
progressexcel.setCaption('Progress');
progressexcel.setText('Printing To Excel..Please Wait');

super();

startLengthyOperation();
element.oQuery();

element.close();
progressexcel.setTotal(8000);
excelApplication = new COM("excel.application");
excelWorkBooks = excelApplication.workBooks();
excelWorkBook = excelWorkBooks.add();
excelWorkSheets = excelWorkBook.worksheets();
excelApplication.visible(false);
excelWorkSheet = excelApplication.activeSheet();

styles = excelWorkBook.styles();
style = styles.add('MyStyle');
font = style.font();
font.bold(true);

range = excelWorkSheet.Range("A1:C1");
range.style('MyStyle');
range.MergeCells(true);
range.value2(CompanyInfo::find().Name);

range = excelWorkSheet.Range("A2:C2");
range.style('MyStyle');
range.MergeCells(true);
range.value2("Stock Existing Report");

range = excelWorkSheet.Range("D2");
range.style('MyStyle');
range.value2(strfmt("Created Date :%1 Created Time :%2",today(),time2str(timenow(),1,1)));

linenum = 3;
i = 1;

range = excelWorkSheet.Range(strfmt("B%1",lineNum));
range.style('MyStyle');
range.value2(strfmt("LIST OF oS - %1",b.valueStr()));
lineNum++;
progressexcel.incCount();


QRN=new QueryRun(Q);
while(QRN.next())
{
intltems = QRN.get(tablenum(ViewBacobActive));


if (tmpb != intltems.b)
{
range = excelWorkSheet.Range(strfmt("B%1",lineNum));
range.style('MyStyle');
range.value2(strfmt("%1",BacbMaster::find(intltems.b).Description));
lineNum++;
progressexcel.incCount();
}
range = excelWorkSheet.Range(strfmt("A%1",lineNum));
range.value2(strfmt("%1",i));
range = excelWorkSheet.Range(strfmt("B%1",lineNum));
range.value2(strfmt("%1 - %2",intltems.oGroup,intltems.o));

lineNum++;
progressexcel.incCount();
i++;
tmpb=intltems.b;
}
excelApplication.visible(true);
excelApplication.finalize();

endLengthyOperation();

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.