使用 ContentTypeProperties
Contents
[
Hide
]
Aspose.Cells提供工作簿.ContentTypeProperties.Add 方法将自定义 ContentTypeProperties 添加到 excel 文件。您还可以通过设置ContentTypeProperty.IsNillable财产给真的.以下代码片段演示了将可选的自定义 ContentTypeProperties 添加到 excel 文件。下图显示了示例代码添加的两个属性。
附上示例代码生成的输出文件,供参考。
示例代码
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 directories. | |
String outputDir = Utils.Get_OutputDirectory(); | |
Workbook workbook = new Workbook(FileFormatType.XLSX); | |
int index = workbook.getContentTypeProperties().add("MK31", "Simple Data"); | |
workbook.getContentTypeProperties().get(index).setNillable(false); | |
index= workbook.getContentTypeProperties().add("MK32", "2019-10-17T16:00:00+00:00", "DateTime"); | |
workbook.getContentTypeProperties().get(index).setNillable(false); | |
workbook.save(outputDir + "WorkingWithContentTypeProperties_out.xlsx"); |