Export Same Table data in one excel with different sheet in Nav 2009.

Hi Everyone,

I am trying to export the same table data using process only report in one excel with multiple sheet in NAV 2009. ie, any particular table's 10 fields and corresponding data in first sheet and another 10 fields and corresponding data in second sheet of same excel.

I tried for one sheet its working fine, but i need as above query in multiple sheets in one excel.

please suggest me for..

Thanks,
Mani.

Answers

  • ManiNavManiNav Member Posts: 82
    Hi Everyone,

    In Process only report:
    1. I have added two data item as G/L entry1 and G/L entry2 for same table G/L entry; as i need two sheet in one excel.
    2. I have created two function: one for header:-MakeExcelHeader, and one for body:-MakeExcelBody
    Screenshot:

    3i4x57305pso.png


    I am using the below code to export data:
    please check once,where i am doing wrong.


    Documentation()

    G/L Entry1 - OnPreDataItem()

    G/L Entry1 - OnAfterGetRecord()
    IF NOT HeaderPrinted THEN
    MakeExcelHeader(1);
    MakeExcelBody(1);
    HeaderPrinted := FALSE;

    G/L Entry1 - OnPostDataItem()
    ExcelBuffer.CreateBook();
    ExcelBuffer.CreateSheet('Daily Sales','Report', COMPANYNAME, USERID);

    G/L Entry2 - OnPreDataItem()
    ExcelBuffer.DELETEALL;
    HeaderPrinted := FALSE;

    G/L Entry2 - OnAfterGetRecord()
    IF NOT HeaderPrinted THEN
    MakeExcelHeader(2);
    MakeExcelBody(2);
    HeaderPrinted := TRUE;

    G/L Entry2 - OnPostDataItem()
    ExcelBuffer.CreateBook();
    ExcelBuffer.CreateSheet('Import','Report', COMPANYNAME, USERID);
    ExcelBuffer.GiveUserControl();
    ERROR('');

    MakeExcelHeader(HeaderFor : Integer)
    ExcelBuffer.NewRow;
    CASE HeaderFor OF
    1:
    BEGIN
    ExcelBuffer.AddColumn('G/L Account No.(GL Code)',FALSE, '', TRUE,FALSE,FALSE,'');
    ExcelBuffer.AddColumn('Global Dimension 2 Code(Analysis Code)',FALSE, '', TRUE,FALSE,FALSE,'');
    END;
    2:
    BEGIN
    ExcelBuffer.AddColumn('Global Dimension 1 Code(Dept Code)',FALSE, '', TRUE,FALSE,FALSE,'');
    ExcelBuffer.AddColumn('Posting Date' ,FALSE, '', TRUE,FALSE,FALSE,'');
    END;
    END;

    MakeExcelBody(BodyFor : Integer)
    ExcelBuffer.NewRow;
    CASE BodyFor OF
    1:
    BEGIN
    ExcelBuffer.AddColumn("G/L Entry1"."G/L Account No.",FALSE, '', TRUE,FALSE,FALSE,'');
    ExcelBuffer.AddColumn("G/L Entry1"."Global Dimension 2 Code",FALSE, '', TRUE,FALSE,FALSE,'');
    END;
    2:
    BEGIN
    ExcelBuffer.AddColumn("G/L Entry2"."Global Dimension 1 Code",FALSE, '', TRUE,FALSE,FALSE,'');
    ExcelBuffer.AddColumn("G/L Entry2"."Posting Date" ,FALSE, '', TRUE,FALSE,FALSE,'');
    END;
    END;



    Documentation()

    Report - OnInitReport()

    Report - OnPreReport()

    Report - OnPostReport()
    //ExcelBuffer.OpenBook();
    ExcelBuffer.DELETEALL;

    Report - OnCreateHyperlink(VAR URL : Text[1024])

    Report - OnHyperlink(URL : Text[1024])



    Please check once my code i guide me, where i am doing wrong.
    Even there is no compilation error, but excel is not generating. when i run the report its buffering continuously.

    Thanks,
    Mani.
  • ManiNavManiNav Member Posts: 82
    Hi Everyone,

    Please guide me for the above query.

    Thanks,
    Mani.
Sign In or Register to comment.