Excel

class Excel(source)

Decode an Excel file.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns tables as a map to mimic previous versions reading the data.

Functions

Link copied to clipboard
fun appendRow(sheet: String, row: List<CellValue?>)

Appends row iterables just after the last filled index in sheet. If sheet does not exist it will be automatically created.

Link copied to clipboard
fun copy(fromSheet: String, toSheet: String)

Copies the content of fromSheet into toSheet. fromSheet should exist in tables.keys. If toSheet does not exist it will be automatically created.

Link copied to clipboard
fun delete(sheet: String)

If sheet exists in tables.keys and tables.keys.size >= 2, it will be deleted.

Link copied to clipboard

Sets the edited values of sheetMap into the files and exports the file.

Link copied to clipboard
fun findAndReplace(sheet: String, source: <Error class: unknown class>, target: String, first: Int = -1, startingRow: Int = -1, endingRow: Int = -1, startingColumn: Int = -1, endingColumn: Int = -1): Int

Returns the count of replaced source occurrences with target. source can be a Regex or a String. Optional first limits replacement to the first N occurrences.

Link copied to clipboard
operator fun get(sheet: String): Sheet

Returns the SheetObject of sheet. If the sheet does not exist it will be created with a new Sheet Object.

Link copied to clipboard

Returns the name of the default sheet (the sheet which opens first when the xlsx file is opened).

Link copied to clipboard

Returns a list of cell IDs for previously merged cells.

Link copied to clipboard

Returns Map<String, Sheet> where key is the Sheet Name and value is the Sheet Object.

Link copied to clipboard
fun insertColumn(sheet: String, columnIndex: Int)

Inserts an empty column in sheet at position columnIndex. If columnIndex< 0 it will not execute. If sheet does not exist it will be created automatically.

Link copied to clipboard
fun insertRow(sheet: String, rowIndex: Int)

Inserts an empty row in sheet at position rowIndex. If rowIndex< 0 it will not execute. If sheet does not exist it will be created automatically.

Link copied to clipboard
fun insertRowIterables(sheet: String, row: List<CellValue?>, rowIndex: Int, startingColumn: Int = 0, overwriteMergedCells: Boolean = true)

Adds the row iterables at the given rowIndex in sheet. If sheet does not exist it will be automatically created.

Link copied to clipboard
fun link(sheet1: String, existingSheetObject: Sheet)

Links existingSheetObject with sheet1. If sheet1 does not exist it will be automatically created. After linkage, operations on sheet1 will also be performed on existingSheetObject and vice-versa.

Link copied to clipboard
fun merge(sheet: String, start: CellIndex, end: CellIndex, customValue: CellValue? = null)

Merges the cells from start to end. If customValue is not defined, it looks for the first available value in range row-wise left to right. If sheet does not exist it will be automatically created.

Link copied to clipboard
fun removeColumn(sheet: String, columnIndex: Int)

If sheet exists and columnIndex< maxColumns, removes column at columnIndex.

Link copied to clipboard
fun removeRow(sheet: String, rowIndex: Int)

If sheet exists and rowIndex< maxRows, removes row at rowIndex.

Link copied to clipboard
fun rename(oldSheetName: String, newSheetName: String)

Renames oldSheetName to newSheetName. oldSheetName must exist and newSheetName must not exist.

Link copied to clipboard
operator fun set(sheet: String, sheetObject: Sheet)

If sheet does not exist it will be automatically created with contents of sheetObject. Newly created sheet will have a separate reference and will not be linked to sheetObject.

Link copied to clipboard
fun setDefaultSheet(sheetName: String): Boolean

Returns true if sheetName is successfully set as the default opening sheet, otherwise false.

Link copied to clipboard
fun unLink(sheet: String)

If sheet is linked with any other sheet's object, the link will be broken.

Link copied to clipboard
fun unMerge(sheet: String, unmergeCells: String)

Unmerges the merged cells specified by unmergeCells.

Link copied to clipboard
fun updateCell(sheet: String, cellIndex: CellIndex, value: CellValue?, cellStyle: CellStyle? = null)

Updates the contents of sheet at cellIndex. Indexing starts from 0; e.g. CellIndex.indexByColumnRow(0, 0) or CellIndex.indexByString("A3"). If sheet does not exist it will be automatically created.