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

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

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

次のサンプルコードでは、ソースExcelファイルをロードします。TxtSaveOptions.KeepSeparatorsForBlankRowプロパティをtrueに設定し、output.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-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
string filePath = dataDir + "Book1.xlsx";
// Create a Workbook object and opening the file from its path
Workbook wb = new Workbook(filePath);
// Instantiate Text File's Save Options
TxtSaveOptions options = new TxtSaveOptions();
// Set KeepSeparatorsForBlankRow to true show separators in blank rows
options.KeepSeparatorsForBlankRow = true;
// Save the file with the options
wb.Save(dataDir + "output.csv", options);