Class QueryTable
Contents
[
Hide
]QueryTable class
Represents QueryTable information.
public class QueryTable
Properties
Name | Description |
---|---|
AdjustColumnWidth { get; set; } | Returns or sets the AdjustColumnWidth of the object. |
ConnectionId { get; } | Gets the connection id of the query table. |
ExternalConnection { get; } | Gets the relate external connection. |
Name { get; } | Gets the name of querytable. |
PreserveFormatting { get; set; } | Returns or sets the PreserveFormatting of the object. |
ResultRange { get; } | Gets the range of the result. |
Examples
using System;
using Aspose.Cells;
namespace AsposeCellsExamples
{
public class CellsClassQueryTableDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Add sample data to create a query table (simulating external data)
worksheet.Cells["A1"].PutValue("ID");
worksheet.Cells["B1"].PutValue("Name");
worksheet.Cells["A2"].PutValue(1);
worksheet.Cells["B2"].PutValue("John");
worksheet.Cells["A3"].PutValue(2);
worksheet.Cells["B3"].PutValue("Mary");
// Check if there are any query tables in the worksheet
if (worksheet.QueryTables.Count > 0)
{
// Get the first query table
QueryTable qt = worksheet.QueryTables[0];
// Display query table properties
Console.WriteLine("Query Table Name: " + qt.Name);
Console.WriteLine("Connection ID: " + qt.ConnectionId);
Console.WriteLine("Result Range: " + qt.ResultRange.Address);
Console.WriteLine("Preserve Formatting: " + qt.PreserveFormatting);
Console.WriteLine("Adjust Column Width: " + qt.AdjustColumnWidth);
// Modify some properties
qt.PreserveFormatting = true;
qt.AdjustColumnWidth = false;
}
else
{
Console.WriteLine("No query tables found in the worksheet.");
}
}
}
}
See Also
- namespace Aspose.Cells
- assembly Aspose.Cells