Reading and Writing Query Table of Worksheet

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.

todo:image_alt_text

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.

todo:image_alt_text

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.