hi Nadeem,
There is no difference exicuting the code in the button or a JOB is same.
you can use this code for your need
void clicked()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
LogisticsPostalAddress postalAddress;
DirPartyLocation partyLocation;
int row =1;
int i=0;
MTCustAddress custAddress;
LogisticsPostalAddress LogisticsPostalAddress;
InventTable inventTableLoc;
CustAccount custAcc;
LogisticsAddressing address;
LogisticsAddressCountyId county;
CustTable custTable;
ItemId itemid;
str ERPItemCode;
Dialog dialog;
DialogField dialogField;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specify the file path that you want to read
//filename = “C:\\Users\\46509010\\Desktop\\book2.xlsx”;
//filename = "C:\\Users\\Administrator\\Desktop\\LabelFields.xlsx";
dialog = new Dialog("FileOpen");
dialogfield = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
dialog.run();
if (dialog.run())
{
filename = (dialogfield.value());
}
//delete_from overtime
//where overtime.MZK_MonthYear == MZK_MonthYear::APR2013
//&& overtime.dataAreaId == “yme”;
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
{
ttsBegin;
row++;
itemid = cells.item(row, 1).value().bStr();
ERPItemCode = cells.item(row, 2).value().bStr();
inventTableLoc = InventTable::find(itemid,true);
inventTableLoc.ItemId = itemid;
inventTableLoc.ERPItemCode = ERPItemCode;
inventTableLoc.update();
ttsCommit;
i++;
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
info("Done");
info(strFmt("%1", i));
}
Thanks and Regards,
Suresh