Look at table 370 Excel Buffer, the existing "CreateSheet" function. It basically assigns a name, left & right header, page orientation, then starts pushing in data...
XlWrkSht.Name := SheetName;
IF ReportHeader <> '' THEN
XlWrkSht.PageSetup.LeftHeader :=
STRSUBSTNO('%1%2%1%3%4',GetExcelReference(1),ReportHeader,CRLF,CompanyName);
XlWrkSht.PageSetup.RightHeader :=
STRSUBSTNO(Text006,GetExcelReference(2),GetExcelReference(3),CRLF,UserID2);
XlWrkSht.PageSetup.Orientation := XlLandscape;
IF FIND('-') THEN
REPEAT
RecNo := RecNo + 1;
Window.UPDATE(1,ROUND(RecNo / TotalRecNo * 10000,1));
IF NumberFormat <> '' THEN
XlWrkSht.Range(xlColID + xlRowID).NumberFormat := NumberFormat;
WITH ExcelBuf DO BEGIN
SetUseInfoSheed;
AddInfoColumn ('Compname',FALSE,'',TRUE,FALSE,FALSE,'');
AddInfoColumn ('Compname',FALSE,'',FALSE,FALSE,FALSE,'');
CreateBook;
END;
and this code on "OnAfterGetRecord Trigger
WITH ExcelBuf DO BEGIN
ClearNewRow;
NewRow;
AddColumn ('No.',FALSE,'',TRUE,FALSE,FALSE,'');
AddColumn ('Description',FALSE,'',FALSE,FALSE,FALSE,'');
NewRow;
AddColumn (Item."No.",FALSE,'',TRUE,FALSE,FALSE,'');
AddColumn (Item.Description,FALSE,'',TRUE,FALSE,FALSE,'');
CreateSheet(FORMAT(intCount),'Test Excel',COMPANYNAME,USERID);
DELETEALL(FALSE);
intCount += 1;
END;
This is on OnPost Report Trigger
ExcelBuf.GiveUserControl;
Comments
XlWrkSht.Name := SheetName;
IF ReportHeader <> '' THEN
XlWrkSht.PageSetup.LeftHeader :=
STRSUBSTNO('%1%2%1%3%4',GetExcelReference(1),ReportHeader,CRLF,CompanyName);
XlWrkSht.PageSetup.RightHeader :=
STRSUBSTNO(Text006,GetExcelReference(2),GetExcelReference(3),CRLF,UserID2);
XlWrkSht.PageSetup.Orientation := XlLandscape;
IF FIND('-') THEN
REPEAT
RecNo := RecNo + 1;
Window.UPDATE(1,ROUND(RecNo / TotalRecNo * 10000,1));
IF NumberFormat <> '' THEN
XlWrkSht.Range(xlColID + xlRowID).NumberFormat := NumberFormat;
WITH ExcelBuf DO BEGIN
SetUseInfoSheed;
AddInfoColumn ('Compname',FALSE,'',TRUE,FALSE,FALSE,'');
AddInfoColumn ('Compname',FALSE,'',FALSE,FALSE,FALSE,'');
CreateBook;
END;
and this code on "OnAfterGetRecord Trigger
WITH ExcelBuf DO BEGIN
ClearNewRow;
NewRow;
AddColumn ('No.',FALSE,'',TRUE,FALSE,FALSE,'');
AddColumn ('Description',FALSE,'',FALSE,FALSE,FALSE,'');
NewRow;
AddColumn (Item."No.",FALSE,'',TRUE,FALSE,FALSE,'');
AddColumn (Item.Description,FALSE,'',TRUE,FALSE,FALSE,'');
CreateSheet(FORMAT(intCount),'Test Excel',COMPANYNAME,USERID);
DELETEALL(FALSE);
intCount += 1;
END;
This is on OnPost Report Trigger
ExcelBuf.GiveUserControl;