modern-xlsx API Reference - v1.3.0
    Preparing search index...

    Function sheetToCsv

    • Convert a Worksheet to a CSV string.

      A boolean cell is written as TRUE or FALSE, as Excel saves it to CSV; every other cell is written as its stored value.

      Parameters

      • ws: Worksheet

        The Worksheet to convert.

      • Optionalopts: SheetToCsvOptions

        Options for separator, quoting, row limit, and formula escaping.

      Returns string

      A CSV-formatted string.

      ModernXlsxError with code SIZE_LIMIT when the rows from the first to the last output line times the columns up to the widest row exceed V8's maximum string length (2^29 - 24 characters). With a non-empty separator the CSV, one separator or newline per field, could not fit in one string; the same bound applies to an empty separator because a grid that large cannot be walked in reasonable time.

      const csv = sheetToCsv(ws);
      fs.writeFileSync('output.csv', csv);