将电子表格导出为 CSV 格式时保留空白行的分隔符

将电子表格导出为 CSV 格式时保留空白行的分隔符

Aspose.Cells 提供了在将电子表格转换为 CSV 格式时保留行分隔符的功能。为此,您可以使用**KeepSeparatorsForBlankRow**的财产**TxtSaveOptions**班级。**KeepSeparatorsForBlankRow**是一个布尔属性。要在将 Excel 文件转换为 CSV 时保留空行分隔符,请设置**KeepSeparatorsForBlankRow**财产给**真的**.

下面的示例代码加载源Excel文件.它设置**TxtSaveOptions.KeepSeparatorsForBlankRow**财产给**真的**并将其另存为KeepSeparatorsForBlankRow.out.csv.屏幕截图显示了源 Excel 文件、将电子表格转换为 CSV 时生成的默认输出与通过设置生成的输出之间的比较**KeepSeparatorsForBlankRow**到**真的**.

待办事项:图片_替代_文本

示例代码

// 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);