Avatar of thomaszhwang
thomaszhwangFlag for United States of America

asked on 

Is it possible to ignore hidden columns when I use OLEDB to load the Excel file in C#?

I can load the entire Excel file now, but I don't want to load those hidden columns in Excel.  Is there a way to do that?  Thanks.
.NET ProgrammingC#Microsoft Excel

Avatar of undefined
Last Comment
thomaszhwang
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Norie
Norie

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of thomaszhwang
thomaszhwang
Flag of United States of America image

ASKER

By "load", I meant I can use OLEDB to connect to the Excel file and load one of the worksheets into a DataTable component.

I'm getting data from Excel to a DataTable Component.  Thanks.
Avatar of thomaszhwang
thomaszhwang
Flag of United States of America image

ASKER

Thanks zorvek.  I don't think copy and past the entire worksheet into another worksheet would work for me.

What do you mean by "parse the worksheet while ignoring hidden columns"?
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of thomaszhwang
thomaszhwang
Flag of United States of America image

ASKER

Thanks Kevin.  Copying the content simply doesn't work in my situation.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of starlite551
starlite551
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of starlite551
starlite551
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of thomaszhwang
thomaszhwang
Flag of United States of America image

ASKER

Thanks both of you.  If we cannot determine if a column is hidden through OLEDB, it would not work for me.

The Excel I'm working with is actually a very complicated Excel application with sheet protection.  I cannot un-hide those hidden columns.  Neither can I see the name of those columns.  What makes it worse, the data in the worksheet is not even strictly column based.

I'm going to close this case.  Thank you guys.  I really appreciate your efforts.
Avatar of Norie
Norie

thomas

I was going to post a similar solution to starlite but I wondered if it would work for you because of needing to name the columns.

I didn't get round to try anything which would work without knowing the names, but now that you've mentioned all these other things I don't think that's going to work either.

Can you even use OLEDB with a protected worksheet?
Avatar of thomaszhwang
thomaszhwang
Flag of United States of America image

ASKER

Yes, I can use OLEDB against a protected worksheet.  Since the column names are unknown, OLEDB parses them as F1, F2, F3 and etc.  In my case, the thing is the Excel uses Macro, the column with the data I want may not be the same column the next time when data in another worksheet is changed.
Avatar of Norie
Norie

Well can't you identify the hidden columns by name, or do you have columns you need called F1, F2 etc.

That's what I was thinking of but assumed you had dismissed the idea, and it might not work anyway.

Or don't you know any of the column names?

By the way, the mention of some of the data not being column based also made me wonder about whether using OLEDB would work.
Avatar of thomaszhwang
thomaszhwang
Flag of United States of America image

ASKER

No, there is no way you can get a "fixed" column name.  The content on the worksheet is dependent on the input on another worksheet and the process is automatically controlled by Macro.

What *is* fixed is a pattern of the display of the data.  However in order to make the pattern work, I need to ignore the hidden columns in that worksheet.  Unfortunately, OLEDB cannot do that.

Although the data is not column-based, OLEDB can still take everything out as text.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo