I am generating Excel file in Microsoft Dynamics AX 2009. I would like to create a table in Excel from 9th row. Even though I set a range, the table always shows at cell A1.
SysExcelRange xlsRange;
SysExcelListObject listObj;
#define.ListObjectName("xlGuess")
...
xlsRange = xlsWorkSheet.range("A9");
listObj = xlsWorkSheet.listObjects().add(xlsRange, #ListObjectName);
I've also tried to set full range like "A9:E13" and "A9:A13", but it didn't work either. Probably, it's possible to do it with COM objects but I couldn't achive it. Why it doesn't work?
It seems that there is a bug in the Excel wrapper of AX.
If I changed one line to pass the actual range to the underlying COM object then it seems to work; have a look at the screenshot for what I have changed.
With a AOT job like this
public static client void TestJob()
{
#define.ListObjectName("xlGuess")
SysExcelApplication xlsApp;
SysExcelWorksheet xlsWorksheet;
SysExcelRange xlsRange;
SysExcelListObject listObj;
;
xlsApp = SysExcelApplication::construct();
xlsApp.workbooks().add();
xlsWorksheet = xlsApp.activeSheet();
xlsRange = xlsWorksheet.range("A9:C12");
listObj = xlsWorkSheet.listObjects().add(xlsRange, #ListObjectName);
xlsApp.visible(true);
}
it will open an Excel file like this: