Reading and Writing Query Table of Worksheet
Aspose.Cells provides Worksheet.getQueryTables() collection which returns the QueryTableCollection. To get a specific QueryTable, use the QueryTableCollection.get() property and pass the index of the QueryTable. The QueryTable class has the following two properties for adjusting the QueryTable.
These are both boolean values. You can view them in Microsoft Excel via Data > Connections > Properties.
Reading and Writing Query Table of Worksheet
The following sample code reads the first QueryTable of the first worksheet and then prints both of the QueryTable properties. Then it sets the QueryTable.PreserveFormatting to true.
The following screenshot shows the source excel file used in the code and its properties showing both of the QueryTable values.
The following screenshot shows the output excel file generated by the code and its properties showing both of the QueryTable values. As you can see the Preserved Formatting checkbox is checked now.
Console Output
Here is the console output of the above sample code
Adjust Column Width: true
Preserve Formatting: false
Retrieve query table result range
Aspose.Cells provides the option to read the address i.e. result range of cells for a query table. Following code demonstrates this feature by reading the address of result range for a query table. The sample file can be downloaded here.