将工作簿保存为严格的 Open XML 电子表格格式
Contents
[
Hide
]
可能的使用场景
Aspose.Cells允许您将工作簿保存为严格的Open XML电子表格格式。为此,它提供了Workbook.Settings.Compliance属性。如果将其值设置为OoxmlCompliance.ISO_29500_2008_STRICT,则输出的Excel文件将以严格的Open XML电子表格格式保存。
将工作簿保存为严格的 Open XML 电子表格格式
以下示例代码创建一个工作簿,并将Workbook.Settings.Compliance属性的值设置为OoxmlCompliance.ISO_29500_2008_STRICT,然后将其另存为输出Excel文件。如果您在Microsoft Excel中打开输出的Excel文件并打开另存为…对话框,您将看到其格式为严格的Open XML电子表格,如此屏幕截图所示。
示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Create workbook. | |
Workbook wb = new Workbook(); | |
// Specify - Strict Open XML Spreadsheet - Format. | |
wb.getSettings().setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT); | |
// Add message in cell B4 of first worksheet. | |
Cell b4 = wb.getWorksheets().get(0).getCells().get("B4"); | |
b4.putValue("This Excel file has Strict Open XML Spreadsheet format."); | |
// Save to output Excel file. | |
wb.save("outputSaveWorkbookToStrictOpenXMLSpreadsheetFormat.xlsx", SaveFormat.XLSX); |