report.hwxdocxtypes Module#

Chapter class#

class Chapter(name=None, parent=None, **kwargs)#

Bases: object

Chapter class creates new chapter object as a child of either a document or and other chapter.

If ‘name’ value is None, creates new chapter with unique name.

If ‘name’ value is not None and no entity of same name exists in the specified report session, new chapter gets created with the given name.

If ‘name’ value is not None and entity of same name exists in the specified session, an error is returned.

Parameters:
  • name (str) – The chapter name.

  • parent (Document | Chapter) – Parent of this chapter.

getChildren(childrenLevel=0, type=[], name=None)#

Returns children of this document as list.

Parameters:
  • childrenLevel (str | int) –

    0 - Returns only direct children of this document. (default)

    1 - Returns children and immediate grand-children of this document. Based on level value, returns all children until that level.

    -1 - Returns all children until last level.

    It also takes string as input. Valid values are:

    ’current’ - Returns only direct children of this document.

    ’next’ - Returns children and immediate grand-children of this document.

    ’all’ - Returns all children until that last level.

  • type (list) – Filters children based on type. By default, no filter is applied. Valid values are ‘DocImage’, ‘DocTable’, ‘DocText’, ‘Chapter’. Default is empty list.

Returns:

List of children of this document.

Return type:

list

property name#

The chapter name.

Getter:

Gets the name of the chapter.

Setter:

Sets the name of the chapter.

Type:

str

property parent#

Returns the parent of the chapter.

Returns:

Parent of the chapter.

Return type:

Document | Chapter

DocImage class#

class DocImage(*args, **kwargs)#

Bases: object

DocImage class constructor can create both new image entity or a reference to an existing image entity present in the library.

In case of a reference, any property changes made on the library image will be reflected in all references. If any changes need to be made to a DocImage, a copy of image gets created and the changes are applied to the copy so the original remains unchanged.

If the specified name does not exists in the report session, a new image/reference is created with given name.

If the specified name exists in the active report session, an error is returned.

Parameters:
  • parent (Document | Chapter) – Parent of the image

  • image (Image | str | numpy-ndarray) – If type is ‘Image’, reference-image gets created. If type is ‘str’ or ‘numpy-ndarray’, a new image gets created.

  • name (str) – Unique name for the image

setAttributes(**kwargs)#

Set multiple attributes.

Parameters:

kwargs (dict) – Valid keywords are name, caption, source, width, height, page, window, and binarydata.

property binarydata#

The image content as binary data.

Getter:

Gets the image content as binary data.

Setter:

Sets the image content as binary data.

Type:

numpy-ndarray

property caption#

The image caption.

Getter:

Gets the image caption.

Setter:

Sets the image caption.

Type:

str

property name#

The image name.

Getter:

Gets the name of the image.

Setter:

Sets the name of the image.

Type:

str

property page: Any#
property parent#

The parent of the image.

Getter:

Gets the image parent.

Setter:

Sets the image parent.

Type:

Document | Chapter

property path#

The image file path.

Getter:

Gets the image file path.

Setter:

Sets the image file path.

Type:

str

property source#

The image source type.

Getter:

Gets the image source type.

Setter:

Sets the image source type. Valid values are ‘graphic’ and ‘file’.

Type:

str

property type#

The image type.

Returns:

Image type. Possible values are ‘bmp’, ‘jpg’, ‘jpeg’, ‘png’, ‘gif’, ‘h3d’, and ‘glb’.

Return type:

str

property window: Any#

DocTable class#

class DocTable(*args, **kwargs)#

Bases: object

DocTable class can create both a new table entity or a reference to an existing table entity present in the library.

In case of reference, any property value changes made in library table, it will reflect in all references. Also in case of reference entity, if any changes need to be made to ‘DocTable’, copy of table gets created and then update the changes. So that, original table remains unchanged.

If ‘name’ does not exists in report session, then new table/reference gets created with given name.

If ‘name’ exists in active report-session, then error thrown.

Parameters:
  • parent (Document | Chapter) – Parent of this table.

  • table (Table | str) – If type is ‘Table’, reference-table gets created. If type is csv-filepath, new table gets created.

  • name (str) – Unique name for this table

addColumn()#

Method to add a new column to the table.

exportCsv(file: str)#

Method to export table data to a CSV file.

Parameters:

file (str) – The CSV file path.

removeColumn(col: int)#

Method to remove a column at specified index.

Parameters:

col (int) – Column index

removeRow(row: int)#

Method to remove a row at specified index.

