Trabajando con ContentTypeProperties
Contents
[
Hide
]
Aspose.Cells proporcionaLibro de trabajo.ContentTypeProperties.Agregar para agregar ContentTypeProperties personalizados a un archivo de Excel. También puede hacer que la propiedad sea opcional configurando elContentTypeProperty.IsNillable propiedad averdadero. El siguiente fragmento de código muestra cómo agregar ContentTypeProperties personalizados opcionales a un archivo de Excel. La siguiente imagen muestra ambas propiedades que fueron agregadas por el código de muestra.
El archivo de salida generado por el código de muestra se adjunta como referencia.
Código de muestra
This file contains 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
// 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"); |