Excel class Core

The main class for reading, creating, and editing Excel .xlsx files.

Constructors

Excel.createExcel()
Creates a new blank Excel workbook with a default sheet.
factory
Excel.decodeBuffer(InputStream input)
Decodes an .xlsx file from an InputStream.
factory
Excel.decodeBytes(List<int> data)
Decodes an .xlsx file from a byte list.
factory

Properties

definedNames List<DefinedName>
The workbook's defined names (named ranges/formulas).
no setter
formula FormulaApi
The formula subsystem — register custom functions for Sheet.evaluate.
latefinal
hashCode int
The hash code for this object.
no setterinherited
isWorkbookProtected bool
Whether the workbook is protected (its structure and/or windows locked).
no setter
parser ↔ Parser
The internal parser that decoded this workbook. Exposed for advanced use; not part of the supported public surface and may change between releases.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sheetOrder List<String>
The sheet names in their current tab order.
no setter
sheets Map<String, Sheet>
Returns all sheets as a map of sheet names to Sheet objects.
no setter
tables Map<String, Sheet>
Returns all sheets as a map of sheet names to Sheet objects.
no setter
workbookStructureLocked bool
Whether the workbook structure is locked — sheets cannot be added, deleted, renamed, moved, hidden, or unhidden in Excel.
no setter
workbookWindowsLocked bool
Whether the workbook windows are locked to their size and position.
no setter

Methods

appendRow(String sheet, List<CellValue?> row) → void
Appends row after the last filled row in sheet.
copy(String fromSheet, String toSheet) → void
Copies contents of fromSheet into toSheet.
delete(String sheet) → void
Deletes sheet if it exists and is not the last sheet.
encode() List<int>?
Encodes the workbook as .xlsx bytes.
findAndReplace(String sheet, Pattern source, dynamic target, {int first = -1, int startingRow = -1, int endingRow = -1, int startingColumn = -1, int endingColumn = -1}) int
Replaces occurrences of source with target in sheet. Returns the count of replacements.
getDefaultSheet() String?
Returns the name of the default sheet.
getMergedCells(String sheet) List<String>
Returns a list of merged cell ranges (e.g. "A1:B2") in sheet.
insertColumn(String sheet, int columnIndex) → void
Inserts an empty column at columnIndex in sheet.
insertRow(String sheet, int rowIndex) → void
Inserts an empty row at rowIndex in sheet.
insertRowIterables(String sheet, List<CellValue?> row, int rowIndex, {int startingColumn = 0, bool overwriteMergedCells = true}) → void
Inserts row values at rowIndex in sheet.
Links sheet1 to existingSheetObject so changes to one affect the other.
merge(String sheet, CellIndex start, CellIndex end, {CellValue? customValue}) → void
Merges cells from start to end in sheet.
moveSheet(String sheetName, {required int toIndex}) → void
Moves sheetName to position toIndex in the tab order (0 = first).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
protectWorkbook({String? password, bool lockStructure = true, bool lockWindows = false}) → void
Protects the workbook, locking its lockStructure (sheet add/delete/ rename/move/hide) and/or lockWindows (window size & position).
recalculate() → void
Recomputes every formula cell in the workbook and stores each result as the formula's cached value (its <v>), so a saved file shows results without the spreadsheet app having to recalculate.
removeColumn(String sheet, int columnIndex) → void
Removes the column at columnIndex from sheet.
removeDefinedName(String name, {int? localSheetId}) bool
Removes the defined name in the given scope (localSheetId / global). Returns whether a name was removed.
removeRow(String sheet, int rowIndex) → void
Removes the row at rowIndex from sheet.
rename(String oldSheetName, String newSheetName) → void
Renames oldSheetName to newSheetName.
save({String fileName = 'FlutterExcel.xlsx'}) List<int>?
Starts Saving the file. On Web
setDefaultSheet(String sheetName) bool
Sets sheetName as the default opening sheet. Returns true on success.
setDefinedName(String name, String refersTo, {int? localSheetId, String? comment, bool hidden = false}) → void
Defines (or replaces) a named range/formula name that refers to refersTo (e.g. "'Sheet1'!\$A\$1:\$B\$2").
toString() String
A string representation of this object.
inherited
Breaks the link between sheet and any shared sheet object.
unMerge(String sheet, String unmergeCells) → void
Unmerges the given unmergeCells range (e.g. "A1:A2") in sheet.
unprotectWorkbook() → void
Removes workbook protection.
updateCell(String sheet, CellIndex cellIndex, CellValue? value, {CellStyle? cellStyle}) → void
Updates a cell's value and optional style at cellIndex in sheet.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String sheet) Sheet
Returns the Sheet for sheet, creating it if it doesn't exist.
operator []=(String sheet, Sheet sheetObject) → void
Sets sheet contents to a clone of sheetObject.