Lavorare con ContentTypeProperties

Aspose.Cells fornisce il metodo Workbook.ContentTypeProperties.Add per aggiungere custom ContentTypeProperties a un file Excel. È anche possibile rendere facoltativa la proprietà impostando la proprietà ContentTypeProperty.IsNillable su true. Il seguente snippet di codice dimostra l’aggiunta facoltativa di custom ContentTypeProperties a un file Excel. L’immagine seguente mostra entrambe le proprietà che sono state aggiunte dal codice di esempio.

todo:image_alt_text

Il file di output generato dal codice di esempio è allegato per riferimento.

File di Output

Codice di Esempio

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