Unable to query named range on sheet with spaces in name in Excel

前端 未结 5 1494
我寻月下人不归
我寻月下人不归 2021-01-18 14:21

I have a workbook with multiple sheets, and each sheet has the same set of named ranges (IE they are scoped to the sheet, not workbook).

I want to query based on a n

5条回答
  •  不思量自难忘°
    2021-01-18 14:59

    Would it be possible to use an excel range instead of named range? I got the following to work:

    SELECT * FROM [Report 1$A4:P]
    

    I'm getting the sheet name from the GetOleDbSchemaTable() method and removing the apostrophes. The sheetname with apostrophes does not work for me with a range.

    if (tableName.Contains(' '))
                tableName = Regex.Match(tableName, @"(?<=')(.*?)(?=\$')", RegexOptions.None).Value + "$";
    

提交回复
热议问题