You are on page 1of 2

Excel Buffer For Dummies

Ok Lets Try to Export Sales Header Info To Excel.
DataItem
Sales Header
Variables
Name
TempExcelBuffer
Window
Row
TotalRecNo
RecNo

DataType Subtype
Record
Excel Buffer
Dialog
Integer
Integer
Integer

___________________________________________________________________________________________________________________________________________________
_

Text Constants
Name
Text000
Text001
Text002
Text003
Text004
Text005
Text006
Text007
Text008

ConstValue
Order No
Analyzing Data...
ShipToName
ShipToAddress
ShipToAddress2
ShipToCity
ShipToState
ShipToZip
ShipToCountry

___________________________________________________________________________________________________________________________________________________
_

OnPreDataItem() This is where I set the column headings
//This Code is a little progress box that shows the export to excel
Window.OPEN(Text001 + '@1@@@@@@@@@@@@@@@@@@@@@\');
Window.UPDATE(1,0);
TotalRecNo := "Sales Header".COUNTAPPROX;
RecNo :=0;
//Double Check everythings all clear
TempExcelBuffer.DELETEALL;
CLEAR(TempExcelBuffer);
//My Headings-I’m setting a Row & Column Manually
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);
//Set my row to 1 for the upcoming data
Row := 1;
___________________________________________________________________________________________________________________________________________________
_
//Create a global function called ENTERCELL

EnterCell(RowNo : Integer;ColumnNo : Integer;CellValue : Text[250];Bold : Boolean;Italic : Boolean;UnderLine : Boolean) : Text[250]
TempExcelBuffer.INIT;
TempExcelBuffer.VALIDATE("Row No.",RowNo);
TempExcelBuffer.VALIDATE("Column No.",ColumnNo);
TempExcelBuffer."Cell Value as Text" := CellValue;
TempExcelBuffer.NumberFormat := '0';
TempExcelBuffer.Formula := '';
TempExcelBuffer.Bold := Bold;

So basically if you add the codes above to pretty much any report it will export to excel. FALSE. Window. FALSE. FALSE). //These are the fields I want to export EnterCell(Row.COMPANYNAME. "Ship-to City".TempExcelBuffer. //Updating the Progress Bar RecNo := RecNo + 1. 8. FALSE. FALSE.CreateSheet(Text000. EnterCell(Row. 5. FALSE). 4. EnterCell(Row. FALSE. . ''''+"Ship-to ZIP Code".USERID).CreateBook. FALSE). FALSE. TempExcelBuffer. TempExcelBuffer. 6. What you will change is the ONAFTERGETRECORD fields you want to export. 7. FALSE.Italic := Italic. FALSE). TempExcelBuffer. FALSE. "Ship-to Name". "No.UPDATE(1. EnterCell(Row.ROUND(RecNo / TotalRecNo * 10000. //Create The Worksheet TempExcelBuffer.". FALSE. EnterCell(Row. ___________________________________________________________________________________________________________________________________________________ _ OnPostDataItem() //Close the progress Bar Window. EnterCell(Row. FALSE). FALSE). ___________________________________________________________________________________________________________________________________________________ _ OnAfterGetRecord() Let’s Export some Data!!! Row := Row + 1. ___________________________________________________________________________________________________________________________________________________ _ That’s it give it a run.CLOSE. FALSE. FALSE).1)). FALSE. EnterCell(Row.Text000. "Ship-to State". 2. FALSE. FALSE. EnterCell(Row. Note you can also add the OnAfterGerRecord Code to Report Sections instead if you want totals or subtotals.INSERT.GiveUserControl. TempExcelBuffer. FALSE. "Ship-to Country Code". 3. FALSE. "Ship-to Address 2". FALSE.Underline := UnderLine. FALSE). 1. "Ship-to Address".