Sorgu Tablosu Veri Kaynağı ile Tablo Okuma ve Yazma

Sorgu Tablosu Veri Kaynağı ile Tablo Okuma ve Yazma

Aspose.Cells ile Datasource olarak QueryTable içeren bir tabloyu okuyabilir ve yazabilirsiniz. Bu özellik için destek, XLS dosyaları için de mevcuttur. Aşağıdaki kod parçacığı, önce tabloyu okuyarak ve ardından toplamlar satırını eklemek için değiştirerek böyle bir tablonun okunmasını ve yazılmasını gösterir.

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

Kaynak ve çıktı excel dosyaları referans için eklenmiştir.

Kaynak dosyası

Çıktı dosyası