Parameters:

row (int) – Row index

setAttributes(**kwargs)#

Method to set multiple attributes.

Parameters:

kwargs (dict) – Valid keywords are name, caption, source, file, width, and height.

setCellValue(row: int, col: int, value)#

Method to set a cell value.

Parameters:
  • row (int) – Row index

  • col (int) – Column index

  • value (str|int|float) – Cell value

setColumnWidth(index: int, width: float)#

Method to set column width.

Parameters:
  • index (int) – Column index

  • width (float) – Column width

setDimension(rows: int, cols: int)#

Method to set number of rows and columns for the table.

Parameters:
  • rows (int) – Row count

  • cols (int) – Column count

setRowHeight(index: int, height: float)#

Method to set row height.

Parameters:
  • index (int) – Row index

  • height (float) – Row height

property caption#

The table caption.

Getter:

Gets the caption of the table.

Setter:

Sets the caption of the table.

Type:

str

property columns#

Returns table column count.

Returns:

Column count

Return type:

int

property file#

The path of the CSV file loaded as table data.

Getter:

Gets the table CSV file path.

Setter:

Sets the table CSV file path.

Type:

str

property height#

The table height.

Getter:

Gets the table height.

Setter:

Sets the table height.

Type:

int

property name#

The table name.

Getter:

Gets the name of the table.

Setter:

Sets the name of the table.

Type:

str

property parent#

The parent of the table.

Getter:

Gets the table parent.

Setter:

Sets the table parent.

Type:

Document | Chapter

property rows#

Returns table row count.

Returns:

Row count

Return type:

int

property width#

The table width.

Getter:

Gets the table width.

Setter:

Sets the table width.

Type:

int

DocText class#

class DocText(*args, **kwargs)#

Bases: object

DocText class can create both new text entity or reference to existing text entity present in the library.

In case of a reference, any property value changes made in library text will reflect in all references.

In case of a reference entity, if any changes need to be made to ‘DocText’, a copy of text gets created and then changes are applied so the original text remains unchanged.

If ‘name’ does not exists in report session, a new text or reference gets created with the given name.

If ‘name’ exists in active report-session, an error is returned.

Parameters:
  • parent (Document | Chapter) – Parent of this text.

  • text (Text | str) – If type is ‘Text’, reference-text gets created. If type is ‘str’, new text gets created.

  • name (str) – Unique name for this text

addFormatedText(text: str | None = '', equation: str | None = None, font_name: str | None = 'Arial', font_size: int | None = 9, font_color: List[int] | None = [0, 0, 0], bold: bool | None = False, italic: bool | None = False, underline: bool | None = False, line_break: bool | None = False, tab_space: bool | None = False, hyperlink: str | None = '')#

Adds new run to the first paragraph of a text entity.

Parameters:
  • text (str) – New run text

  • equation (str) – New run equation

  • font_name (str) – New run font name

  • font_size (int) – New run font size

  • bold (bool) – New run bold status

  • italic (bool) – New run italic status

  • underline (bool) – New run underline status

  • line_break (bool) – New run linebreak status

  • tab_space (bool) – New run tabspace status

  • hyperlink (str) – New run hyperlink

addImage(image, lineBreak=False)#

Method to add new image to the first paragraph of text entity.

Parameters:
  • image (str | numpy-ndarray) – Image path or stream

  • lineBreak (bool) – Add line break for image

setAttributes(**kwargs)#

Method to set multiple attributes.

Parameters:

kwargs (dict) – Valid keywords are name, fontName, fontColor, fontSize, boldFont, italicFont, underline, lineBreak, tabSpace, hyperLink, textcontent, and alignment.

property alignment#

The text alignment. Valid values are ‘none’, ‘left’, ‘right’, ‘center’, ‘justify’, ‘justifyLow’, and ‘distribute’.

Getter:

Gets the text alignment.

Setter:

Sets the text alignment.

Type:

str

property boldFont#

The flag to activate or deactivate the bold font.

Getter:

Gets the status of the bolt font.

Setter:

Sets the status of the bolt font.

Type:

bool

property fontColor#

The font color as a list of RGB values [r,g,b]. Valid values range from 0 to 255.

Getter:

Gets the name of the font color.

Setter:

Sets the name of the font color.

Type:

list

property fontName#

The font name.

Getter:

Gets the name of the font.

Setter:

Sets the name of the font.

Type:

str

property fontSize#

The font size.

Getter:

Gets the name of the size.

Setter:

