Läs och skriv tabell med datakälla för frågetabell
Contents
[
Hide
]
Läs och skriv tabell med datakälla för frågetabell
Med Aspose.Cells for Python via Java kan du läsa och skriva en tabell som har en QueryTable som datakälla. Stödet för den här funktionen finns även för XLS-filer. Följande kodavsnitt demonstrerar att läsa och skriva en sådan tabell genom att först läsa tabellen och sedan ändra den för att lägga till totalraden.
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") |
Käll- och utdata Excel-filerna bifogas som referens.