Leer y Escribir Tabla con Origen de Datos de Tabla de Consulta
Leer y Escribir Tabla con Origen de Datos de Tabla de Consulta
Con Aspose.Cells, puedes leer y escribir una tabla que tiene un QueryTable como Origen de Datos. El soporte para esta característica también existe para archivos XLS. La siguiente muestra de código demuestra cómo leer y escribir dicha tabla, primero leyendo la tabla y luego modificándola para agregar la fila de totales.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the output directory. | |
String sourceDir = Utils.Get_SourceDirectory(); | |
String outputDir = Utils.Get_OutputDirectory(); | |
// Load workbook object | |
Workbook workbook = new Workbook(sourceDir + "SampleTableWithQueryTable.xls"); | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
ListObject table = worksheet.getListObjects().get(0); | |
// Check the data source type if it is query table | |
if (table.getDataSourceType() == TableDataSourceType.QUERY_TABLE) | |
{ | |
table.setShowTotals(true); | |
} | |
// Save the file | |
workbook.save(outputDir + "SampleTableWithQueryTable_out.xls"); |
Se adjuntan los archivos de Excel de origen y salida para referencia.