SBX - Search With Button

SBX - Forum Post Title

Auto fit in excel buffer

Microsoft Dynamics NAV Forum

NavTech asked a question on 30 Jan 2019 7:25 AM
My Badges

Question Status

Suggested Answer

I am exporting data in excel using excel bufer in nav 2017 . I tried alot on google to find a solution to auto fit data . But no solution worked for me . I am not able to use variable XlWrkBk. I don't know how to instantiate it. Please help.

Reply
Suresh Kulla responded on 30 Jan 2019 9:53 AM
My Badges
Suggested Answer
LOCAL PROCEDURE PostOpenExcel@8();
    BEGIN
      XlWrkBk := XlApp.ActiveWorkbook;

      IF ISNULL(XlWrkBk) THEN
        ERROR(Text036);

      // autofit all columns on all worksheets
      XlHelper.AutoFitColumnsInAllWorksheets(XlWrkBk);

      // activate the previous saved sheet name in the workbook
      XlHelper.ActivateSheet(XlWrkBk,ActiveSheetName);
    END;


I think they might have removed the funciton in 2017, check in NAV 2015 there is a function in the Excel Buf called AutoFit and function in teh XlHelper to AutoFitAllColumns. It is called during OpenExcel in the PostOpenExcel Function.

Reply
Terry45 responded on 7 Feb 2019 4:29 AM

NavTech

I am exporting data in excel using excel bufer in nav 2017 . I tried alot on google to find a solution to auto fit data . But no solution worked for me . I am not able to use variable XlWrkBk. I don't know how to instantiate it. Please help.

I'm also facing the issue, please help me to resolve this issue.

Reply
Suresh Kulla responded on 30 Jan 2019 9:53 AM
My Badges
Suggested Answer
LOCAL PROCEDURE PostOpenExcel@8();
    BEGIN
      XlWrkBk := XlApp.ActiveWorkbook;

      IF ISNULL(XlWrkBk) THEN
        ERROR(Text036);

      // autofit all columns on all worksheets
      XlHelper.AutoFitColumnsInAllWorksheets(XlWrkBk);

      // activate the previous saved sheet name in the workbook
      XlHelper.ActivateSheet(XlWrkBk,ActiveSheetName);
    END;


I think they might have removed the funciton in 2017, check in NAV 2015 there is a function in the Excel Buf called AutoFit and function in teh XlHelper to AutoFitAllColumns. It is called during OpenExcel in the PostOpenExcel Function.

Reply

SBX - Two Col Forum

SBX - Migrated JS