C# reading Excel 2007 worksheet is limited to 255 characters per Cell
Posted on 2014-02-26
I have a c# application which is scccessfully reading data from various excel sheets. However once the cell exceeds 255 characters the value is either truncated to 255 or returned as null.
If I run the code below on my windows 7 64bit o/s - It reads the full contents of the cell which has more than 255 characters (700 characters). However if I run it on my windows 7 32bit o/s laptop then it returns null for every cell exceeding 255 characters.
Can anyone tell me why it works in 64b but not in 32b. see code below
static void Main(string args)
string con = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
@"Data Source=c:\temp\Book1.xlsx;" +
@"Extended Properties='Excel 8.0;HDR=Yes; IMEX=1;'";
using (OleDbConnection connection = new OleDbConnection(con))
OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection);
var TranArr = new string[999, 20];
int i = 0;
using (OleDbDataReader dr = command.ExecuteReader())
TranArr[i, 1] = dr.ToString();
TranArr[i, 2] = dr.ToString();