static void ImportFromExcelUpdVolumeWeight(Args _args)
{
InventTable inventTable;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
ItemId_Crystall itemId_Crystall;
Name name;
FileName filename;
int row = 1;
str crystall;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
filename = "D:\\sample.xlsx";
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();
ttsBegin;
do
{
row++;
itemId_Crystall = str2int(strRem(strRem(cells.item(row, 1).value().toString(), '"'), ' VT_BSTR'));
inventTable = InventTable::findItemId_Crystall(itemId_Crystall, true);
inventTable.UnitVolume = cells.item(row, 4).value().double();
inventTable.TaraWeight = cells.item(row, 5).value().double();
inventTable.update();
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
ttsCommit;
application.quit();
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.