Skip to main content

Excel Export

PRO
Pro preview

This feature is part of FD Components Pro, which is documented as a preview and is not publicly available yet. See Editions and Availability.

FDC Pro provides an Excel-compatible SpreadsheetML XML writer without requiring an external spreadsheet dependency.

Register Pro export formats​

Initialize optional Pro integrations once during application startup:

void main() {
FdcPro.ensureInitialized();
runApp(const App());
}

This registers both the Excel and PDF writers with FdcExportRegistry. The call is idempotent.

Export a DataSet​

final result = await FdcExporter.exportDataSet(
orders,
format: FdcExcelExportFormat.spreadsheetXml,
options: FdcExportOptions(
scope: FdcExportScope.currentView,
valueMode: FdcExportValueMode.raw,
),
suggestedFileName: 'orders.xml',
);

final bytes = result.bytes;

The output MIME type is application/vnd.ms-excel, while the file content is SpreadsheetML XML.

Type preservation​

In raw mode, the writer preserves supported scalar types where possible:

  • booleans as Excel Boolean cells,
  • safe integers and finite numeric values as Number cells,
  • FdcDecimal as a numeric value using its exact decimal string representation,
  • DateTime as DateTime cells with date/date-time styles,
  • other values as strings.

Display mode forces exported values to string-oriented presentation:

FdcExportOptions(
valueMode: FdcExportValueMode.display,
)

Headers and frozen first row​

When headers are enabled, the writer emits a bold header row and configures the worksheet with a frozen first row:

FdcExportOptions(
includeHeaders: true,
)

Formula sanitization​

Spreadsheet formula sanitization is enabled by default:

FdcExportOptions(
sanitizeSpreadsheetFormulas: true,
)

String values that look like spreadsheet formulas are prefixed so they are treated as text rather than executable formulas. Keep this enabled when exporting user-controlled or otherwise untrusted text.

Custom worksheet name​

Pass the writer directly when a custom worksheet name is needed:

final result = await FdcExporter.exportDataSet(
orders,
format: FdcExcelExportFormat.spreadsheetXml,
writer: const FdcExcelXmlExportWriter(
worksheetName: 'Orders 2026',
),
);

Invalid worksheet-name characters are replaced, blank names fall back to Sheet1, and names longer than 31 characters are truncated.

Grid toolbar export​

After Pro initialization, Excel becomes available through the registered format set used by FdcGridExportButton.

FdcGridExportButton(
visible: true,
formats: const [
FdcExportFormat.csv,
FdcExcelExportFormat.spreadsheetXml,
],
onExport: handleExport,
)