Excel class Core
The main class for reading, creating, and editing Excel .xlsx files.
- Available extensions
Constructors
- Excel.createExcel()
-
Creates a new blank Excel workbook with a default sheet.
factory
- Excel.decodeBuffer(InputStream input)
-
Decodes an
.xlsxfile from an InputStream.factory -
Excel.decodeBytes(List<
int> data) -
Decodes an
.xlsxor legacy binary.xlsfile from a byte list.factory - Excel.fromCsv(String csv, {String sheetName = 'Sheet1', bool inferTypes = true, CsvConfig? config, CsvSchema? schema})
-
Creates a new workbook from CSV
csv, with the data in a single sheet.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
rowafter the last filled row insheet. -
copy(
String fromSheet, String toSheet) → void -
Copies contents of
fromSheetintotoSheet. -
delete(
String sheet) → void -
Deletes
sheetif it exists and is not the last sheet. -
encode(
) → List< int> ? -
Encodes the workbook as
.xlsxbytes. -
encodeAsync(
) → Future< List< int> ?> -
Encodes the workbook as
.xlsxbytes on a background isolate, so a large save (cell serialization + zip compression) does not block the UI thread. -
encodeToStream(
void onBytes(List< int> bytes)) → void -
Encodes the workbook as
.xlsx, forwarding each chunk of the zip toonBytesas it is produced instead of buffering the whole file in memory. -
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
sourcewithtargetinsheet. 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") insheet. -
importCsv(
String csv, {String? sheetName, bool inferTypes = true, CsvConfig? config, CsvSchema? schema}) → Sheet -
Available on Excel, provided by the ExcelCsv extension
Importscsvinto a worksheet of this workbook and returns that sheet. -
insertColumn(
String sheet, int columnIndex) → void -
Inserts an empty column at
columnIndexinsheet. -
insertRow(
String sheet, int rowIndex) → void -
Inserts an empty row at
rowIndexinsheet. -
insertRowIterables(
String sheet, List< CellValue?> row, int rowIndex, {int startingColumn = 0, bool overwriteMergedCells = true}) → void -
Inserts
rowvalues atrowIndexinsheet. -
link(
String sheet1, Sheet existingSheetObject) → void -
Links
sheet1toexistingSheetObjectso changes to one affect the other. -
merge(
String sheet, CellIndex start, CellIndex end, {CellValue? customValue}) → void -
Merges cells from
starttoendinsheet. -
moveSheet(
String sheetName, {required int toIndex}) → void -
Moves
sheetNameto positiontoIndexin 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/orlockWindows(window size & position). -
recalculate(
{Iterable< String> ? changed}) → 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
columnIndexfromsheet. -
removeDefinedName(
String name, {int? localSheetId}) → bool -
Removes the defined
namein the given scope (localSheetId/ global). Returns whether a name was removed. -
removeRow(
String sheet, int rowIndex) → void -
Removes the row at
rowIndexfromsheet. -
rename(
String oldSheetName, String newSheetName) → void -
Renames
oldSheetNametonewSheetName. -
save(
{String fileName = 'FlutterExcel.xlsx'}) → List< int> ? -
Starts Saving the file.
On Web -
setDefaultSheet(
String sheetName) → bool -
Sets
sheetNameas the default opening sheet. Returnstrueon success. -
setDefinedName(
String name, String refersTo, {int? localSheetId, String? comment, }) → void -
Defines (or replaces) a named range/formula
namethat refers torefersTo(e.g."'Sheet1'!\$A\$1:\$B\$2"). -
streamRows(
String sheetName) → Iterable< List< CellValue?> > -
Available on Excel, provided by the SheetStream extension
ReadssheetNamerow by row without building the sheet's cell grid. -
streamRowsAsMaps(
String sheetName, {int headerRow = 0}) → Iterable< Map< String, dynamic> > -
Available on Excel, provided by the SheetStream extension
ReadssheetNamerow by row as maps keyed by a header row. -
toCsv(
{String? sheet, CsvConfig? config, bool formulasAsText = false}) → String - Serialises one sheet of this workbook to CSV text.
-
toJson(
{String? sheet, int? headerRow = 0, bool skipEmptyRows = true, bool formulasAsText = false, bool pretty = false}) → String - Serialises this workbook to a JSON string.
-
toString(
) → String -
A string representation of this object.
inherited
-
unLink(
String sheet) → void -
Breaks the link between
sheetand any shared sheet object. -
unMerge(
String sheet, String unmergeCells) → void -
Unmerges the given
unmergeCellsrange (e.g."A1:A2") insheet. -
unprotectWorkbook(
) → void - Removes workbook protection.
-
updateCell(
String sheet, CellIndex cellIndex, CellValue? value, {CellStyle? cellStyle}) → void -
Updates a cell's value and optional style at
cellIndexinsheet. -
validateRows(
String sheetName, CsvSchema schema, {int headerRow = 0}) → Iterable< SheetRowValidation> -
Available on Excel, provided by the SheetValidation extension
ValidatessheetNameone row at a time againstschema.
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
sheetcontents to a clone ofsheetObject.
Static Methods
-
decodeBytesAsync(
List< int> data) → Future<Excel> -
Decodes an
.xlsxfile from a byte list on a background isolate, so a large workbook can be opened without blocking the UI thread.