Issue in exporting a report to excel

Hi,

I hav developed a report using “Sales Invoice Line” table. I am trying to export thereport to excel. But i’m getting an error in it - “The Dialog box is not open”.

Have shown the following codes in following triggers…

Sales Invoice Line-OnPreDataItem()

IF PrintToExcel THEN
BEGIN
window.OPEN(Text001 + ‘@1@@@@@@@@@@@@@@@@@@@@@’);
window.UPDATE(1,0);
TotalRecNo := “Sales Invoice Line”.COUNTAPPROX;
RecNo :=0;

TempExcelBuffer.DELETEALL;
CLEAR(TempExcelBuffer);

ENTERCELL(1, 1, Text000, TRUE, TRUE, FALSE);
ENTERCELL(1, 2, Text002, TRUE, TRUE, FALSE);
ENTERCELL(1, 3, Text003, TRUE, TRUE, FALSE);
ENTERCELL(1, 4, Text004, TRUE, TRUE, FALSE);
ENTERCELL(1, 5, Text005, TRUE, TRUE, FALSE);
ENTERCELL(1, 6, Text006, TRUE, TRUE, FALSE);
ENTERCELL(1, 7, Text007, TRUE, TRUE, FALSE);
ENTERCELL(1, 8, Text008, TRUE, TRUE, FALSE);

row := 1;
RecNo := RecNo + 1;
window.UPDATE(1,ROUND(RecNo / TotalRecNo * 10000,1));
END;

Sales Invoice Line-OnAfterGetRecord()

IF PrintToExcel THEN
BEGIN
window.CLOSE;
TempExcelBuffer.CreateBook;
TempExcelBuffer.CreateSheet(Text000,Text000,COMPANYNAME,USERID);
TempExcelBuffer.GiveUserControl;
END;

Sales Invoice Line,Body-OnPostSection()

IF PrintToExcel THEN
BEGIN
row := row + 1;
ENTERCELL(row, 1, “No.”, FALSE, FALSE, FALSE);
ENTERCELL(row, 2, Description, FALSE, FALSE, FALSE);
ENTERCELL(row, 3, FORMAT(“Quantity (Base)”),FALSE, FALSE, FALSE);
ENTERCELL(row, 4, “Unit of Measure Code”, FALSE, FALSE, FALSE);
ENTERCELL(row, 5, FORMAT(CBQty), FALSE, FALSE, FALSE);
ENTERCELL(row, 6, FORMAT(PMQty), FALSE, FALSE, FALSE);
ENTERCELL(row, 7, FORMAT(OtherQty), FALSE, FALSE, FALSE);
ENTERCELL(row, 8, FORMAT(CostAmount), FALSE, FALSE, FALSE);

RecNo := RecNo + 1;
window.UPDATE(1,ROUND(RecNo / TotalRecNo * 10000,1));
END;

Its jus creating a blank excel sheet with that error on the report, if I run with the debugger its pointing to the window.UPDATE line which is highlighted. Can anyone pls help me how to go on with this…

Thanks in advance…

Why did you use window.CLOSE; in Sales Invoice Line-OnAfterGetRecord() trigger?

IF PrintToExcel THEN
BEGIN
window.CLOSE;
TempExcelBuffer.CreateBook;
TempExcelBuffer.CreateSheet(Text000,Text000,COMPANYNAME,USERID);
TempExcelBuffer.GiveUserControl;
END;

Comment that code and try…

You need to use window.CLOSE; at last…

The error message describes the issue exactly. “The dialog box is not open”. So you either never opened it in the first place (which we know it was opened so this isn’t it), or it was opened and then closed before you tried to update it.

Think about your code in general terms of what it is doing. OnAfterGetRecord gets a record from a database. Do you want to create a sheet in Excel, close your progress bar, and open Excel after every sales invoice line? I don’t think so.

This may helpful

http://dynamicsuser.net/forums/p/31675/166416.aspx#166416