web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Export To Excel Problem

(0) ShareShare
ReportReport
Posted on by

Hi,

I am using dotnet variables in nav to  do this.

I followed this link to do the export to excel.

http://forum.mibuso.com/discussion/56735/dotnet-and-excel-in-nav2013.

when I run the report I am getting following error message

"A call to System.__ComObject.Open failed with this message: The type of one or more arguments does not match the method's parameter type."

I have given the following parameters for open function.


XlWrkBk:=XlApp.Workbooks.Open('Excelfile',0,TRUE,5,'','',TRUE,EnumToInt(XlPlatformFullName,

                                                         'xlWindows'),'\t',FALSE,FALSE,0,TRUE,1,0);

I am using NAV 2015 version

Can any body give some useful example or suggestion

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    we have checked with this below  link for parameters.

    msdn.microsoft.com/.../microsoft.office.interop.excel.workbooks.open.aspx

  • Verified answer
    keoma Profile Picture
    32,729 on at

    hi,

    better you use table excel buffer or use the same global vars as in this table like XlWrkBkReader (Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorkbookReader.'Microsoft.Dynamics.Nav.OpenXml, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35') to work with excel files.

    using com objects is always an adventure.

    there goto function OpenBook:

    ...

    XlWrkBkReader := XlWrkBkReader.Open(FileName);

    IF XlWrkBkReader.HasWorksheet(SheetName) THEN BEGIN

     XlWrkShtReader := XlWrkBkReader.GetWorksheetByName(SheetName);

    ...

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at
  • Community Member Profile Picture
    on at

    I'm getting an error in NAV 2015 when trying to import an password protected NAV 2015 file, do you have any ideas on how to counter this?

  • Suggested answer
    HILBE Profile Picture
    300 on at

    Hi,

    you have to do this this way

    ExcelApplicationClass_l := ExcelApplicationClass_l.ApplicationClass;

    ExcelWorkbook_l := ExcelApplicationClass_l.Workbooks.Open(FileName_v,0,TRUE,5,'','',TRUE,ExcelXLPlatform_l.xlWindows,'\t',FALSE,FALSE,0,TRUE,1,0);

    Name DataType Subtype Length

    ExcelApplicationClass_l DotNet Microsoft.Office.Interop.Excel.ApplicationClass.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    ExcelWorkbook_l DotNet Microsoft.Office.Interop.Excel.Workbook.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    ExcelXLPlatform_l DotNet Microsoft.Office.Interop.Excel.XlPlatform.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    This is a problem, because you have to assign the parameter complete correctly.

    You're EnumToInt(...) will not work in NAV. You have to use dotnet variable for that:

    Microsoft.Office.Interop.Excel.XlPlatform.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    best regards

    Robert

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans