7/03/2011

Axapta : Open OpenOffice document and Save as

Axapta : Open OpenOffice document and Save as
  COM OpenOffice;
    COM oDeskTop;
    COM oDocument;
    COMVariant arg;
    COMVariant byte;
    Array Arr = new Array(Types::Class);
    Array oArr = new Array(Types::Class);
    str url,outFile;
    COM FileProperties;
;
    OpenOffice = new Com("com.sun.star.ServiceManager");
    oDeskTop = OpenOffice.CreateInstance("com.sun.star.frame.Desktop");

// #############################################################
// เปิดไฟล์
    arg = comVariant::createFromArray(Arr);
    url = "file://Axaptaserver/AxaptaSP4/Excel/Losses.xls";
    oDocument = oDeskTop.LoadComponentFromURL(url, "_blank", 0, arg);
// #############################################################

// #############################################################
// Save as เป็นอีกไฟล์
    FileProperties = OpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
    FileProperties.Name('Overwrite');
    FileProperties.Value(true);
    oArr.value(1,FileProperties);
    arg = comVariant::createFromArray(oArr);
    outFile = "file:///C:/Losses.xls";
    oDocument.storeAsURL(outFile,arg);
// #############################################################

No comments:

Post a Comment