OpenOffice

You are currently browsing the articles from KomKid.Net matching the category OpenOffice.

Axapta : Open OpenOffice document and Save as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    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);
// #############################################################

Written by Komkid on November 22nd, 2009 with no comments.
Read more articles on Axapta and OpenOffice and Programming.

OpenOffice : Double line style

วิธีขีดเส้นใน OpenOffice ให้มี 2 เส้น ทำได้ดังนี้
1.ใช้เครื่องมือลากเส้น (Line ใน Drawing toolbar) ขีดไว้ แล้วคลิกขวาที่ เส้น เลือก Line…
openoffice_drawing_toolbar
2.คลิกที่ tab Shadow แล้วติ๊กที่ Use shadow
3.เลือกตำแหน่ง ,ระยะห่างระหว่างเส้นและสีของเส้นที่ 2
openoffice_line _shadow

Written by Komkid on October 9th, 2009 with no comments.
Read more articles on OpenOffice.

OpenOffice : Rows to repeat at top

เวลาจะพิมพ์โดยให้มีแถวใดขึ้นอยู่บนหัวกระดาษทุกหน้า
ใน Excel จะเข้าไปที่
1.File > Page Setup…
2.แล้วก็คลิก tab Sheet
3.ในกลุ่มของ Print titles เลือก Rows to repeat at top ดังรูป

rows_to_repeat_at_top

ใน OpenOffice เข้าไปที่
1.Format > Print Ranges > Edit…
2.แล้วก็เลือกตรง Rows to repeat

print_range_edit

Written by Komkid on September 3rd, 2009 with no comments.
Read more articles on IT Tips and OpenOffice.

OpenOffice : Concatenate cells with newline

อยากรวม 2 Cell เข้าด้วยกัน โดยให้มีการขึ้นบรรทัดใหม่ด้วย
เช่น
A1 = Name
B1 = Email
แล้วต้องการให้
C1 = Name ขึ้นบรรทัดใหม่ แล้วก็ Email แบบนี้
Name
Email

ปกติเวลาจะขึ้นบรรทัดใหม่ใน Cell เดิม ก็จะใช้วิธีกด Ctrl + Enter

แต่ถ้าจะใช้ Formula ก็ตามนี้ครับ

=CONCATENATE(A1,CHAR(13),CHAR(10),B1)

Written by Komkid on September 3rd, 2009 with no comments.
Read more articles on OpenOffice.

Axapta : Sending data to OpenOffice Calc by X++ using COM

การส่งข้อมูลจาก Axapta ไปให้ OpenOffice อีกวิธีก็คือ ใช้ API ที่ OpenOffice เตรียมไว้ให้ บวกกับคุณสมบัติด้าน COM ของ Axapta

ลักษณะโดยทั่วไปของโปรแกรมประเภท Spread Sheet ก็คือ
- 1 Document มีได้หลาย Sheets
- 1 Sheet มีได้หลาย Ranges หลาย Cells
- 1 Ranges สามารถประกอบได้จาก หลาย Cells
- 1 Cell ใส่ข้อมูลได้ 1 ชุด
ตามคู่มือของ OpenOffice ก็นำมาเขียนโดยใช้ X++ ได้ดังนี้

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
static void ooTest(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);

    //Create new document
    oDocument = oDeskTop.LoadComponentFromURL("private:factory/scalc", "_blank", 0, arg);
    oSheets   = oDocument.getSheets(); //object  นี้รับ sheet ทั้งหมด
    oSheet    = oSheets.getByIndex(0); // object นี้รับ sheet แรกมาเพื่อใช้ทำงาน

    BorderStruct = OpenOffice.Bridge_GetStruct('com.sun.star.table.BorderLine');
    BorderStruct.Color(24567057);
    BorderStruct.LineDistance(0);
    BorderStruct.InnerLineWidth(0);
    BorderStruct.OuterLineWidth(1);

    oRange = oSheet.getCellRangeByName("H2:I2");
    oRange.merge(true); //รวม Cells

    oRange.setPropertyValue("CellBackColor", 16764057);  // format cell
    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");
        }
}

ลองเล่นดูนะครับ ลองหลายแบบ ๆ ตามคู่มือได้เลย (ตัวอย่างผมได้มาจาก web เป็นภาษารัสเซียครับ http://axforum.info/forums/showthread.php?t=18722&highlight=openoffice)

Written by Komkid on August 13th, 2009 with no comments.
Read more articles on Axapta and OpenOffice and Programming.

« Older articles

No newer articles