在 ODF 1.1 和 1.2 规范中保存 ODS 文件
Contents
[
Hide
]
Aspose.Cells 支持保存一个 ODS 文件(OpenDocument电子表格) 在 ODF (开放文档格式 ) 1.1 和 1.2 规范。 Aspose.Cells 有OdsSaveOptions.IsStrictSchema11指定使用 ODF 1.1 规范保存 ODS 文件的属性。该属性的默认值为错误的,所以没有这个设置保存的ODS文件使用的是1.2规范。
下面的示例代码创建一个工作簿对象,向第一个工作表的单元格 A1 添加一些值,然后将 ODS 文件保存在 ODF 1.1 和 1.2 规范中。默认情况下,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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook | |
Workbook workbook = new Workbook(); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Put some value in cell A1 | |
Cell cell = worksheet.Cells["A1"]; | |
cell.PutValue("Welcome to Aspose!"); | |
// Save ODS in ODF 1.2 version which is default | |
OdsSaveOptions options = new OdsSaveOptions(); | |
workbook.Save(dataDir + "ODF1.2_out.ods", options); | |
// Save ODS in ODF 1.1 version | |
options.OdfStrictVersion = Aspose.Cells.Ods.OpenDocumentFormatVersionType.Odf11; | |
workbook.Save(dataDir + "ODF1.1_out.ods", options); | |
// Save ODS in ODF 1.3 version | |
options.OdfStrictVersion = Aspose.Cells.Ods.OpenDocumentFormatVersionType.Odf13; | |
workbook.Save(dataDir + "ODF1.3_out.ods", options); |