toCsv method

String toCsv({
  1. String? sheet,
  2. CsvConfig? config,
  3. bool formulasAsText = false,
})

Serialises one sheet of this workbook to CSV text.

sheet names the worksheet to export; when omitted, the default sheet (getDefaultSheet) is used. See SheetCsv.toCsv for the value mapping and the config / formulasAsText options.

Throws an ArgumentError when no sheet named sheet exists.

Implementation

String toCsv({
  String? sheet,
  CsvConfig? config,
  bool formulasAsText = false,
}) {
  final name = sheet ?? getDefaultSheet() ?? sheetOrder.first;
  final target = sheets[name];
  if (target == null) {
    throw ArgumentError.value(sheet, 'sheet', 'no sheet named "$name"');
  }
  return target.toCsv(config: config, formulasAsText: formulasAsText);
}