Sign in to follow this  
Moe

[.net] Problems reading more than 255 characters from a single excel spreadsheet cell...

Recommended Posts

Moe    1256
You will have to forgive me guys - I am at work, and strangely enough I can't post at MSDN (They have particular scripts blocked. Go figure). Anyway, a coworker and I have run across a very bizarre problem. We are attempting to read a spreadsheet using an OleDBDataReader and an OleDbConnection. We can read in most things fine from the spreadsheet - it opens up fine, and we are able to get data from it. The odd thing is though, is that we aren't able to read in more than 255 characters from a single cell. Here is the kicker though - the coworker of mine sent it to another employee, and he was able to run it fine and able to read in much more than 255 characters from a single cell. We tried running the same exe on several different machines, with a few different users, and no luck. There is no difference in OS, .Net framework, or the exe, yet it is giving different results. Anyone have a clue what might be going wrong here? I haven't seen anything on MSDN about there being a 255 character limit anywhere.... [looksaround]

Share this post


Link to post
Share on other sites
Palidine    1315
You'll have to post some code. Are you by chance using a byte as an index somewhere or only declaring a buffer 256 long? 255 is awfully coincidental otherwise.

-me

Share this post


Link to post
Share on other sites
Michalson    1657
What version of Excel is installed on his machine vs the rest? Any way to see what interface? If it goes through the older Excel 97 automation interface, I'm pretty sure it's going to be truncated to 255 characters.

Also, putting "Excel 97 255" into Google returned this knowledge base article talking about ODBC drivers and Excel determining datatypes and results being truncated to 255 characters.

Share this post


Link to post
Share on other sites
Moe    1256
As far as I know, its Office 2000. I will hit up that link Michalson, and post some code as soon as I can.

EDIT: Michalson, you were spot on! We changed the registry value and it worked like a charm. I never would have thought that something like that was causing the problem.

Thanks a bunch you two!

[Edited by - Moe on May 4, 2007 9:41:06 AM]

Share this post


Link to post
Share on other sites
Niksan2    265
I'm not sure if it helps, but we had the exact same problem, but we were using reference/invoke/dll jobby instead of OleDBDataReader, the cause for us was we were receiving the values like so, System.Array myvalues = (System.Array)range.Cells.Value2, changing to System.Array myvalues = (System.Array)range.get_Value(Excel.XlRangeValueDataType.xlRangeValueDefault); fixed the problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this