วันศุกร์ที่ 12 ตุลาคม พ.ศ. 2555
Export to Excel
static void Q_Prod_Eff_All_DoubleDie_MFG3(Args _args)
{
// Retreive data
ProdJournalRoute _ProdJournalRoute;
ProdJournalTable _ProdJournalTable;
SWAN_Machine_Capacity _SWAN_Machine_Capacity;
ProdTable _ProdTable;
Date _fromDate;
Date _toDate;
// Export to Excel
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
CustTable custTable;
int row = 1;
str fileName;
;
// Export to Excel
//Filename
fileName = "C:\\Test.xlsx";
//Initialize Excel instance
xlsApplication = SysExcelApplication::construct();
//Open Excel document
//xlsApplication.visible(true);
//Create Excel WorkBook and WorkSheet
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
//Excel columns captions
xlsWorkSheet.cells().item(row,1).value("Machine No.");
xlsWorkSheet.cells().item(row,2).value("ProdId");
xlsWorkSheet.cells().item(row,3).value("JournalId");
xlsWorkSheet.cells().item(row,4).value("Team");
xlsWorkSheet.cells().item(row,5).value("Trandate");
xlsWorkSheet.cells().item(row,6).value("ActualCap");
xlsWorkSheet.cells().item(row,7).value("Fullcap");
row++;
while
select * from _SWAN_Machine_Capacity
group by MachineNo
order by MachineNo
where _SWAN_Machine_Capacity.MachineNo Like "DD*"
{
print "----------------------------";
print _SWAN_Machine_Capacity.MachineNo;
print "----------------------------";
//strMachineNO = _SWAN_Machine_Capacity.MachineNo;
// Group by Team and Full,Acutualcap and ItemId and ProdId and JournalId
while
select * from _ProdJournalTable
where _ProdJournalTable.MachineNo == _SWAN_Machine_Capacity.MachineNo
join _ProdJournalRoute
where _ProdJournalRoute.ProdId == _ProdJournalTable.ProdId
&& _ProdJournalRoute.JournalId == _ProdJournalTable.JournalId
&& _ProdJournalRoute.TransDate == mkDate(10,08,12) // dialog feild
// _ProdJournalRoute.TransDate <= DateTo // dialog feild
{
// print _ProdJournalTable.MachineNo;
print _ProdJournalTable.ProdId;
print _ProdJournalTable.JournalId;
print _ProdJournalTable.MachineNo;
print _ProdJournalTable.Team;
print _ProdJournalRoute.FullCap;
print _ProdJournalRoute.ActualCap;
print _ProdJournalRoute.TransDate;
//Find ItemId
select _ProdTable
where _ProdTable.ProdId == _ProdJournalTable.ProdId;
print _ProdTable.ItemId;
print "++++++++++++++++++++++++++++++";
pause;
xlsWorkSheet.cells().item(row,1).value(_ProdJournalTable.MachineNo);
xlsWorkSheet.cells().item(row,2).value(_ProdJournalTable.ProdId);
xlsWorkSheet.cells().item(row,3).value(_ProdJournalTable.JournalId);
xlsWorkSheet.cells().item(row,4).value(_ProdJournalTable.Team);
xlsWorkSheet.cells().item(row,5).value(_ProdJournalRoute.TransDate);
xlsWorkSheet.cells().item(row,6).value(_ProdJournalRoute.ActualCap);
xlsWorkSheet.cells().item(row,7).value(_ProdJournalRoute.FullCap);
row++;
}
// break;
}
//Check whether the document already exists
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
//Save Excel document
xlsWorkbook.saveAs(fileName);
//Open Excel document
xlsApplication.visible(true);
//Close Excel
//xlsApplication.quit();
//xlsApplication.finalize();
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น