Leer en inglés

Compartir a través de


WorksheetBase.QueryTables Property

Definition

Gets the QueryTables collection that represents all the query tables on the worksheet.

C#
public Microsoft.Office.Interop.Excel.QueryTables QueryTables { get; }

Property Value

The QueryTables collection that represents all the query tables on the worksheet.

Examples

The following code example uses the QueryTables property to refresh the data in every Microsoft.Office.Interop.Excel.QueryTable on the current worksheet.

This example is for a document-level customization.

C#
private void RefreshQueryTables()
{
    if (this.QueryTables.Count > 0)
    {
        for (int i = 1; i <= this.QueryTables.Count; i++)
        {
            if (!this.QueryTables[i].Refresh())
            {
                MessageBox.Show("Refresh of query table " +
                    this.QueryTables[i].Name + " failed.");
            }
        }
    }
    else
    {
        MessageBox.Show("This worksheet contains no query tables.");
    }
}

Applies to

Producto Versiones
Visual Studio Tools for Office 2017, 2019, 2022