### Run example utility Source: https://pub.dev/documentation/excel2003/latest/index.html Execute the provided example command-line utility to read an .xls file. ```bash # use your own .xls file or copy one into the repo root dart run example/xls_reader_example.dart path/to/book.xls ``` -------------------------------- ### Install excel2003 package Source: https://pub.dev/documentation/excel2003/latest/index.html Add the package to your Dart or Flutter project using the pub CLI. ```bash dart pub add excel2003 ``` -------------------------------- ### Read Excel file content Source: https://pub.dev/documentation/excel2003/latest/index.html Example demonstrating how to open an .xls file and iterate through its sheets, rows, and columns to print cell values. ```dart import 'package:excel2003/excel2003.dart'; void main() { final reader = XlsReader('路径/到/文件.xls'); reader.open(); print('工作表:${reader.sheetNames}'); final sheet = reader.sheet(0); for (int row = sheet.firstRow; row < sheet.lastRow; row++) { for (int col = sheet.firstCol; col < sheet.lastCol; col++) { final value = sheet.cell(row, col); if (value != null) { print('Cell($row,$col)=$value'); } } } } ``` -------------------------------- ### Example usage of XlsReader Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader-class.html Opens an .xls file, prints sheet count, and iterates over all sheets and cells to print non-null values. ```dart final reader = XlsReader('path/to/book.xls'); reader.open(); print('Sheet count: ${reader.sheetCount}'); for (int i = 0; i < reader.sheetCount; i++) { final sheet = reader.sheet(i); print('Sheet "${sheet.name}": ${sheet.rowCount} rows, ${sheet.colCount} cols'); for (int r = 0; r < sheet.rowCount; r++) { for (int c = 0; c < sheet.colCount; c++) { final value = sheet.cell(r, c); if (value != null) { print('Cell($r, $c): $value'); } } } } ``` -------------------------------- ### sheetCount Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheetCount.html Gets the number of sheets in the workbook. ```APIDOC ## sheetCount ### Description Returns the number of sheets in the workbook. ### Property `int get sheetCount` ### Returns - **int** - The number of sheets in the workbook. ### Implementation ```dart int get sheetCount => _sheets.length; ``` ``` -------------------------------- ### rows getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/rows.html Gets all rows as a 2D list. This getter iterates over the row range and returns a list of row lists. ```APIDOC ## rows getter ### Description Gets all rows as a 2D list. ### Method Getter ### Return Type List> ### Implementation ```dart List> get rows { final result = >[]; for (int r = _firstRow; r < _lastRow; r++) { result.add(row(r)); } return result; } ``` ``` -------------------------------- ### getCell(int row, int col) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/getCell.html Gets the cell at the specified row and column. Returns null if the cell is empty or doesn't exist. ```APIDOC ## getCell(int row, int col) ### Description Gets the cell at the specified row and column. Returns null if the cell is empty or doesn't exist. ### Method `XlsCell? getCell(int row, int col)` ### Parameters - **row** (int) - Required - The row index of the cell. - **col** (int) - Required - The column index of the cell. ### Returns - **XlsCell?** - The cell at the specified position, or null if the cell is empty or doesn't exist. ### Implementation ```dart XlsCell? getCell(int row, int col) { return _cells[row]?[col]; } ``` ``` -------------------------------- ### Iterate sheets and cells Source: https://pub.dev/documentation/excel2003/latest/index.html Lists sheet names, gets the first sheet, and iterates the used range. firstRow/firstCol are inclusive, lastRow/lastCol are exclusive. Prints non-null cell values. ```Dart // list sheet names print(reader.sheetNames); // grab sheet 0 (first sheet) final sheet = reader.sheet(0); // iterate the used range; firstRow/firstCol are inclusive, lastRow/lastCol // are exclusive (similar to Dart ranges) for (int r = sheet.firstRow; r < sheet.lastRow; r++) { for (int c = sheet.firstCol; c < sheet.lastCol; c++) { final v = sheet.cell(r, c); if (v != null) print('Cell($r,$c): $v'); } } ``` -------------------------------- ### row(int rowIndex) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/row.html Gets a row as a list of cell values. The method takes a row index and returns a list of dynamic values representing the cells in that row. ```APIDOC ## row(int rowIndex) ### Description Gets a row as a list of cell values. ### Method row ### Parameters - **rowIndex** (int) - Required - The index of the row to retrieve. ### Returns List - A list of cell values in the specified row. ### Implementation ```dart List row(int rowIndex) { final result = []; for (int c = _firstCol; c < _lastCol; c++) { result.add(cell(rowIndex, c)); } return result; } ``` ``` -------------------------------- ### rowCount getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/rowCount.html Gets the number of rows with data in the sheet. This property is read-only and returns an integer. ```APIDOC ## rowCount property ### Description Gets the number of rows with data in the sheet. ### Property `int get rowCount` ### Returns - **int** - The number of rows with data. ### Implementation ```dart int get rowCount => _lastRow - _firstRow; ``` ``` -------------------------------- ### int get lastRow Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/lastRow.html Gets the last row index (exclusive) of the sheet. This property is read-only and returns an integer value. ```APIDOC ## int get lastRow ### Description Gets the last row index (exclusive) of the sheet. ### Property Signature int get lastRow ### Return Value - **int** - The last row index (exclusive). ### Implementation ```dart int get lastRow => _lastRow; ``` ``` -------------------------------- ### cell(int row, int col) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/cell.html Gets the cell value at the specified row and column. Returns null if the cell is empty or doesn't exist. ```APIDOC ## cell(int row, int col) ### Description Gets the cell value at the specified row and column. Returns null if the cell is empty or doesn't exist. ### Method cell ### Parameters - **row** (int) - Required - The row index of the cell. - **col** (int) - Required - The column index of the cell. ### Returns - **dynamic** - The value of the cell, or null if the cell is empty or doesn't exist. ### Implementation ``` dynamic cell(int row, int col) { return _cells[row]?[col]?.value; } ``` ``` -------------------------------- ### int get colCount Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/colCount.html Getter property that returns the number of columns with data in the sheet. It is implemented as the difference between the last and first column indices. ```APIDOC ## int get colCount ### Description Returns the number of columns with data in the sheet. ### Property - **Type**: int - **Getter**: colCount ### Implementation ```dart int get colCount => _lastCol - _firstCol; ``` ``` -------------------------------- ### column(int colIndex) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/column.html Gets a column as a list of cell values. The method iterates over all rows in the sheet and collects the value of the cell at the given column index for each row. ```APIDOC ## column(int colIndex) ### Description Gets a column as a list of cell values. The method iterates over all rows in the sheet and collects the value of the cell at the given column index for each row. ### Method column ### Signature List column(int colIndex) ### Parameters - **colIndex** (int) - Required - The zero-based index of the column to retrieve. ### Returns - **List** - A list of cell values for the specified column, one per row. ### Implementation ```dart List column(int colIndex) { final result = []; for (int r = _firstRow; r < _lastRow; r++) { result.add(cell(r, colIndex)); } return result; } ``` ``` -------------------------------- ### Iterable get cells Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/cells.html Returns an iterable of all non-empty cells in the sheet. This getter is used to access the cells that contain data, skipping empty ones. ```APIDOC ## Iterable get cells ### Description Returns an iterable of all non-empty cells in the sheet. This getter is used to access the cells that contain data, skipping empty ones. ### Method Getter ### Return Type Iterable ### Implementation ```dart Iterable get cells sync* { for (final rowMap in _cells.values) { for (final cell in rowMap.values) { if (cell.type != CellType.empty) { yield cell; } } } } ``` ``` -------------------------------- ### numericValue getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/numericValue.html Gets the numeric value of the cell. Returns a double if the cell value is a number or a parseable string, otherwise returns null. ```APIDOC ## numericValue getter ### Description Returns the cell value as a number, or null if not a number. ### Method GET ### Endpoint `numericValue` ### Parameters None ### Return Value - **double?** - The numeric value of the cell, or null if the value is not a number. ### Implementation ```dart double? get numericValue { if (value is num) return value.toDouble(); if (value is String) return double.tryParse(value); return null; } ``` ``` -------------------------------- ### XlsReader.new Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/XlsReader.html Documentation for the XlsReader constructor, which initializes an instance with a file path. ```APIDOC ## XlsReader.new ### Description Creates a new XlsReader instance with the specified path to an Excel 2003 file. ### Constructor XlsReader(String path) ### Parameters - **path** (String) - Required - The path to the Excel file to read. ### Implementation ```dart XlsReader(this.path); ``` ``` -------------------------------- ### open method implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/open.html Opens and parses the workbook. Throws ArgumentError if the file does not exist. Sets _opened to true after successful parsing. ```dart void open() { if (_opened) return; if (!File(path).existsSync()) { throw ArgumentError('File not found: $path'); } _ole2.open(path); _parseWorkbook(); _opened = true; } ``` -------------------------------- ### XlsReader Constructor Implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/XlsReader.html Initializes the XlsReader with the specified file path. ```dart XlsReader(this.path); ``` -------------------------------- ### XlsReader.fromBytes factory constructor implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/XlsReader.fromBytes.html Creates an XlsReader from a Uint8List of bytes. The implementation creates an XlsReader with an empty string and then opens the bytes internally. ```dart factory XlsReader.fromBytes(Uint8List bytes) { final reader = XlsReader(''); reader._openBytes(bytes); return reader; } ``` -------------------------------- ### XlsReader.fromBytes(Uint8List bytes) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/XlsReader.fromBytes.html Creates an XlsReader from the provided bytes. This factory constructor initializes an XlsReader instance by reading the given byte array. ```APIDOC ## XlsReader.fromBytes(Uint8List bytes) ### Description Creates an XlsReader from bytes. ### Constructor XlsReader.fromBytes(Uint8List bytes) ### Parameters - **bytes** (Uint8List) - Required - The byte array containing the Excel file data. ### Implementation ```dart factory XlsReader.fromBytes(Uint8List bytes) { final reader = XlsReader(''); reader._openBytes(bytes); return reader; } ``` ``` -------------------------------- ### Open a workbook with XlsReader Source: https://pub.dev/documentation/excel2003/latest/index.html Creates an XlsReader from a file path and opens it. The open() method throws if the file is missing or not a valid BIFF8 stream. After opening, the sheetCount property is available. ```Dart import 'package:excel2003/excel2003.dart'; void main() { // Create reader from file path. You can also call // `XlsReader.fromBytes(bytes)` if you already have the workbook data. final reader = XlsReader('path/to/workbook.xls'); reader.open(); // throws if file is missing or not a valid BIFF8 stream print('Opened workbook with ${reader.sheetCount} sheets'); } ``` -------------------------------- ### XlsCell constructor Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell-class.html Creates a new XlsCell instance with the specified row, column, type, value, and optional xfIndex. ```APIDOC ## XlsCell({required int row, required int col, required CellType type, required dynamic value, int xfIndex = 0}) ### Description Creates a new XlsCell instance representing a cell in a worksheet. ### Parameters - **row** (int) - Required - The row index of the cell. - **col** (int) - Required - The column index of the cell. - **type** (CellType) - Required - The type of the cell. - **value** (dynamic) - Required - The value of the cell. - **xfIndex** (int) - Optional - The formatting index, defaults to 0. ``` -------------------------------- ### Read Excel 97-2003 files with XlsReader Source: https://pub.dev/documentation/excel2003/latest/excel2003 Demonstrates opening an .xls file, listing sheet names, iterating through cells, and converting sheet data to maps. ```dart import 'package:excel2003/excel2003.dart'; void main() { final reader = XlsReader('path/to/workbook.xls'); reader.open(); // List all sheets print('Sheets: ${reader.sheetNames}'); // Access first sheet final sheet = reader.sheet(0); print('Sheet "${sheet.name}": ${sheet.rowCount} rows'); // Read cell values for (int row = sheet.firstRow; row < sheet.lastRow; row++) { for (int col = sheet.firstCol; col < sheet.lastCol; col++) { final value = sheet.cell(row, col); if (value != null) { print('Cell($row, $col) = $value'); } } } // Or convert to maps using first row as headers final data = sheet.toMaps(); for (final row in data) { print(row); } } ``` -------------------------------- ### XlsCell methods Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell-class.html Methods available on the XlsCell class. ```APIDOC ## XlsCell Methods ### toString() → String Returns a string representation of this object. Overrides the default implementation. ``` -------------------------------- ### Implementation of xfIndex Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/xfIndex.html The xfIndex property is defined as a final integer. ```java final int xfIndex; ``` -------------------------------- ### toMaps method implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/toMaps.html Converts the sheet to a list of maps. Returns an empty list if there are no data rows. Uses the first row as headers, defaulting to 'Column$c' for empty header cells. Each subsequent row becomes a map with header keys. ```dart List> toMaps() { if (_lastRow <= _firstRow) return []; // Get headers from first row final headers = []; for (int c = _firstCol; c < _lastCol; c++) { final value = cell(_firstRow, c); headers.add(value?.toString() ?? 'Column$c'); } // Convert remaining rows to maps final result = >[]; for (int r = _firstRow + 1; r < _lastRow; r++) { final map = {}; for (int c = 0; c < headers.length; c++) { map[headers[c]] = cell(r, _firstCol + c); } result.add(map); } return result; } ``` -------------------------------- ### XlsCell({required int row, required int col, required CellType type, required dynamic value, int xfIndex = 0}) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/XlsCell.html Creates a new XlsCell instance with the specified row, column, type, value, and optional xfIndex. The xfIndex defaults to 0 if not provided. ```APIDOC ## XlsCell({required int row, required int col, required CellType type, required dynamic value, int xfIndex = 0}) ### Description Creates a new XlsCell instance with the specified row, column, type, value, and optional xfIndex. The xfIndex defaults to 0 if not provided. ### Parameters - **row** (int) - Required - The row index of the cell. - **col** (int) - Required - The column index of the cell. - **type** (CellType) - Required - The type of the cell. - **value** (dynamic) - Required - The value of the cell. - **xfIndex** (int) - Optional - The index of the cell format, defaults to 0. ### Implementation ```dart XlsCell({ required this.row, required this.col, required this.type, required this.value, this.xfIndex = 0, }); ``` ``` -------------------------------- ### toMaps() Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet-class.html Converts the sheet to a list of maps, using the first row as headers. ```APIDOC ## [toMaps] XlsSheet.toMaps() ### Description Converts the sheet to a list of maps (each row as a map). Uses the first row as headers. ### Method toMaps ### Signature List> toMaps() ### Parameters None ### Return (List>) - A list of maps, each mapping header names to cell values for a row. ``` -------------------------------- ### Convert a sheet to maps Source: https://pub.dev/documentation/excel2003/latest/index.html Treats the first non-empty row as column headers and returns a list of maps. Access values by header name, e.g., map['Name']. ```Dart final rows = sheet.toMaps(); for (final map in rows) { print(map['Name']); } ``` -------------------------------- ### Implementation of toString for XlsSheet Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/toString.html This override returns a formatted string containing the sheet name, row count, and column count. ```dart @override String toString() => 'XlsSheet("$name", rows: $rowCount, cols: $colCount)'; ``` -------------------------------- ### Implementation of toString method Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/toString.html This implementation returns a string containing the row, column, and value of the cell, formatted as 'Cell(row, col): value'. ```dart @override String toString() => 'Cell($row, $col): $value'; ``` -------------------------------- ### Implementation of firstCol property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/firstCol.html Retrieves the first column index using the _firstCol field. ```dart int get firstCol => _firstCol; ``` -------------------------------- ### Implementation of getCell method Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/getCell.html This snippet shows the internal implementation of the getCell method, which accesses the _cells map using the provided row and column indices. ```dart XlsCell? getCell(int row, int col) { return _cells[row]?[col]; } ``` -------------------------------- ### XlsCell Constructor Implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/XlsCell.html The implementation of the XlsCell constructor requiring row, col, type, and value, with a default xfIndex of 0. ```dart XlsCell({ required this.row, required this.col, required this.type, required this.value, this.xfIndex = 0, }); ``` -------------------------------- ### sheetNames Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheetNames.html Getter property that returns the names of all sheets in the Excel workbook as a list of strings. ```APIDOC ## sheetNames ### Description Returns the names of all sheets in the workbook. ### Property List get sheetNames ### Returns List - A list containing the names of all sheets. ### Implementation ```dart List get sheetNames => _sheets.map((s) => s.name).toList(); ``` ``` -------------------------------- ### Implementation of column method Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/column.html This method iterates through rows from _firstRow to _lastRow, collecting cell values at the specified colIndex into a list. ```dart List column(int colIndex) { final result = []; for (int r = _firstRow; r < _lastRow; r++) { result.add(cell(r, colIndex)); } return result; } ``` -------------------------------- ### name property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/name.html A final String property that holds the name of the sheet. ```APIDOC ## name property ### Description A final String property that holds the name of the sheet. ### Type String ### Modifiers final ### Implementation dart final String name; ``` -------------------------------- ### sheetByName(String name) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheetByName.html Returns a sheet by name. The method performs a case-insensitive search and returns null if no sheet matches. ```APIDOC ## sheetByName(String name) ### Description Returns a sheet by name. The method performs a case-insensitive search and returns null if no sheet matches. ### Method sheetByName ### Signature XlsSheet? sheetByName(String name) ### Parameters - **name** (String) - Required - The name of the sheet to find. ### Return Value - **XlsSheet?** - The sheet with the given name, or null if not found. ### Implementation ```dart XlsSheet? sheetByName(String name) { final index = _sheets.indexWhere( (s) => s.name.toLowerCase() == name.toLowerCase(), ); if (index < 0) return null; return sheet(index); } ``` ``` -------------------------------- ### Implementation of the sheet method Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheet.html This method retrieves a sheet by index, throwing a RangeError if the index is out of bounds. It uses the internal _sheets list and calls _parseSheet to return the XlsSheet object. ```dart XlsSheet sheet(int index) { if (index < 0 || index >= _sheets.length) { throw RangeError('Sheet index out of range: $index'); } final sheetInfo = _sheets[index]; return _parseSheet(sheetInfo); } ``` -------------------------------- ### firstCol getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/firstCol.html Getter for the first column index. Returns an integer representing the first column index. ```APIDOC ## firstCol property ### Description Returns the first column index. ### Property Signature int get firstCol ### Implementation ```dart int get firstCol => _firstCol; ``` ``` -------------------------------- ### sheet(int index) Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheet.html Returns a sheet by index. Throws a RangeError if the index is out of range. ```APIDOC ## sheet(int index) ### Description Returns a sheet by index. ### Method sheet ### Parameters #### Parameters - **index** (int) - Required - The index of the sheet to retrieve. ### Return Value - **XlsSheet** - The sheet at the specified index. ### Exceptions - **RangeError** - Thrown if the index is out of range (less than 0 or greater than or equal to the number of sheets). ### Implementation ```dart XlsSheet sheet(int index) { if (index < 0 || index >= _sheets.length) { throw RangeError('Sheet index out of range: $index'); } final sheetInfo = _sheets[index]; return _parseSheet(sheetInfo); } ``` ``` -------------------------------- ### firstRow getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/firstRow.html Getter that returns the first row index of the sheet. ```APIDOC ## firstRow getter ### Description Returns the first row index of the sheet. ### Method GET ### Endpoint firstRow ### Parameters None ### Request Example None ### Response #### Success Response - **return** (int) - The first row index. #### Response Example ``` int ``` ``` -------------------------------- ### String toString() Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/toString.html Returns a string representation of the XlsCell object. The implementation returns 'Cell($row, $col): $value'. ```APIDOC ## String toString() ### Description Returns a string representation of the XlsCell object. The default implementation provides a textual representation useful for debugging and logging. ### Method String toString() ### Implementation ```dart @override String toString() => 'Cell($row, $col): $value'; ``` ### Returns - **String** - A string representation of the cell in the format 'Cell(row, col): value'. ``` -------------------------------- ### XlsReader Class API Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader-class.html Code snippets for the XlsReader class methods and constructors. ```APIDOC ## XlsReader(String path) ### Description Creates an XlsReader instance from a file path. ### Constructor XlsReader(String path) ### Parameters - **path** (String) - Required - The path to the .xls file. ### Example ```dart final reader = XlsReader('path/to/book.xls'); ``` ``` ```APIDOC ## XlsReader.fromBytes(Uint8List bytes) ### Description Creates an XlsReader from bytes. This is a factory constructor. ### Constructor XlsReader.fromBytes(Uint8List bytes) ### Parameters - **bytes** (Uint8List) - Required - The bytes of the .xls file. ### Example ```dart final reader = XlsReader.fromBytes(bytes); ``` ``` ```APIDOC ## open() ### Description Opens and parses the workbook. ### Method void open() ### Parameters None. ### Example ```dart reader.open(); ``` ``` ```APIDOC ## sheet(int index) ### Description Returns a sheet by index. ### Method XlsSheet sheet(int index) ### Parameters - **index** (int) - Required - The index of the sheet. ### Returns - **XlsSheet** - The sheet at the given index. ### Example ```dart final sheet = reader.sheet(0); ``` ``` ```APIDOC ## sheetByName(String name) ### Description Returns a sheet by name. ### Method XlsSheet? sheetByName(String name) ### Parameters - **name** (String) - Required - The name of the sheet. ### Returns - **XlsSheet?** - The sheet with the given name, or null if not found. ### Example ```dart final sheet = reader.sheetByName('Sheet1'); ``` ``` -------------------------------- ### row method implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/row.html Returns a list of cell values for the given row index. Iterates from the first to the last column, adding each cell value to the result. ```dart List row(int rowIndex) { final result = []; for (int c = _firstCol; c < _lastCol; c++) { result.add(cell(rowIndex, c)); } return result; } ``` -------------------------------- ### rows getter implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/rows.html Returns all rows as a 2D list by iterating from _firstRow to _lastRow and calling row(r) for each index. ```dart content_copyList> get rows { final result = >[]; for (int r = _firstRow; r < _lastRow; r++) { result.add(row(r)); } return result; } ``` -------------------------------- ### sheetNames getter implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheetNames.html Returns a list of sheet names by mapping each sheet object to its name property. This getter is part of the XlsReader class. ```dart List get sheetNames => _sheets.map((s) => s.name).toList(); ``` -------------------------------- ### sheetCount getter implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheetCount.html Returns the number of sheets by returning the length of the internal _sheets list. This is the exact implementation of the sheetCount getter. ```dart content_copyint get sheetCount => _sheets.length; ``` -------------------------------- ### Implementation of value property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/value.html Defines the value property as a final dynamic type. ```dart final dynamic value; ``` -------------------------------- ### Implementation of the cell method Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/cell.html This implementation accesses the internal _cells structure to retrieve the value at the given row and column indices. ```dart dynamic cell(int row, int col) { return _cells[row]?[col]?.value; } ``` -------------------------------- ### sheetByName method implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/sheetByName.html Returns the sheet whose name matches the given name, case-insensitive. Iterates internal _sheets list comparing lowercased names; returns null if none matches, otherwise returns the sheet at that index. ```dart content_copyXlsSheet? sheetByName(String name) { final index = _sheets.indexWhere( (s) => s.name.toLowerCase() == name.toLowerCase(), ); if (index < 0) return null; return sheet(index); } ``` -------------------------------- ### Implement colCount property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/colCount.html The implementation of the colCount property calculates the number of columns by subtracting the first column index from the last column index. ```dart int get colCount => _lastCol - _firstCol; ``` -------------------------------- ### Implementation of firstRow property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/firstRow.html The firstRow property returns the integer index of the first row. ```dart int get firstRow => _firstRow; ``` -------------------------------- ### Declare final String path property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsReader/path.html Declares a final String property named 'path' in a Dart class. This is the implementation of the 'path' property. ```dart final String path; ``` -------------------------------- ### Implementation of rowCount Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/rowCount.html The rowCount property is implemented as a getter that calculates the number of rows with data by subtracting the first row index from the last row index. ```dart int get rowCount => _lastRow - _firstRow; ``` -------------------------------- ### Declare final String name property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/name.html Declares a final String field named `name`. The `content_copy` label above the snippet suggests this code is intended to be copied. ```dart final String name; ``` -------------------------------- ### XlsCell properties Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell-class.html Properties of the XlsCell class for accessing cell data. ```APIDOC ## XlsCell Properties ### col → int Returns the column index of the cell. ### numericValue → double? Returns the cell value as a number, or null if not a number. ### row → int Returns the row index of the cell. ### stringValue → String Returns the cell value as a string. ### type → CellType Returns the type of the cell. ### value → dynamic Returns the value of the cell. ### xfIndex → int Returns the formatting index of the cell. ``` -------------------------------- ### stringValue getter implementation Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/stringValue.html Getter that returns the cell value as a string, returning an empty string if the value is null. ```dart content_copyString get stringValue { if (value == null) return ''; return value.toString(); } ``` -------------------------------- ### Implementation of lastCol property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/lastCol.html The lastCol property is implemented as a getter that returns the private _lastCol field. ```dart int get lastCol => _lastCol; ``` -------------------------------- ### Implementation of col property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/col.html The col property is declared as a final integer. ```dart final int col; ``` -------------------------------- ### xfIndex property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/xfIndex.html The xfIndex property is a final integer that holds the index of the cell's extended format. It is read-only and can be accessed directly. ```APIDOC ## xfIndex property ### Description The xfIndex property is a final integer that represents the index of the cell's extended format. It is read-only and can be accessed directly. ### Declaration ```dart final int xfIndex; ``` ### Type int ### Modifiers final ### Usage This property is used to retrieve the format index of a cell. It is typically accessed after obtaining an XlsCell object. ``` -------------------------------- ### Implementation of row property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/row.html The row property is declared as a final integer. ```dart final int row; ``` -------------------------------- ### Implementation of type property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/type.html The type property is defined as a final CellType field. ```dart final CellType type; ``` -------------------------------- ### Implementation of numericValue property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/numericValue.html This getter checks if the cell value is a number or a string, returning the double representation or null if conversion is not possible. ```dart double? get numericValue { if (value is num) return value.toDouble(); if (value is String) return double.tryParse(value); return null; } ``` -------------------------------- ### Dart implementation of cells getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/cells.html Defines the `cells` getter as a sync* generator that iterates over the internal `_cells` map and yields each cell with type different from `CellType.empty`. ```dart Iterable get cells sync* { for (final rowMap in _cells.values) { for (final cell in rowMap.values) { if (cell.type != CellType.empty) { yield cell; } } } } ``` -------------------------------- ### Implementation of lastRow getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/lastRow.html Returns the internal `_lastRow` value. The index is exclusive, meaning it points to the first row after the last used row. No additional logic is provided; the getter simply forwards the internal field. ```dart content_copyint get lastRow => _lastRow; ``` -------------------------------- ### lastCol getter Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsSheet/lastCol.html Returns the last column index (exclusive) as an integer. This getter provides read-only access to the last column index of the sheet. ```APIDOC ## lastCol getter ### Description Returns the last column index (exclusive) as an integer. ### Method GET ### Endpoint lastCol ### Parameters None ### Implementation ```dart int get lastCol => _lastCol; ``` ### Return Value - **int** - The last column index (exclusive). ``` -------------------------------- ### row property Source: https://pub.dev/documentation/excel2003/latest/excel2003/XlsCell/row.html The row property is a final integer that holds the row index of the cell. It is read-only and can be accessed directly. ```APIDOC ## row property ### Description The row property is a final integer that represents the row index of the cell. It is read-only and can be accessed directly. ### Property - **row** (int) - final - The row index of the cell. ### Implementation ```dart final int row; ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.