Sets the name of the size.

Type:

str

The hyperlink definition.

Getter:

Gets the hyperlink.

Setter:

Sets the hyperlink.

Type:

str

property italicFont#

The flag to activate or deactivate the italic font.

Getter:

Gets the status of the italic font.

Setter:

Sets the status of the italic font.

Type:

bool

property lineBreak#

The flag to activate or deactivate the line break.

Getter:

Gets the status of the line break.

Setter:

Sets the status of the line break.

Type:

bool

property name#

The text name.

Getter:

Gets the name of the text.

Setter:

Sets the name of the text.

Type:

str

property parent#

The parent of the text.

Getter:

Gets the text parent.

Setter:

Sets the text parent.

Type:

Document | Chapter

property tabSpace#

The flag to activate or deactivate the tabular space.

Getter:

Gets the status of the tabular space.

Setter:

Sets the status of the tabular space.

Type:

bool

property textcontent#

The text to default run of default paragraph.

Getter:

Gets the text.

Setter:

Sets the text.

Type:

str

property underline#

The flag to activate or deactivate the underline.

Getter:

Gets the status of the underline.

Setter:

Sets the status of the underline.

Type:

bool

Document class#

class Document(name=None, **kwargs)#

Bases: CommonProperties

Document class creates document object under Report object.

If ‘name’ value is None, creates new document with unique name.

If ‘name’ value is not None and no entity of same name exists in specified report session, a new image gets created with given name.

If ‘name’ value is not None and any entity of same name exists in specified session, an error is returned.

Parameters:

name (str) – Document name

getChildren(childrenLevel=0, type=[], name=None)#

Returns children of this document as list.

Parameters:
  • childrenLevel (str | integer) –

    0 - Returns only direct children of this document. (default)

    1 - Returns children and immediate grand-children of this document. Based on level value, returns all children until that level.

    -1 - Returns all children until last level.

    It also takes string as input:

    ’current’ - Returns only direct children of this document.

    ’next’ - Returns children and immediate grand-children of this document.

    ’all’ - Returns all children until that last level.

  • type (list) – Filters children based on type. By default, no filter is applied. Valid values are ‘DocImage’, ‘DocTable’, ‘DocText’, ‘Chapter’. Default is empty list.

Returns:

Return list of children of this document.

Return type:

list

saveAsHTML(path, open=False) None#

Saves output as HTML file.

Parameters:
  • path (str) – File path for HTML file.

  • open (bool) – Opens file after creation (default False)

saveDocx(path=None, **kwargs)#

Save output document file

Parameters:
  • path (str) – Generated document file path

  • kwargs (dict) – Possible keys are open, mode

savePDF(path=None, **kwargs)#

Method to save a PDF file.

Parameters:
  • path (str) – Generated PDF file path

  • kwargs (dict) – Valid keyword is open.

setAttributes(**kwargs)#

Set multiple attributes

Parameters:

kwargs (dict) – Valid keywords are name, template

property name#

The name of the entity.

Getter:

Gets the name of the entity.

Setter:

Sets the name of the entity.

Type:

str

property session#

Returns session to which this entity belongs.

Returns:

Report session

Return type:

ReportSession

property template#

Returns template filename used for document export.

Returns:

Template filepath used for document export.

Return type:

str

Image class#

class Image(name=None, **kwargs)#

Bases: CommonProperties

Image class creates new image entity

If ‘name’ value is None, creates new image with unique name.

If ‘name’ value is not None and session of ‘name’ does not exists, then new image gets created with given name.

If ‘name’ value is not None and session of ‘name’ exists, then error thrown.

Parameters:
  • name (str) – Image name.

  • session (str) – Session name. If not specified, uses currently active report session name

  • path (str) – Source image file path.

  • source (str) – Valid values are ‘graphic’ and ‘file’ (default).

setAttributes(**kwargs)#

Method to set multiple attributes.

Parameters:

kwargs (dict) – Valid keywords are name, source, type, path, caption, page, and window.

property binarydata#

The image content as binary data.

Getter:

Gets the image content as binary data.

Setter:

Sets the image content as binary data.

Type:

numpy-ndarray

property caption#

The image caption.

Getter:

Gets the image caption.

Setter:

Sets the image caption.

Type:

str

property ensureFit#

The flag to activate or deactivate the ensure fit.

Getter:

Gets the status of the ensure fit.

Setter:

Sets the status of the ensure fit.

Type:

bool

property name#

The name of the entity.

Getter:

Gets the name of the entity.

