October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How do you control SheetJS Excel-to-CSV output?

SheetJS converts one chosen worksheet at a time. Set CSV options deliberately, especially for dates, hidden data, blank rows, quoting and BOM behavior.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To convert Excel data to CSV with SheetJS Community Edition, choose the worksheet you want and pass it to XLSX.utils.sheet_to_csv(ws, opts). The utility returns a JavaScript string, not a complete multi-sheet workbook: CSV represents one flat table at a time. Decide which sheet to export, then configure dates, blank rows, hidden data, separators and quoting for the system that will receive the file.

Choose a worksheet before exporting

Read the workbook, select a worksheet by name, then convert that worksheet. For example:

As an Amazon Associate I earn from qualifying purchases.

const workbook = XLSX.readFile("report.xlsx");
const sheetName = "Sales";
const worksheet = workbook.Sheets[sheetName];

if (!worksheet) {
  throw new Error(`Worksheet not found: ${sheetName}`);
}

const csv = XLSX.utils.sheet_to_csv(worksheet);

sheet_to_csv accepts a worksheet object and returns a string. A workbook can contain multiple sheets, but a CSV has no workbook or sheet structure. Export the intended sheet explicitly, or repeat the operation for each sheet and give each result its own destination. SheetJS documents the worksheet utility in its CSV and Text API and discusses worksheet exports in its Data Export guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose between a string and a CSV file

Use sheet_to_csv when your application needs the CSV text to inspect, transform or send elsewhere. Use XLSX.write or XLSX.writeFile with CSV output when you want SheetJS to produce a file. These are distinct output routes, and their BOM behavior differs.

Route Result BOM behavior
XLSX.utils.sheet_to_csv(worksheet, opts) JavaScript string for one worksheet Does not include a byte-order mark
XLSX.write or XLSX.writeFile with CSV output CSV file-oriented output Includes a UTF-8 BOM for Excel compatibility

The distinction can matter if a receiving application expects a particular first byte sequence. If you switch from the raw string utility to file writing, check whether the BOM is appropriate for that consumer. See SheetJS CSV utility documentation and Writing Files for the documented behavior.

Set the CSV shape for the receiving system

The defaults are comma-separated fields and newline-separated records. The utility also provides options for output details that downstream importers may care about.

Option Documented behavior When to consider changing it
FS Field separator; default is a comma When the destination expects another delimiter
RS Record separator; default is a newline When the destination requires a particular line ending
blankrows Blank lines are included by default Set to false to omit blank lines
skipHidden Hidden rows and columns are included by default Set to true to omit hidden data
dateNF Controls date formatting in string output When a particular text representation is required for dates
forceQuotes Defaults to false Set to true to quote every cell
strip Removes trailing field separators When the output should not retain trailing separators

For example, a tab-separated export without empty lines can be produced as follows:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const csv = XLSX.utils.sheet_to_csv(worksheet, {
  FS: "t",
  blankrows: false
});

These settings affect the serialized text, not the choice of worksheet or the meaning of the underlying data. Confirm the receiving system’s delimiter, line-ending, blank-row and quoting expectations before exporting. The option definitions and defaults are in the SheetJS CSV and Text API.

Know when fields are quoted

SheetJS automatically wraps a field in double quotes when it contains the configured field separator or record separator. That protects separators inside a value from being treated as boundaries between cells or records. Set forceQuotes: true if the target requires every cell to be quoted, rather than only fields that need quoting.

Quoting is CSV syntax; it does not prevent spreadsheet applications from interpreting a value when someone opens the file. Applications may parse plaintext values according to their own rules, so do not assume that an exported string will display or behave identically in every spreadsheet program.

Rank #4
Express Schedule Free Employee Scheduling Software [PC/Mac Download]
  • Simple shift planning via an easy drag & drop interface
  • Add time-off, sick leave, break entries and holidays
  • Email schedules directly to your employees

Format dates as text deliberately

CSV stores dates as formatted text, not as Excel’s rich date type or its display behavior. Spreadsheet dates are commonly represented in Excel files as numeric date codes paired with number formats. When converting to CSV, choose the intended date text with dateNF rather than assuming the exported value will retain the spreadsheet’s date semantics.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const csv = XLSX.utils.sheet_to_csv(worksheet, {
  dateNF: "yyyy-mm-dd"
});

The format string should match the requirements of the system that will consume the CSV. The CSV utility documentation describes dateNF for string output; the writing documentation describes writer behavior and date handling.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Hidden rows and columns are exported unless you opt out

Hidden worksheet data is included by default. To omit it, set skipHidden: true:

const csv = XLSX.utils.sheet_to_csv(worksheet, {
  skipHidden: true
});

There is a prerequisite: row and column settings are not saved by the read and readFile methods by default. Set cellStyles when reading if the text processor needs those settings to identify hidden rows and columns:

const workbook = XLSX.readFile("report.xlsx", {
  cellStyles: true
});

Without the needed row and column settings available to the text processor, skipHidden cannot reliably make the export reflect hidden data. See the options in the CSV and Text API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assume export recalculates formulas

Formula extraction and formula export are separate concerns. For some input formats, formula parsing depends on enabling cellFormula when reading. The conversion documentation does not establish that CSV export recalculates formulas, so do not treat an export as a calculation step or promise refreshed formula results.

Plaintext input also has parsing considerations of its own: SheetJS applies delimiter heuristics to some legacy or ambiguous delimited files, and an explicit FS can be used where the delimiter is known. Codepage configuration matters for some older formats and for CSV input without a BOM in binary mode. These are read-side concerns rather than controls for choosing the worksheet to export. Consult Reading Files for parser options and File Formats for supported formats.

A practical export checklist

  • Identify the worksheet by name instead of relying on an accidental sheet order.
  • Choose whether your application needs a JavaScript string or a file-oriented CSV writer.
  • Match field and record separators to the destination.
  • Decide whether blank rows and hidden rows or columns belong in the output.
  • Set the text format for dates, and decide whether every field must be quoted.
  • Check the output with the receiving application, especially if BOM handling or plaintext interpretation matters.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.