Reading Data from Excel File

static void ReadExcel(Args _args)
SysExcelApplication application; 
SysExcelWorkbooks workbooks; 
SysExcelWorkbook workbook; 
SysExcelWorksheets worksheets; 
SysExcelWorksheet worksheet; 
SysExcelCells cells; 
COMVariantType type; 
int row; 
ItemId itemid; 
Name name; 
FileName filename; 

application = SysExcelApplication::construct(); 
workbooks = application.workbooks(); 
//specify the file path that you want to read 
filename = “C:\\item.xls”; 

catch (Exception::Error) 

throw error(“File cannot be opened.”); 

workbook = workbooks.item(1); 
worksheets = workbook.worksheets(); 
worksheet = worksheets.itemFromNum(1); 
cells = worksheet.cells(); 

itemId = cells.item(row, 1).value().bStr(); 
name = cells.item(row, 2).value().bStr(); 
info(strfmt(‘%1 – %2′, itemId, name)); 
type = cells.item(row+1, 1).value().variantType(); 

while (type != COMVariantType::VT_EMPTY); 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.