使用ContentTypeProperties

Contents
[ ]

Aspose.Cells提供Workbook.ContentTypeProperties.Add方法向Excel文件添加自定义ContentTypeProperties。您还可以通过将ContentTypeProperty.IsNillable属性设置为true使属性变为可选。以下代码片段演示了将可选自定义ContentTypeProperties添加到Excel文件中。以下图像显示了示例代码添加的两个属性。

todo:image_alt_text

由示例代码生成的输出文件附在下方以供参考。

输出文件

示例代码

// 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");