Setter:

Sets the name of the entity.

Type:

str

property page: Any#
property path#

The image file path.

Getter:

Gets the image file path.

Setter:

Sets the image file path.

Type:

str

property session#

Returns session to which this entity belongs.

Returns:

Report session

Return type:

ReportSession

property source#

The image source type. Valid values are ‘graphic’ and ‘file’.

Getter:

Gets the image source type.

Setter:

Sets the image source type.

Type:

str

property type#

The image format type. Valid values are ‘jpg’, ‘png’, and ‘bmp’.

Getter:

Gets the image format type.

Setter:

Sets the image format type.

Type:

str

property window: Any#

ReportManager class#

class ReportManager(**kwargs)#

Bases: object

ReportManager class can provide information about all available report sessions and the active report session.

getAllSessionNames()#

Method to return list of all available report session names.

Returns:

All report session names

Return type:

list

property activeSession#

The active session.

Getter:

Gets the active session name.

Setter:

Sets the active session.

Type:

str

ReportSession class#

class ReportSession(name=None, **kwargs)#

Bases: object

ReportSession can create new report session or return an existing report session.

If ‘name’ value is None, ReportSession can create new session with unique name.

If ‘name’ value is not None and session of ‘name’ does not exists, then ReportSession creates new session.

If ‘name’ value is not None and session of ‘name’ exists, then ReportSession returns existing session.

Parameters:

value (str) – Report session name

close()#
delete(objects)#

Method to delete entities from the session.

Parameters:

objects (Single object or list of Table | Text | Image | Presentation | Slide | SlideImage | SlideTable | SlideText | Chapter | Document | DocImage | DocTable | DocText) – Entity object to be deleted or list of entity objects to be deleted

get(entity_type, entity_name)#

Method to find and return an entity object based on entity type and name. If not found, returns None.

Parameters:
Returns:

Report entity object

Return type:

Table | Text | Image | Presentation | Slide | SlideImage | SlideTable | SlideText | Chapter | Document

getLayouts(output_type=None)#

Method to return all layout objects or layout names in the session.

Parameters:

output_type (str | None) – Valid values are ‘name’ and None.

Returns:

List of layout names or layout objects

Return type:

list

paste(paste_objects, destination)#

Method to copy entities and create new entities in the destination.

Parameters:
  • paste_objects (Single object or list of DocImage | DocTable | DocText) – Entity object to be pasted or list of entity objects to be pasted

  • destination (Document | Chapter) – Destination object where entity will be pasted

reset()#

Method to delete all entities present in the report session.

property activePresentation#

The active presentation in the report session.

Getter:

Gets the active presentation name.

Setter:

Sets the active presentation.

Type:

str

property name#

Returns report session name.

Returns:

Report session name

Return type:

str

property session#

Table class#

class Table(name=None, **kwargs)#

Bases: CommonProperties

Table class creates table entity.

If ‘name’ value is None, creates new table with unique name.

If ‘name’ value is not None and no entity of same name exists in specified report session, a new table gets created with given name.

If ‘name’ value is not None and any entity of same name exists in specified session, an error is returned.

Parameters:
  • name (str) – Table name.

  • session (ReportSession) – Session name. If not specified, uses currently active report session name.

  • datafile (str) – CSV file path.

addColumn()#

Method to add new column to table.

exportCsv(file: str) int#

Method to export the table content to a CSV file.

Parameters:

file (str) – CSV file path

loadCsv(file: str) int#

Method to loads content of a CSV file to the table entity.

Parameters:

file (str) – CSV file path

removeColumn(index: int)#

Method to remove column at specified index.

Parameters:

col (int) – Column index

removeRow(index: int)#

Method to remove row at specified index.

Parameters:

row (int) – Row index

setAttributes(**kwargs)#

Method to set multiple attributes.

Parameters:

kwargs (dict) – Valid keywords are name, csvFile, caption, split, splitBy, maxRows, maxColumns, and stretch.

setCellValue(row: int, col: int, value)#

Method to set cell value for at particular index.

Parameters:
  • row (int) – Row index

  • col (int) – Column index

setColumnColor(index: int = 0, color: list = [0, 0, 0])#

Method to set column color.

Parameters:
  • index (int) – Column index

  • color (list) – RGB color

setColumnWidth(index: int, width: float)#

Method to set column width.

Parameters:
  • index (int) – Column index

  • width (float) – Column width

setDimension(rows: int, cols: int)#

Method to set number of rows and columns for table.

