在ODF 1.1和1.2规范中保存ODS文件
Contents
[
Hide
]
Aspose.Cells支持在ODF(OpenDocument Format)1.1和1.2规范中保存ODS文件(OpenDocument Spreadsheet)。 Aspose.Cells具有OdsSaveOptions.IsStrictSchema11属性,该属性指定保存ODS文件时使用ODF 1.1规范。 此属性的默认值为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-.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); |