Export to multiple sheet in excel - Nav 2018

Djou2424Djou2424 Member Posts: 76
I'm looking for an exemple of how to export data to excel in Navision 2018 using multiple sheets.
We have a custom report for one of our client in nav 2013 R2 that export orders informations to different excel spreadsheet.
Now that we are upgrading them to 2018, the code is not working anymore

Here is part of the code in 2013 R2 that is working fine:
ExcelBuf.OnlyCreateBook('ABC', 'ABC',COMPANYNAME, USERID,TRUE);
ExcelBuf.DELETEALL;

Here is the error message we get in 2018 when running the same report
2kpieei71xe2.png

Here is where in the code of the excel buffer table it's failing
51gur3l85zeb.png
l6skgsc9tvh1.png

Answers

  • vaprogvaprog Member Posts: 1,144
    OnlyCreateBook is no standard function. Nor are the Add... functions.

    ExcelBuffer used to use Automation in order to remote control Excel. It now uses Dotnet OpenXML library to create a document directly.

    You will have to re-implement extensions to your Excel Buffer using that library.
  • Djou2424Djou2424 Member Posts: 76
    Ok, do you know where I could find an example of how to do that?
  • Djou2424Djou2424 Member Posts: 76
    Still looking for help on how to do this
  • zack90zack90 Member Posts: 1
    edited 2020-09-28
    try this:


    AddSheet(SheetName : Text[250])
    CurrentRow := 0;
    CurrentCol := 0;

    XlWrkShtWriter := XlWrkBkWriter.AddWorksheet(SheetName);
    IF SheetName <> '' THEN BEGIN
    XlWrkShtWriter.Name := SheetName;
    ActiveSheetName := SheetName;
    END;


    ChangeSheet(SheetName : Text[250])
    XlWrkShtWriter := XlWrkBkWriter.GetWorksheetByName(SheetName);
    IF SheetName <> '' THEN BEGIN
    XlWrkShtWriter.Name := SheetName;
    ActiveSheetName := SheetName;
    END;

    WrkShtHelper := WrkShtHelper.WorksheetHelper(XlWrkBkWriter.GetWorksheetByName(SheetName).Worksheet);
    Worksheet := XlWrkShtWriter.Worksheet;
Sign In or Register to comment.