Parameters:
  • rows (int) – Row count

  • cols (int) – Column count

setRowColor(index: int = 0, color: list = [0, 0, 0])#

Method to set row color.

Parameters:
  • index (int) – Row index

  • color (list) – RGB color

setRowHeight(row_index: int, height: float)#

Method to set row height.

Parameters:
  • index (int) – Row index

  • height (float) – Row height

property autoFilter#

The flag to activate or deactivate autofilter.

Getter:

Gets the status of the autofilter.

Setter:

Sets the status of the autofilter.

Type:

bool

property autoSort#

The flag to activate or deactivate autosort.

Getter:

Gets the status of the autosort.

Setter:

Sets the status of the autosort.

Type:

bool

property autoToolTip#

The flag to activate or deactivate autotooltip.

Getter:

Gets the status of the autotooltip.

Setter:

Sets the status of the autotooltip.

Type:

bool

property borderVisibility#

The table border visibility. An enumeration.

Getter:

Gets the table border visibility.

Setter:

Sets the table border visibility.

Type:

TableBordersVisibility

property caption#

The table caption.

Getter:

Gets the table caption.

Setter:

Sets the table caption.

Type:

str

property columns#

Returns table column count.

Returns:

Column count

Return type:

int

property csvFile#

The path of the CSV file loaded as the table data.

Getter:

Gets the table CSV file path.

Setter:

Sets the table CSV file path.

Type:

str

property fontsize#

The font size.

Getter:

Gets the name of the size.

Setter:

Sets the name of the size.

Type:

str

property name#

The name of the entity.

Getter:

Gets the name of the entity.

Setter:

Sets the name of the entity.

Type:

str

property rows#

Returns table row count.

Returns:

Row count

Return type:

int

property session#

Returns session to which this entity belongs.

Returns:

Report session

Return type:

ReportSession

property stretch#

The flag to activate or deactivate the table stretch.

Getter:

Gets the status of the table stretch.

Setter:

Sets the status of the table stretch.

Type:

bool

TableBordersVisibility class#

enum TableBordersVisibility(value)#

Valid values are as follows:

ALL_BORDERS = <TableBordersVisibility.ALL_BORDERS: 0>#
NO_BORDERS = <TableBordersVisibility.NO_BORDERS: 1>#
BOTTOM = <TableBordersVisibility.BOTTOM: 2>#
TOP = <TableBordersVisibility.TOP: 3>#
LEFT = <TableBordersVisibility.LEFT: 4>#
RIGHT = <TableBordersVisibility.RIGHT: 5>#
INSIDE_HORIZONTAL = <TableBordersVisibility.INSIDE_HORIZONTAL: 6>#
INSIDE_VERTICAL = <TableBordersVisibility.INSIDE_VERTICAL: 7>#
ALL_OUTSIDE = <TableBordersVisibility.ALL_OUTSIDE: 8>#
ALL_INSIDE = <TableBordersVisibility.ALL_INSIDE: 9>#

Text class#

class Text(name=None, **kwargs)#

Bases: CommonProperties

Text class creates a new text entity.

If ‘name’ value is None, creates new text with unique name.

If ‘name’ value is not None and session of ‘name’ does not exists, then new text gets created with given name

If ‘name’ value is not None and session of ‘name’ exists, then error thrown.

Parameters:
  • name (str) – Text entity name

  • session (ReportSession) – Session name. If not specified, uses currently active report session name.

  • text (str) – Text content

addParagraph()#

Method to add new paragraph.

Returns:

Paragraph entity

Return type:

Paragraph

getParagraph(index: int = 0)#

Method to return paragraph present at ‘index’.

Parameters:

index (int) – Index of paragraph in text runs

Returns:

Paragraph entity

Return type:

Paragraph

removeParagraph(index: int)#

Method to remove paragraph present at ‘index’.

Parameters:

index (int) – Index of paragraph in text runs

setAttributes(**kwargs)#

Method to set multiple attributes.

Parameters:

kwargs (dict) – Valid keywords are name, text, ensureFit, and alignment.

property alignment#

The text alignment.

Getter:

Gets the text alignment.

Setter:

Sets the text alignment.

Type:

int

property name#

The name of the entity.

Getter:

Gets the name of the entity.

Setter:

Sets the name of the entity.

Type:

str

property session#

Returns session to which this entity belongs.

Returns:

Report session

Return type:

ReportSession

property text#

The default run text content.

Getter:

Gets the default run text content.

Setter:

Sets the default run text content.

Type:

str