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