ContentTypePropertiesの操作

Aspose.Cells for Python via .NETは、Workbook.content_type_properties.add()メソッドを提供し、ExcelファイルにカスタムContentTypePropertiesを追加します。ContentTypeProperty.is_nillableプロパティをtrueに設定することで、そのプロパティをオプションにすることもできます。以下のコードスニペットは、オプションのカスタムContentTypePropertiesをExcelファイルに追加する方法を示しています。以下の画像は、サンプルコードで追加された両方のプロパティを示しています。

todo:image_alt_text

サンプルコードによって生成された出力ファイルが添付されています。

出力ファイル

サンプルコード

from aspose.cells import FileFormatType, Workbook
from datetime import datetime
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# source directory
outputDir = RunExamples.Get_OutputDirectory()
workbook = Workbook(FileFormatType.XLSX)
index = workbook.content_type_properties.add("MK31", "Simple Data")
workbook.content_type_properties[index].is_nillable = False
index = workbook.content_type_properties.add("MK32", datetime.now().strftime("%Y-%m-%d'T'hh:%M:%S"), "DateTime")
workbook.content_type_properties[index].is_nillable = True
workbook.save(outputDir + "WorkingWithContentTypeProperties_out.xlsx")