Tuesday, 22 January 2019

import data from excel x++

public void readFromExcell()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row = 1;

Dialog dialog;
DialogField dialogPath;
CommaIO inFile;
FilenameOpen fileName;
str personnelNumberId;
MonthsOfYear month;
DateExpected saturdayOffDate;
Str60 testMonth;
str dayOfDate;
boolean ret, error;
Description255 remarks;
HcmWorker hcmWorker;

application = SysExcelApplication::construct();
workbooks = application.workbooks();

dialog = new Dialog(“Import Override Exception Saturday Off”);
dialogPath = dialog.addField(extendedTypeStr(Filenameopen), “File Name”);
dialog.run();

if (dialog.run())
{
filename = dialogPath.value();
}

workbooks.open(filename);

workbook = workbooks.item(1);
worksheets = workbook.worksheets();

worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();

do
{
row++;

personnelNumberId = this.COMVariant2Str(cells.item(row,1).value());
saturdayOffDate = cells.item(row,2).value().date();
remarks = cells.item(row,3).value().bStr();
dayOfDate = dayName(dayOfWk(saturdayOffDate));

type = cells.item(row+1, 1).value().variantType();
}

while (type != COMVariantType::VT_EMPTY);
application.quit();

}

1 comment: