Workbook
classin packageklyn.io.xlsx
public class Workbook extends Object implements AutoClosable:
└ Workbook
All Implemented Interfaces: AutoClosable

XLSX workbook reader and writer.

The writer produces a real OpenXML workbook with worksheets, column widths, inline string cells, numeric cells, boolean cells and simple cell formats. Reading currently supports uncompressed ZIP entries, which includes files produced by this writer through Klyn's ZipArchiver.

@example `klyn import klyn.io.xlsx

try workbook = Workbook("spies.xlsx", WorkbookMode.CREATE): sheet = workbook.addWorksheet("Spies") sheet.write("A1", "James")

Properties
Modifier and Type Member Description
public readonly property sheetCount
sheetCount as Int:
Number of worksheets in the workbook.
public readonly property worksheets
worksheets as WorkbookWorksheets:
Ordered worksheet collection.
Properties inherited from Object: type
Constructors
Modifier and Type Member Description
public Workbook
Workbook(filePath as String, mode as WorkbookMode = WorkbookMode.READ) throws IOException:
Creates or reads a workbook.
public Workbook
Workbook(path as Path, mode as WorkbookMode = WorkbookMode.READ) throws IOException:
Creates or reads a workbook.
Methods
Modifier and Type Member Description
public addChart
addChart(options as Map<String, Object>) as Chart:
Creates a chart owned by this workbook.
public addFormat
addFormat(options as Map<String, Object>) as Format:
Adds a cell format to the workbook style table.
public addWorksheet
addWorksheet(name as String = "") as Worksheet:
Adds a worksheet.
public override close
close() as Void throws IOException:
Closes the workbook.
public save
save() as Void throws IOException:
Writes the workbook to its configured path.
public save
save(filePath as String) as Void throws IOException:
Writes the workbook to a specific path.
public worksheet
worksheet(index as Int) as Worksheet:
Returns a worksheet by zero-based index.
public worksheet
worksheet(name as String) as Worksheet:
Returns a worksheet by name.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Methods inherited from AutoClosable: close