Reputation: 545
I want to create an Excel file in batch job, I tried to use SysExcelApplication class but it doesn't work in batch job, I also had problems with winAPIServer::fileExist/::FileDelete class, i found solution by using System.IO.file::exist/Delete(filename) Here's my code in X++:
SysExcelApplication xlsapplication;
;
xlsApplication = SysExcelApplication::construct();
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
I got an error on SysExcelApplication::construct(); when running batch job(can execute on server side), how can I do the same with dotnet?
Upvotes: 1
Views: 3096
Reputation: 894
There are a couple of options that you have:
You can use XML and XSLT to do it. I have put an article on my blog once that simply takes a simple XML and transforms it to fit into a saved Excel file (in XML format) This can be a good solution since writing XML files from Dynamics Ax is quite easy. The article shows how to create an XML with items and shows how to get it into Excel. Using C#, XML and XSLT to create an Excel spreadsheet
You could use OpenXML (Using C# and OpenXML SDK)
And there is also an option to use third party controls created to do this (Infragistics Excel for example)
Upvotes: 1