Axapta : Sending data to OpenOffice Calc by X++ using OOCALCVB.dll

วิธีการนี้ต้องใช้ตัวช่วยคือ OOCALCVB.dll
1.Download DLL OOCALCVB.dll ไปไว้ในเครื่อง ปกติก็คือที่ C:\Windows\System32\

2.ใน Axapta เลือกเมนู Tools > Development tools > Wizards > COM Class Wrapper Wizard
2009-08-13_141006

3.คลิก Next แล้วก็ Brows หาไฟล์ในข้อ 1 แล้วก็คลิก Next

4.ป้อน oo ตรงช่อง Element Mask เพื่อเอาไว้สังเกต Classes ที่จะได้ แล้วคลิก Next จะได้รายการของ Class ที่เกิดจาก OOCALCVB.dll
2009-08-13_141552

5.คลิก Next แล้วรอจนเสร็จ ก็คลิก Finish

6.เปิดดู AOT จะเห็นว่ามี Class ใหม่เกิดขึ้นมาดังรูป
2009-08-13_141822

ต่อไปก็ลองเขียน X++ ติดต่อดู ดังตัวอย่าง
ooCalc ooCalc;
#ooCOMDEF
;

ooCalc = new ooCalc();
ooCalc.Workbooks().OpenFile("\\\\Axaptaserver\\AxaptaSP4\\Excel\\Losses.xls",false,"",false);

ooCalc.ActiveWorkbook().ActiveSheet().Cells().Item("A1").Value(66);
// ooCalc.ActiveWorkbook().ActiveSheet().Cells().Item("A1").SetString(strfmt("Losses of %1 from %2 to %3",fromDate,toDate)); //SetString อันนี้ใช้ไม่ได้
ooCalc.ActiveWorkbook().ActiveSheet().Cells().Item("A1").Formula(strfmt("Losses of %1 from %2 to %3",fromDate,toDate)); //SetString ไม่ได้ ใช้ Formula แทนไปก่อน

Comments

Popular posts from this blog

Artillery Hornet + OctoPrint + Klipper

ย้ายบ้าน

ใต้ร่มกาสาวพัตร