How to export the HCMworker data to excel?
send any one code as soon as possible.
use bellow code in Class and make necessary changes using your tables.
Assettable assettable;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
// worksheet = worksheets.itemFromNum(1);
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range(‘A:A’).numberFormat(’@’);
cell = cells.item(1,1);
cell.value(“Asset Id”);
cell = cells.item(1,2);
cell.value(“Asset Group”);
cell = cells.item(1,3);
cell.value(“Name”);
cell = cells.item(1,4);
cell.value(“Name Alias”);
cell = cells.item(1,5);
cell.value(“Responsible”);
cell = cells.item(1,6);
cell.value(“Location”);
cell = cells.item(1,7);
cell.value(“Asset Type”);
row = 1;
while select assettable order by assettable.AssetId asc
{
row++;
cell = cells.item(row, 1);
cell.value(assettable.AssetId);
cell = cells.item(row, 2);
cell.value(assettable.AssetGroup);
cell = cells.item(row, 3);
cell.value(assettable.Name);
cell = cells.item(row, 4);
cell.value(assettable.NameAlias);
cell = cells.item(row, 5);
cell.value(assettable.Responsible);
cell = cells.item(row, 6);
cell.value(assettable.Location);
cell = cells.item(row, 7);
cell.value(assettable.AssetType);
}
application.visible(true);
}
static void ImportInventLocation(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
//ProductType productType;
InventLocation inventLocation;
int row;
Dialog dialog;
Dialogfield dialogfield;
boolean first = true;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//filename = @“C:\Users\Desktop\ImportWareHouse.xlsx”;
dialog = new dialog(‘Excel Import’);
dialogfield = dialog.addField(extendedTypeStr(FilenameOpen), ‘File Name’);
dialog.run();
filename =(dialogfield.value());
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++;
inventLocation.InventLocationId = cells.item(row, 1).value().bStr();
inventLocation.Name = cells.item(row, 2).value().bStr();
inventLocation.InventSiteId = cells.item(row, 3).value().bStr();
inventLocation.insert();
type = cells.item(row+1, 1).value().variantType();
//For time import using excel
/* timesheet.StartTime = time2Str(str2time(cells.item(row,6).value().bStr()), TimeSeparator::Colon, TimeFormat::Hour24);//cells.item(row,6).value().bStr();
timesheet.EndTime = time2Str(str2time(cells.item(row,7).value().bStr()), TimeSeparator::Colon, TimeFormat::Hour24);//cells.item(row,7).value().bStr();
timesheet.Work = COMVariant2Str(cells.item(row, 8).value());*/
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
workbooks.close();
info(“Done”);
}
thanks for given reply sir.
sir i want 2 export data for hcm worker like fields name, id, employeementstartdate,employementtype,senioritydate.sir cnd me the exact logic
Why cannot you use the Data import export frame work? What is your AX version?
ax 2012 r2
sir, how r u. since 2days u will not come 2 online sir.
Give me reply sir urgent requirement.
Have you tired using Data import export framework?
i dont know dixf process .sir
I am written code in class but its not working properly and i will send screen shots . could u please check and send me correct code. its is urgent requirement. i am already taken 4 days. but till now i am not exporting data properly. my requirement is i am selecting multipe lines in hcm worker listpage. that line i want 2 export in excel.
but above code not working sir, i got errors liike sys excel worksheet objects not intilized.
Can you insert the code here (instead of screen shots)?
sir, if u dont mind . could u plz give me ur whats up number.bcz i want 2 learn subject from u
You can put your code here. If not me, someone is going to help you.