首页 文章

MS Excel - 现有连接字符串对应于哪个数据表

提问于
浏览
1

我有一个excel电子表格,有8个连接 . 我想知道什么连接字符串对应于excel中的哪个datatable / pivot表 . 2007或2010方法的解决方案很好 .

这可能吗?

2 回答

  • 3

    可以使用“数据”选项卡 .

    试试这个:

    • 单击 Data 选项卡中的 Connections 以显示 Workbook Connections 对话框 .

    Excel Data --> Connections

    • 单击列表中的连接 .

    List of Workbook Connections

    • 点击链接: click here to see where the selected connections are used

    Show where data connections are used in Workbook

  • 0

    这也可以从VBA获得 . 此查询只是枚举它们 .

    您可以使用 PivotCache.RefreshQueryTable.Refresh 轻松修改此示例以刷新查询 .

    Sub ShowAllQueryConnectionStrings()
        Dim oSheet As Excel.Worksheet
        For Each oSheet In Application.ActiveWorkbook.Sheets
            Dim oTable As Excel.QueryTable
            For Each oTable In oSheet.QueryTables
                Debug.Print "QueryTable " & oTable.Name & ": " & oTable.Connection
            Next
            Dim oPivot As Excel.PivotTable
            For Each oPivot In oSheet.PivotTables
                Debug.Print "PivotTable " & oPivot.Name & ": " & oPivot.PivotCache.Connection
            Next
        Next
    End Sub
    

相关问题