comet.excel

The comet.excel module provides access to reading and writing Microsoft Excel files (.xlsx).

See also

Class CExcelBook

Opened Excel file with methods to fetch and write data.

Methods

comet.excel.open(path: str, autoSave: bool = False, useGlobal: bool = True) CExcelBook

Open an Excel file.

Parameters:
  • path (str) – The file path. May start with $ALIAS names.

  • autoSave (bool) – Should the file be saved automatically before closing?

  • useGlobal (bool) –

    Open file globally or only for the current script?

    • True

      Open file globally. The Excel file remains open until the current data connection is closed or a until call to CExcelBook.close(). If the file has already been opened in a previous script, this already opened file is returned. Since you probably want to use the file in multiple scripts, this is the recommended procedure.

    • False : Open file only for the current script. In this case the received result of the function must be closed again with CExcelBook.close()!

Returns:

The opened file

Return type:

CExcelBook

Raises:
Available:

InDesign® comet_pdf® Illustrator®

See also:

CExcelBook.close()

CScript:

excel::open

comet.excel.indexToColumn(index: int) str

Conversion of a column number into the form A, B, …, Z, AA, AB, …, which is commonly used in Excel.

Parameters:

index (int) – The index to convert.

Returns:

The column name

Return type:

str

Raises:

TypeError – When parameter types are invalid

Available:

InDesign® comet_pdf® Illustrator®

CScript:

excel::i2col

comet.excel.columnToIndex(column: str) int

Conversion of an Excel column name of the form A, B, …, Z, AA, AB, … …into an index number.

Parameters:

column (str) –

String consisting of the letters A-Z and a-z.

Lower case letters are automatically evaluated as upper case letters.

Please note that Excel supports a maximum of 2^14 = 16.384 columns only.

This corresponds to the string ‘XFD’.

Returns:

The index of the column

Return type:

int

Raises:

TypeError – When parameter types are invalid

Available:

InDesign® comet_pdf® Illustrator®

CScript:

excel::col2i