在ODF 1.1和1.2规范中保存ODS文件
Contents
[
Hide
]
Aspose.Cells支持使用ODF 1.1规范和ODF 1.2规范保存(OpenDocument Format)ODS文件。Aspose.Cells已经添加了OdsSaveOptions.setStrictSchema11()属性以使用ODF 1.1规范保存ODS文件。此属性的默认值为false,因此未使用此特殊设置保存的ODS文件将使用1.2规范。
下面的示例代码创建工作簿对象,在第一个工作表的A1单元格中添加一些值,然后按照ODF 1.1和1.2规范保存ODS文件。默认情况下,ODS文件保存在ODF 1.2规范中。
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 | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SaveODSfile.class); | |
// Create workbook | |
Workbook workbook = new Workbook(); | |
// Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Put some value in cell A1 | |
Cell cell = worksheet.getCells().get("A1"); | |
cell.putValue("Welcome to Aspose!"); | |
// Save ODS in ODF 1.2 version which is default | |
OdsSaveOptions options = new OdsSaveOptions(); | |
workbook.save("ODF1.2.ods", options); | |
// Save ODS in ODF 1.1 version | |
options.setOdfStrictVersion(OpenDocumentFormatVersionType.ODF_11); | |
workbook.save("ODF1.1.ods", options); | |
// Save ODS in ODF 1.3 version | |
options.setOdfStrictVersion(OpenDocumentFormatVersionType.ODF_13); | |
workbook.save("ODF1.3.ods", options); | |