Create a function “EnterCell” with the variables as follows:
Var Name DataType Subtype Length
RowNo Integer
ColumnNo Integer
CellValue Text 100
Bold Boolean
Underline Boolean
NumberFormat Text 30
Italic Boolean
and in the body of the function write this code:
ExcelBuf.INIT;
ExcelBuf.VALIDATE(“Row No.”,RowNo);
ExcelBuf.VALIDATE(“Column No.”,ColumnNo);
ExcelBuf.“Cell Value as Text” := CellValue;
ExcelBuf.Bold := Bold;
ExcelBuf.Underline:=Underline;
ExcelBuf.Italic:=Italic;
ExcelBuf.NumberFormat := NumberFormat;
ExcelBuf.INSERT;
NOW put this code on these following trigeers:
Report - OnInitReport()
PrintToExcel:=FALSE;
RowID:=3;
Report - OnPreReport()
IF PrintToExcel THEN
ExcelBuf.DELETEALL(TRUE);
GLFilter := “G/L Account”.GETFILTERS;
GLDateFilter := “G/L Account”.GETFILTER(“Date Filter”);
Report - OnPostReport()
IF PrintToExcel THEN BEGIN
ExcelBuf.CreateBook;
ExcelBuf.CreateSheet(‘f form detail’,‘f form detail’,COMPANYNAME,USERID);
ExcelBuf.GiveUserControl;
END;
Now put this code on the OnPresection of every part, I mean Header(1),Header(2), Body,etc. as per the content in those.
In my case, I am putting you the code for header…You have to follow accordingly to manage your rows.
IF
PrintToExcel THEN BEGIN
RowID+=1;
EnterCell(RowID,1,‘Detail Trial Balance’,TRUE,TRUE,’@’,TRUE);
EnterCell(RowID,8,FORMAT(TODAY,0,4),TRUE,TRUE,’’,TRUE);
RowID+=1;
EnterCell(RowID,1,FORMAT(STRSUBSTNO(Text000,GLDateFilter)),TRUE,TRUE,’’,TRUE);
EnterCell(RowID,8,‘Page’,TRUE,TRUE,’@’,TRUE);
EnterCell(RowID,9,FORMAT(CurrReport.PAGENO),TRUE,TRUE,’’,TRUE);
RowID+=1;
EnterCell(RowID,8,FORMAT(COMPANYNAME),TRUE,TRUE,’’,TRUE);
EnterCell(RowID,9,FORMAT(USERID),TRUE,TRUE,’’,TRUE);
RowID+=2;
END;
I hope u will easily be able to do it…All the best !