クエリ テーブル データ ソースを使用したテーブルの読み取りと書き込み
Contents
[
Hide
]
クエリ テーブル データ ソースを使用したテーブルの読み取りと書き込み
Aspose.Cells を使用すると、QueryTable を Datasource として持つテーブルを読み書きできます。この機能のサポートは、XLS ファイルにも存在します。次のコード スニペットは、最初にテーブルを読み取り、次にそれを変更して合計行を追加することによって、このようなテーブルの読み取りと書き込みを示しています。
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"); |
参照用にソースと出力の Excel ファイルが添付されています。