static void UpdateSupplementaryQuantities(Args _args)
{
//initializing system excel objects to use
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
Filename filename; //get the file name
COMVariantType type; //to check if it's the end
int rowNo; //getting the row number
//here you get an object form your table
YourTable _yourTable;
//initializing the requiered fields you want to handle, ehither you use there ExtendType or there actual data type
SomeExtendType firstObject;
str secondObject;
//////
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specify the file path that you want to read
filename = @"your_file_path";
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //working with sheet one in the excel
cells = worksheet.cells(); // getting all the cells
rowNo = 1; //row number starts to count rows from 2 because usually the header is in the first row
do
{
rowNo++;
//let's assume you have two columns
firstObject = cells.item(rowNo, 1).value().double();
//you get the row number and then the column for the data you want and the value of it and it's double because it may have extend type but the original data type it's own data type and here it's real so we use double
secondObject = cells.item(rowNo, 2).value().bStr(); // here we use bStr because our object's data type is string
//now you have the data for the first record in the excel, you handle it using SQL and x++
ttsBegin;
//your code goes here
ttsCommit;
type = cells.item(rowNo+1, 1).value().variantType(); //here we check if the next row it's not empty
}
while (type != COMVariantType::VT_EMPTY); // a loop to get the next rows
workbooks.close();
}