Behalte Trenner für leere Zeilen beim Exportieren von Tabellenkalkulationen im CSV Format mit Node.js über C++
Trennzeichen für leere Zeilen beim Exportieren von Tabellenkalkulationen im CSV-Format beibehalten
Aspose.Cells bietet die Möglichkeit, Zeilentrenner beim Konvertieren von Tabellenkalkulationen ins CSV-Format beizubehalten. Dafür können Sie die TxtSaveOptions.getKeepSeparatorsForBlankRow() Eigenschaft von TxtSaveOptions verwenden. TxtSaveOptions.getKeepSeparatorsForBlankRow() ist eine Boolesche Eigenschaft. Um die Trenner für leere Zeilen beim Konvertieren der Excel-Datei in CSV beizubehalten, setzen Sie die TxtSaveOptions.getKeepSeparatorsForBlankRow() Eigenschaft auf true.
Der folgende Beispielcode lädt die Quellexcel-Datei. Es setzt die TxtSaveOptions.getKeepSeparatorsForBlankRow()-Eigenschaft auf true und speichert sie als output.csv. Der Screenshot zeigt den Vergleich zwischen der Quell-Excel-Datei, der standardmäßigen Ausgabe beim Konvertieren in CSV und der Ausgabe, die durch Setzen von TxtSaveOptions.getKeepSeparatorsForBlankRow() auf true erzeugt wurde.
Beispielcode
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);