Class CalcCharts
- class ooodev.calc.CalcCharts(owner, charts, lo_inst=None)[source]
Bases:
LoInstPropsPartial
,TableChartsComp
,QiPartial
,ServicePartial
,CalcSheetPropPartial
,CalcDocPropPartial
Class for managing Calc Charts.
New in version 0.26.1..
- __delitem__(_item)[source]
Removes a chart from the document.
- Parameters:
_item (int | str, TableChart) – Index, name, or TableChart to remove.
- Raises:
TypeError – If the item is not a supported type.
- Return type:
None
- __getitem__(index)[source]
Gets the chart at the specified index or name.
This is short hand for
get_by_index()
orget_by_name()
.- Parameters:
key (key, str, int) – The index or name of the chart. When getting by index can be a negative value to get from the end.
index (str | int) –
- Returns:
The chart with the specified index or name.
- Return type:
See also
- __len__()[source]
Gets the number of charts in the document.
- Returns:
Number of charts in the document.
- Return type:
int
- add_new_by_name(name, rect, ranges, column_headers, row_headers)
Creates a chart and adds it to the collection.
- Return type:
None
- Parameters:
name (str) –
rect (com.sun.star.awt.Rectangle) –
ranges (Tuple[CellRangeAddress, ...]) –
column_headers (bool) –
row_headers (bool) –
- create_enumeration()
Creates an enumeration of the container’s elements.
- Return type:
XEnumeration
- get_by_index(idx)[source]
Gets the element at the specified index.
- Parameters:
idx (int) – The Zero-based index of the element. Idx can be a negative value to index from the end of the list. For example, -1 will return the last element.
- Returns:
The element at the specified index.
- Return type:
- get_by_name(name)[source]
Gets the element with the specified name.
- Parameters:
name (str) – The name of the element.
- Raises:
MissingNameError – If sheet is not found.
- Returns:
The element with the specified name.
- Return type:
- get_count()
Gets the number of elements contained in the container.
- Returns:
The number of elements.
- Return type:
int
- get_element_names()
Gets the names of all elements contained in the container.
- Returns:
The names of all elements.
- Return type:
tuple[str, …]
- get_element_type()
Gets the type of the elements contained in the container.
- Returns:
The type of the elements.
None
means that it is a multi-type container and you cannot determine the exact types with this interface.- Return type:
Any
- get_services()
Gets service names for the instance.
- Returns:
service names
- Return type:
List[str]
- has_by_name(name)
Checks if the container has an element with the specified name.
- Parameters:
name (str) – The name of the element.
- Returns:
True
if the container has an element with the specified name, otherwiseFalse
.- Return type:
bool
- has_elements()
Determines whether the container has elements.
- Return type:
bool
- insert_chart(*, rng_obj=None, cell_name='', width=16, height=9, diagram_name='Column', color_bg=14085119, color_wall=11393254, **kwargs)[source]
Insert a new chart.
- Parameters:
rng_obj (RangeObj, optional) – Cell range object. Defaults to current selected cells.
cell_name (str, optional) – Cell name such as
A1
.width (int, optional) – Width. Default
16
.height (int, optional) – Height. Default
9
.diagram_name (ChartTemplateBase | str) – Diagram Name. Defaults to
Column
.color_bg (
Color
, optional) – Color Background. Defaults toCommonColor.PALE_BLUE
. If set toNone
then no color is applied.color_wall (
Color
, optional) – Color Wall. Defaults toCommonColor.LIGHT_BLUE
. If set toNone
then no color is applied.
- Keyword Arguments:
- Raises:
ChartError – If error occurs
- Returns:
Chart Document that was created and inserted into the sheet.
- Return type:
Note
Keyword Arguments are to mostly be ignored. If finer control over chart creation is needed then Keyword Arguments can be used.
Note
See Open Office Wiki - The Structure of Charts for more information.
- qi(atype, raise_err=False)
Generic method that get an interface instance from an object.
- Parameters:
atype (T) – Interface type to query obj for. Any Uno class that starts with ‘X’ such as XInterface
raise_err (bool, optional) – If True then raises MissingInterfaceError if result is None. Default False
- Raises:
MissingInterfaceError – If ‘raise_err’ is ‘True’ and result is None
- Returns:
instance of interface if supported; Otherwise, None
- Return type:
T | None
Note
When
raise_err=True
return value will never beNone
.
- remove_by_name(name)
Removes a chart from the collection.
- Return type:
None
- Parameters:
name (str) –
- remove_chart(chart_name)[source]
Removes a chart from Spreadsheet.
- Parameters:
sheet (XSpreadsheet) – Spreadsheet
chart_name (str) – Chart Name
- Returns:
True
if chart was removed; Otherwise,False
- Return type:
bool
- support_service(*service)
Gets if instance supports a service.
- Parameters:
*service (str) – Variable length argument list of UNO namespace strings such as
com.sun.star.configuration.GroupAccess
- Returns:
True
if instance supports any passed in service; Otherwise,False
- Return type:
bool
- property component: com.sun.star.table.TableCharts
TableCharts Component
- Return type:
TableCharts
- property office_doc: OfficeDocumentT
Office Document.
- Return type: