static void ReadExcel(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
Name name;
FileName filename;
CustNew custNew;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
filename = "F:\\Copy of CustTable.xls";
custNew.clear();
try
custNew.clear();
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++;
custAccount = cells.item(row, 1).value().bStr();
name = cells.item(row, 2).value().bStr();
type = cells.item(row+1, 1).value().variantType();
custNew.AccountNum=custAccount;
custNew.Name=name;
custNew.insert();
} while (type != COMVariantType::VT_EMPTY);
application.quit();
}