I am looking into exporting NAV data into a specific format in Excel. I have the following sample code:
FileName := 'C:\Book1.xlsx';
XlApp := XlApp.ApplicationClass;
XlWrkBk := XlApp.Workbooks.Open(FileName,0,TRUE,5,'','',TRUE,2,'\t',FALSE,FALSE,0,TRUE,1,0);
XlWrkSht := XlWrkBk.Sheets.Item(1);
XlRange := XlWrkSht.Range('A1','A10');
I wanted to loop through and write data in the cells in the defined XlRange but I do not know the exact syntax for using cells. At the moment I can do the following:
XlRange := XlWrkSht.Range('A1','A1');
XlRange.Value2 := 'HELLO WORLD';
This would mean though that I would have to create range each time I change a cell. I was thinking of doing something like:
XlRange.Cells(1,1).Value2 := 'HELLO ME';
But it does not recognize the cell coordinates, rather it throws an error that CELLS does no exact more than 0 parameters.
Any help is greatly appreciated.