Quantcast
Channel: NAV Three Tier — mibuso.com
Viewing all articles
Browse latest Browse all 10032

Import to Nav from Excel using Interop

$
0
0
Hi,


I have a scenario where I have an existing Excel automation where I import Excel data into Nav 5.0. Now that we have migrated to Nav 2013 R2, the same automation takes very slow. So I tried out using DotNet Interop, and got the following code through searching:
  XlApp := XlApp.ApplicationClass;
  
  XlWrkBk := XlApp.Workbooks.Open(FileName,0,TRUE,5,'','',TRUE,2,'\t',FALSE,FALSE,0,TRUE,1,0);
  
  XlWrkSht := XlWrkBk.Worksheets.Item(1);
  
  XlRange :=  XlWrkSht.Range('A1', 'A1');

Now I am stuck with the error on the XlRange line, showing the following:
Cannot serialize an instance of the following .NET Framework object: assembly mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089,type System._ComObject.

This is the first time i am dabbling on this so any help is appreciated. Thanks.

PS. :smile:

I am basically trying to replicate the following in DotNet Interop
ExcelWorkbooks.Open(FileName);
ExcelWorkbook := ExcelApp.ActiveWorkbook;
ExcelSheets := ExcelWorkbook.Worksheets;
ExcelWorksheet := ExcelSheets.Item(1);
ExcelWorksheet.Range('H'+FORMAT(Row)).Value

Viewing all articles
Browse latest Browse all 10032

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>