Options

Excel-add multi sheets

csimoneauxcsimoneaux Member Posts: 168
edited 2010-03-08 in NAV Three Tier
I am trying to add new sheet for each Company...
I have taken the standard Fixed asset report and customized it to look at every company and bring back all data for all companies.
Data Item
Company
Fixed asset.
On the Report - OnPostReport() I have added the following.

IF PrintDetail THEN BEGIN
TmpExcelBuffer.CreateBook;
TmpExcelBuffer.CreateSheet('FixedAsset','Fixed Asset Book Value 01',COMPANYNAME,USERID);
TmpExcelBuffer.GiveUserControl;
END;

Every time the Company changes I need the data to print to another sheet until it reaches the next company, which in turn should create another sheet.
There are 26 companies in Total.

Would someone be able to help me figure out how to do this. I see data on how to create new sheet, But I can not figure out where to put code to create sheet when Company changes.

Comments

  • Options
    rsfairbanksrsfairbanks Member Posts: 107
    You could try setting the sheet name to the company name each time you change company, then do the
    TmpExcelBuffer.CreateSheet(SheetName,'Fixed Asset Book Value 01',COMPANYNAME,USERID);
    prior to getting the next company.
    You will have to do the createbook before this.
  • Options
    csimoneauxcsimoneaux Member Posts: 168
    If I create new sheets for each company on Report - OnPostReport(), How do I tell what data goes to what sheet.
    Report - OnPostReport runs after all data has been put into the ExcelBuffer Table.
    Did I miss something here?
  • Options
    rsfairbanksrsfairbanks Member Posts: 107
    Yes you need to do it before the onPostReport, where you have modified the report to swap Companies. I cannot tell where this is because I don't know how you've customised the report, and the solution will in some respects depend on how this was done.

    Essentially,
    1 create book
    2 get data for 1st company
    3 create sheet for 1st company
    4 repeat 2 and 3 for other companies
    5 give user control

    But as I say will in part be determined how you modified the report.
Sign In or Register to comment.