Axapta : Axapta Marge Cell And Set Backgroud LibreOffice Calc
Code :
strMarge = strfmt("A%1:J%1", rows + 1);
oRange = oSheet.getCellRangeByName(strMarge);
oRange.merge(true);
oRange.setPropertyValue("CellBackColor", 0x00dcff);
oRange = oSheet.getCellByPosition(0, rows);
oRange.SetString(strfmt("ÃÒ§ҹÂÍ´¢ÒÂã¹»ÃÐà·È ( %1 )", SalesGroupName));
strMarge = strfmt("A%1:J%1", rows + 2);
oRange = oSheet.getCellRangeByName(strMarge);
oRange.merge(true);
oRange = oSheet.getCellByPosition(0, rows + 1);
oRange.SetString(strfmt("From : %1 To : %2", fromDate, toDate));
Code : ALL
static void openOffice(Args _args)
{
COM OpenOffice;
COM oDeskTop;
COM oDocument;
COM oSheets;
COM oSheet;
COM oRange;
COM BorderStruct;
COMVariant arg;
COMVariant byte;
Array arr = new Array(Types::String);
str url;
int i;
;
OpenOffice = new Com("com.sun.star.ServiceManager");
oDeskTop = OpenOffice.CreateInstance("com.sun.star.frame.Desktop");
// create and initialize a COMVariant object
arg = COMVariant::createFromArray(arr);
// url = "file:///C:/Losses.xls"; //open local file
// url = "file://Axaptaserver/AxaptaSP4/Excel/Losses.xls"; //open share file
// oDocument = oDeskTop.LoadComponentFromURL(url, "_blank", 0, arg);
oDocument = oDeskTop.LoadComponentFromURL("private:factory/scalc", "_blank", 0, arg); //create new file
oSheets = oDocument.getSheets();
oSheet = oSheets.getByIndex(0); // select sheet
BorderStruct = OpenOffice.Bridge_GetStruct('com.sun.star.table.BorderLine');
BorderStruct.Color(24567057);
BorderStruct.LineDistance(0);
BorderStruct.InnerLineWidth(0);
BorderStruct.OuterLineWidth(1);
// oRange = oSheet.getCellByPosition(8,1,9,1);
oRange = oSheet.getCellRangeByName("H2:I2"); //ทำงานกับ range
oRange.merge(true); // สั่ง merge ได้ด้วย
oRange.setPropertyValue("CellBackColor", 16764057);
oRange.SetPropertyValue("LeftBorder",BorderStruct);
oRange.SetPropertyValue("RightBorder",BorderStruct);
oRange.SetPropertyValue("TopBorder",BorderStruct);
oRange.SetPropertyValue("BottomBorder",BorderStruct);
//*****************************
for(i=1; i<10;i++)
{
oRange = oSheet.getCellByPosition(0,i);
oRange.SetValue(i); //ส่งข้อมูลจำพวกตัวเลข
oRange.setPropertyValue("CellStyle", "Result");
oRange = oSheet.getCellByPosition(1,i);
oRange.Setstring('????????'); //ส่งข้อมูลประเภทตัวอักษร
oRange.setPropertyValue('CharPosture',100);
oRange = oSheet.getCellByPosition(2,i);
oRange.SetValue(i*i);
oRange.setPropertyValue('CharWeight',200);
oRange.setPropertyValue('CharUnderline',124);
oRange = oSheet.getCellByPosition(3,i);
oRange.SetString(date2str(today(),123,2,2,2,2,4));
oRange.setPropertyValue("CharColor", 500);
oRange.setPropertyValue('CharShadowed', True);
oRange = oSheet.getCellByPosition(4,i);
oRange.SetString(today());
oRange.setPropertyValue("CellBackColor", 0x99CCFF);
oRange.setPropertyValue("CharHeight", 12);
oRange.setPropertyValue("IsTextWrapped", True);
oRange = oSheet.getCellByPosition(5,i);
oRange.SetString(today());
oRange.setPropertyValue("CellStyle", "Date");
}
}
No comments:
Post a Comment