Leggi e Scrivi Tabella con Origine Dati Tabella Query

Leggere e scrivere una tabella con dati della tabella di query

Con Aspose.Cells, puoi leggere e scrivere una tabella che ha una QueryTable come origine dati. Il supporto per questa funzionalità esiste anche per i file XLS. Il seguente frammento di codice dimostra come leggere e scrivere una tale tabella leggendo prima la tabella e quindi modificandola per aggiungere la riga dei totali.

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

I file excel sorgente e di output sono allegati a scopo informativo.

File di origine

File di output