开发者

How to select the default worksheet from an excel file

开发者 https://www.devze.com 2023-02-24 09:09 出处:网络
In the case where my user uploads an excel file with only one worksheet, I want to intelligently use only that worksheet.However, when I pull the schema for this file I see an unexpected worksheet (ci

In the case where my user uploads an excel file with only one worksheet, I want to intelligently use only that worksheet. However, when I pull the schema for this file I see an unexpected worksheet (circled):

How to select the default worksheet from an excel file

The schema is retrieved via:

OleDBConnection.GetSchema("Tables")

In this case, it looks like the second worksheet is a filter defined by the user to "peg" two columns from scrolling.

Question: Is it safe for me to ignore worksheets开发者_如何学JAVA with "$<filter>" appended? Put another way, if I run through all the worksheets, throwing out the "$<filter>" types, and find that there is only one left, is it a reasonable default to use that worksheet? Does anyone have a reference?

Thanks!


yes, i would have thought so. $ usually means it is refering to named range or macro in that workbook. you might use Regex and capture anything within ' '.

Here is a reference on how to select data from a named range:

http://msdn.microsoft.com/en-us/library/ms971514.aspx

How do u pull the schema for this file? maybe you can filter it so that it only has Worksheets ?

0

精彩评论

暂无评论...
验证码 换一张
取 消