使用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-.NET
//source directory
string outputDir = RunExamples.Get_OutputDirectory();
Workbook workbook = new Workbook(FileFormatType.Xlsx);
int index = workbook.ContentTypeProperties.Add("MK31", "Simple Data");
workbook.ContentTypeProperties[index].IsNillable = false;
index = workbook.ContentTypeProperties.Add("MK32", DateTime.Now.ToString("yyyy-MM-dd'T'hh:mm:ss"), "DateTime");
workbook.ContentTypeProperties[index].IsNillable = true;
workbook.Save(outputDir + "WorkingWithContentTypeProperties_out.xlsx");