11/06/2010

Control Calc chart using python

ref: http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/Structure_of_Charts

ref: http://www.oooforum.org/forum/viewtopic.phtml?p=56037


Legend show/hide

oChart = oSheet.Charts.getByIndex(0).EmbeddedObject
oChart.HasLegend = False


Set main title

oChart.HasMainTitle = True
oChart.Title.String = "main-title-string"


Set XAxis title

oDiagram = oChart.Diagram
oDiagram.HasXAxisTitle = True
oDiagram.XAxisTitle.String = "x-title"


Set XAxis label text rotation

oDiagram.XAxis.TextRotation = 90 * 100 # for 90 degree rotation

Set cell border

oBorderLine = createUnoStruct("com.sun.star.table.BorderLine2")
oBorderLine.InnerLineWidth = 2
oBorderLine.Color = 255 # blue

oCell.LeftBorder = oBorderLine
oCell.RightBorder = oBorderLine

Set cellRange border (apply to every cells)

oCellRange = oSheet.getCellRangeByPosition(1, 2, 3, 4)
oCellRange.BottomBorder = oBorderLine

Set cellRange TableBorder (apply to only edge lines not inner lines)

oCellRange.TableBorder -> com.sun.star.table.TableBorder

oTableBorder = createUnoStruct("com.sun.star.table.TableBorder")

# there are 2 types: BorderLine and BorderLine2. Confusing, be careful to choose.
oBorderLine = createUnoStruct("com.sun.star.table.BorderLine")
#oBorderLine2 = createUnoStruct("com.sun.star.table.BorderLine2")

# make oTableBorder object
oTableBorder.BottomLine = oBorderLine
oTableBorder.TopLine = oBorderLine
oTableBorder.LeftLine = oBorderLine
oTableBorder.RightLine = oBorderLine

# ... something like this ...
oTableBorder.IsTopLineValid = True
oTableBorder.IsBottomLineValid = True
oTableBorder.IsLeftLineValid = True
oTableBorder.IsRightLineValid = True

# set
oCellRange.TableBorder = oTableBorder
### Sometimes the code above does not work.
### Be sure that "oTableBorder.IsTopLineValid = True" line is correct.



.....

댓글 없음: