Tabla de lectura y escritura con fuente de datos de tabla de consulta
Contents
[
Hide
]
Tabla de lectura y escritura con fuente de datos de tabla de consulta
Con Aspose.Cells, puede leer y escribir una tabla que tenga una QueryTable como fuente de datos. El soporte para esta característica también existe para archivos XLS. El siguiente fragmento de código muestra cómo leer y escribir una tabla de este tipo leyendo primero la tabla y luego modificándola para agregar la fila de totales.
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 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"); |
Los archivos de Excel de origen y salida se adjuntan como referencia.