Leggi e Scrivi Tabella con Origine Dati Tabella Query
Leggere e scrivere una tabella con dati della tabella di query
Con Aspose.Cells for Python via Java, è possibile leggere e scrivere una tabella che ha un QueryTable come origine dati. Il supporto per questa funzionalità esiste anche per i file XLS. Il seguente snippet di codice dimostra la lettura e la scrittura di tale tabella, leggendo prima la tabella e quindi modificandola per aggiungere la riga dei totali.
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
# Load workbook object | |
workbook = Workbook(source_directory + "SampleTableWithQueryTable.xls") | |
worksheet = workbook.getWorksheets().get(0) | |
# Access first list object or table | |
listObj = worksheet.getListObjects().get(0) | |
# Check the data source type if it is query table | |
if (listObj.getDataSourceType() == TableDataSourceType.QUERY_TABLE): | |
listObj.setShowTotals(True) | |
# Save the excel file. | |
workbook.save(output_directory + "SampleTableWithQueryTable_out.xls") |
I file excel sorgente e di output sono allegati a scopo informativo.