Keep Separators for Blank Rows while exporting spreadsheets to CSV format with Node.js via C++

Keep Separators for Blank Rows while exporting spreadsheets to CSV format

Aspose.Cells provides the ability to keep line separators while converting spreadsheets to CSV format. For this, you may use the TxtSaveOptions.getKeepSeparatorsForBlankRow() property of TxtSaveOptions. TxtSaveOptions.getKeepSeparatorsForBlankRow() is a boolean property. To keep the separators for blank lines while converting the Excel file to CSV, set the TxtSaveOptions.getKeepSeparatorsForBlankRow() property to true.

The following sample code loads the source Excel file. It sets the TxtSaveOptions.getKeepSeparatorsForBlankRow() property to true and saves it as output.csv. The screenshot shows the comparison between the source Excel file, the default output generated while converting the spreadsheet to CSV, and the output generated by setting TxtSaveOptions.getKeepSeparatorsForBlankRow() to true.

todo:image_alt_text

Sample Code

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "Book1.xlsx");

// Create a Workbook object and opening the file from its path
const wb = new AsposeCells.Workbook(filePath);

// Instantiate Text File's Save Options
const options = new AsposeCells.TxtSaveOptions();

// Set KeepSeparatorsForBlankRow to true to show separators in blank rows
options.setKeepSeparatorsForBlankRow(true);

// Save the file with the options
wb.save(path.join(dataDir, "output.csv"), options);