Skip to main content

Posts

Showing posts with the label Dynamics Axapta

Axapta Code to Import from Excel To Table.

Axapta Code to Import from Excel To Table. void importFromExcel() { myTable myTable; COMVariant COMVariant1; SysExcelApplication app; SysExcelWorkbooks Workbooks; SysExcelWorkbook Workbook; SysExcelWorksheets Worksheets; SysExcelWorksheet Worksheet; SysExcelCells Cells; SysExcelCell RCell; int i; #excel app = SysExcelApplication::construct(); Workbooks = app.Workbooks(); COMVariant1 = new COMVariant(); COMVariant1.bStr("C:\\myExcel.xls"); Workbook = Workbooks.Add(COMVariant1); Worksheets = Workbook.worksheets(); Worksheet = Worksheets.itemFromName("myTable"); Cells = Worksheet.Cells(); i = 2; RCell = Cells.Item(i, 1); ttsbegin; while(RCell.Value().bStr() != '') { myTable.Field1Id = RCell.value().bStr(); RCell = Cells.Item(i, 2); myTable.Field2 = RCell.value().bStr(); RCell = Cells.Item(i, 3); myTable.FieldInt = str2int(RCell.value().toString()); RCell = Cells.It