tessera_xlsx 0.2.0
tessera_xlsx: ^0.2.0 copied to clipboard
Excel (.xlsx) support for the tessera pivot-table engine: import a worksheet as a data source, export a cube as a formatted worksheet. Pure Dart.
tessera_xlsx #
Excel (.xlsx) support for the tessera pivot-table engine:
XlsxDataSource— aDataSourcethat streams the rows of one worksheet, so a workbook can be inferred and imported like a CSV file (including in an isolate, vialoadFactsInIsolate).XlsxCubeExporter— writes aCubeLayout(the expanded rows and columns exactly as shown) as a formatted worksheet: merged group headers in the "rotated L" shape, level shading, bold summaries, frozen headers, localized labels throughTesseraStrings. The engine'sCubeExportTheme(shared with the other exporters) sets fills, borders, fonts and the number format with plain ARGB ints — no Flutter types;CubeExportTheme.brand(primary: 0xFF00695C)derives a whole theme from one company colour,gradientbuilds level fills. Excel-only choices (numberFormatCode,freezeHeaders, column-width bounds) are on the exporter.
Pure Dart, no Flutter dependency — works in Flutter apps, on servers and in command-line tools alike. Both directions live in one package because they share the same OOXML machinery.
Both directions are implemented and tested (the exporter's output is verified by opening it with LibreOffice in the tests).
import 'package:tessera_xlsx/tessera_xlsx.dart';
final source = XlsxDataSource.fromData(bytes, name: 'sales.xlsx');
final result = await loadFacts(source);
final xlsx = XlsxCubeExporter(strings: TesseraStrings.forLanguage('hu')!)
.export(cube.layout);
export returns the workbook as a Uint8List, ready to write to a file
or hand to a download.
User guide: github.com/nagylzs/tessera/docs — data sources, schema, cubes, aggregates, filters, the expression language, widgets, theming, export, localization, saving, large data.
Example #
example/main.dart does the whole round trip from
the command line — read example/sales.xlsx, infer and import, build a
region/country × year/quarter cube with every region expanded, write it
as sales_pivot.xlsx:
dart run example/main.dart [input.xlsx] [output.xlsx]
License #
MIT — see LICENSE. Author: László Zsolt Nagy.