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

Started by
3 comments, last by Niksan2 16 years, 11 months ago
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]
Advertisement
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
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.
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]
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.

This topic is closed to new replies.

Advertisement