ContentTypePropertiesの操作
Contents
[
Hide
]
Aspose.Cells for Python via .NETは、Workbook.content_type_properties.add()メソッドを提供し、ExcelファイルにカスタムContentTypePropertiesを追加します。ContentTypeProperty.is_nillableプロパティをtrueに設定することで、そのプロパティをオプションにすることもできます。以下のコードスニペットは、オプションのカスタムContentTypePropertiesをExcelファイルに追加する方法を示しています。以下の画像は、サンプルコードで追加された両方のプロパティを示しています。
サンプルコードによって生成された出力ファイルが添付されています。
サンプルコード
This file contains hidden or 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
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") |