spAXrrttaaaaaaannn!! ..
Waktu tahun 2002-2003 aku pernah dalam project Human Resource dan ada sebuah script yang melempar data-data/record-record ke file Excel ...
void clicked()
{
CustTable CustTableSelected; //buffor to store the selected
COM excelApplication;
COM excelWorkBooks;
COM excelWorkBook;
COM excelWorkSheets;
COM excelWorkSheet;
COM range;
int lineNum;
Array arr;
;
excelApplication = new COM("excel.application");
excelWorkBooks = excelApplication.workBooks();
excelWorkBook = excelWorkBooks.add();
excelWorkSheets = excelWorkBook.worksheets();
excelWorkSheet = excelWorkSheets.add();
excelApplication.visible(TRUE);
super();
for (CustTableSelected = CustTable_ds.getFirst(true) ?
CustTable_ds.getFirst(true) : CustTable_ds.cursor(); CustTableSelected;
CustTableSelected = CustTable_ds.getnext())
{
lineNum++;
arr = new Array(Types::String);
arr.value( 1, custTableSelected.AccountNum);
arr.value( 2, custTableSelected.Name);
arr.value( 4, custTableSelected.CustGroup);
range = excelWorkSheet.Range(strfmt("A%1:D%1", lineNum));
range.value2(COMVariant::createFromArray(arr));
}
}
source code diatas sebenarnya bukan dari yang aku punya tapi aku dapat dari http://snippets.dzone.com/tag/Axapta
oh iya ini hasil Editan saya
void clicked()
{
CustTable CustTableSelected; //buffor to store the selected
COM excelApplication;
COM excelWorkBooks;
COM excelWorkBook;
COM excelWorkSheets;
COM excelWorkSheet;
COM rangetit;
COM range;
int lineNum;
int linetit;
Array arr;
Array arrtit;
int i=1;
;
excelApplication = new COM("excel.application");
excelWorkBooks = excelApplication.workBooks();
excelWorkBook = excelWorkBooks.add();
excelWorkSheets = excelWorkBook.worksheets();
excelWorkSheet = excelWorkSheets.add();
excelApplication.visible(TRUE);
super();
/*
for (CustTableSelected = CustTable_ds.getFirst(true) ?
CustTable_ds.getFirst(true) : CustTable_ds.cursor(); CustTableSelected;
CustTableSelected = CustTable_ds.getnext())
{
lineNum++;
arr = new Array(Types::String);
arr.value( 1, custTableSelected.AccountNum);
arr.value( 2, custTableSelected.Name);
arr.value( 4, custTableSelected.CustGroup);
range = excelWorkSheet.Range(strfmt("A%1:D%1", lineNum));
range.value2(COMVariant::createFromArray(arr));
}
*/
lineNum = i;
linetit++;
arrtit = new Array(Types::String);
arrtit.value(1,"Account");
arrtit.value(2,"Name");
arrtit.value(4,"Group");
rangetit = excelWorkSheet.Range(strfmt("A%1:D%1", linetit));
rangetit.value2(COMVariant::createFromArray(arrtit));
while select CustTableSelected
{
lineNum++;
arr = new Array(Types::String);
arr.value( 1, custTableSelected.AccountNum);
arr.value( 2, custTableSelected.Name);
arr.value( 4, custTableSelected.CustGroup);
range = excelWorkSheet.Range(strfmt("A%1:D%1", lineNum));
range.value2(COMVariant::createFromArray(arr));
}
}
oh iya ini hasil Editan saya
void clicked()
{
CustTable CustTableSelected; //buffor to store the selected
COM excelApplication;
COM excelWorkBooks;
COM excelWorkBook;
COM excelWorkSheets;
COM excelWorkSheet;
COM rangetit;
COM range;
int lineNum;
int linetit;
Array arr;
Array arrtit;
int i=1;
;
excelApplication = new COM("excel.application");
excelWorkBooks = excelApplication.workBooks();
excelWorkBook = excelWorkBooks.add();
excelWorkSheets = excelWorkBook.worksheets();
excelWorkSheet = excelWorkSheets.add();
excelApplication.visible(TRUE);
super();
/*
for (CustTableSelected = CustTable_ds.getFirst(true) ?
CustTable_ds.getFirst(true) : CustTable_ds.cursor(); CustTableSelected;
CustTableSelected = CustTable_ds.getnext())
{
lineNum++;
arr = new Array(Types::String);
arr.value( 1, custTableSelected.AccountNum);
arr.value( 2, custTableSelected.Name);
arr.value( 4, custTableSelected.CustGroup);
range = excelWorkSheet.Range(strfmt("A%1:D%1", lineNum));
range.value2(COMVariant::createFromArray(arr));
}
*/
lineNum = i;
linetit++;
arrtit = new Array(Types::String);
arrtit.value(1,"Account");
arrtit.value(2,"Name");
arrtit.value(4,"Group");
rangetit = excelWorkSheet.Range(strfmt("A%1:D%1", linetit));
rangetit.value2(COMVariant::createFromArray(arrtit));
while select CustTableSelected
{
lineNum++;
arr = new Array(Types::String);
arr.value( 1, custTableSelected.AccountNum);
arr.value( 2, custTableSelected.Name);
arr.value( 4, custTableSelected.CustGroup);
range = excelWorkSheet.Range(strfmt("A%1:D%1", lineNum));
range.value2(COMVariant::createFromArray(arr));
}
}
Tidak ada komentar:
Posting Komentar