Leggere e scrivere la tabella con l'origine dati della tabella delle query
Contents
[
Hide
]
Leggere e scrivere la tabella con l’origine dati della tabella delle query
Con Aspose.Cells for Python via Java, puoi leggere e scrivere una tabella che ha una QueryTable come origine dati. Il supporto per questa funzione esiste anche per i file XLS. Il frammento di codice seguente illustra la lettura e la scrittura di una tabella di questo tipo leggendo prima la tabella e quindi modificandola per aggiungere la riga dei totali.
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
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 di origine e di output sono allegati per riferimento.