Hi Martin I Have Added my new code But now i am getting different issue Just a beginner in Ax. But I Have given the correct location for the file.Dono why its showing this error.
1.Method 'open' in COM object of class 'Workbooks' returned error code 0x800A03EC (<unknown>) which means: '@ C:\item.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.
2.File cannot be opened.
static void Excel(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
COMVariantType type;
int row;
ItemId itemid;
InventDim inventdim;
InventSiteId inventsiteid;
InventItemInventSetup inventsetup;
Name name;
FileName filename;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specify the file path that you want to read
filename ="@ C:\\item.xls";
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
do
{
row++;
itemId = cells.item(row, 1).value().bStr();
inventsiteid = cells.item(row, 2).value().bStr();
inventsetup.LowestQty= cells.item(row, 3).value().int();
inventsetup.HighestQty=cells.item(row, 4).value().int();
//editHighestQty= cells.item(row, 3).value().bStr();
info(strfmt('%1 - %2- %3- %4', itemId, inventsiteid,inventsetup.LowestQty,inventsetup.HighestQty));
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
}