スプレッドシートをCSV形式にエクスポートする際に、空行のセパレーターを保持します

CSV形式へのスプレッドシートのエクスポート時に空行の区切り記号を保持する

Aspose.Cellsは、スプレッドシートをCSV形式に変換する際に行のセパレーターを保持する機能を提供します。これには、TxtSaveOptionsクラスのKeepSeparatorsForBlankRowプロパティを使用します。KeepSeparatorsForBlankRowはブール値のプロパティです。ExcelファイルをCSVに変換する際に空白の行のセパレーターを保持するには、KeepSeparatorsForBlankRowプロパティをtrueに設定します。

以下のサンプルコードは、元のExcelファイルを読み込みます。TxtSaveOptions.KeepSeparatorsForBlankRowプロパティをtrueに設定して、KeepSeparatorsForBlankRow.out.csvとして保存します。スクリーンショットには、元のExcelファイル、スプレッドシートをCSVに変換したときに生成されるデフォルトの出力、KeepSeparatorsForBlankRowtrueに設定したときに生成される出力の比較が表示されています。

todo:image_alt_text

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(ConvertTableToRangeWithOptions.class) + "LoadingSavingConvertingAndManaging/";
// Open an existing file that contains a table/list object in it
Workbook workbook = new Workbook(dataDir + "KeepSeparatorsForBlankRow.xlsx");
// Instantiate Text File's Save Options
TxtSaveOptions options = new TxtSaveOptions();
// Set KeepSeparatorsForBlankRow to true show separators in blank rows
options.setKeepSeparatorsForBlankRow(true);
// Save the file with the options
workbook.save(dataDir + "KeepSeparatorsForBlankRow.out.csv", options);