Jump to content
  • Advertisement
Sign in to follow this  
Moe

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

This topic is 4039 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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

Share this post


Link to post
Share on other sites
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!