Closed GoogleCodeExporter closed 8 years ago
Ok aftwer lookint through your code and googling a little I found this:
http://www.dotnet247.com/247reference/msgs/37/187667.aspx
It is actually not a bug in your code : private object
GetColumnValue(IDataRecord
data, string columnName, string propertyName)
After 8 rows oledb automatically asumes all data types in the column will be
the
same. The only way to get around this is to change registry settings as shown
in the
link.
Original comment by miguel.m...@gmail.com
on 29 May 2010 at 5:14
A work around for this could be instead of bulk reading the whole document in
your
code, read line by line and treat every/column individually. Just a thought
Original comment by miguel.m...@gmail.com
on 29 May 2010 at 6:14
Can you attach the spreadsheet you are using so I can see if I can find a
workaround
for it.
Original comment by paulyo...@gmail.com
on 29 May 2010 at 4:23
Sorry, here's the file, NUMERO PARTE is the column you can have a look at, ado
will
take first 8 rows to sample the data type. but at row 20 or so, there are
letters
and numbers. the only work around that seems to work is changing the value of
the
registry TypeGuessRows, set it to 0 so every row can be scanned for its data
type.
see: http://www.dotnet247.com/247reference/msgs/37/187667.aspx
other work around could be the one I stated in a previous comment.
Cheers!
Original comment by miguel.m...@gmail.com
on 29 May 2010 at 5:32
Attachments:
I was able to find a workaround.
You will need to use the WorksheetNoHeader() method. By not using a header row,
Excel
does not try to determine the datatype. Note, however, that it will return the
header
row as the first result row, so make sure to skip the first row returned.
Here's a short code example on how to use the WorksheetNoHeader() method.
var excel = new ExcelQueryFactory(Path.Combine(
Environment.CurrentDirectory,
"Example.xls"));
var rows = from x in excel.WorksheetNoHeader("Hoja1")
select x;
bool firstRow = true;
foreach (var row in rows)
{
if (firstRow)
{
firstRow = false;
continue;
}
Console.WriteLine(row[11]); //The 11th column index is NUMERO PARTE
}
Console.ReadLine();
Original comment by paulyo...@gmail.com
on 29 May 2010 at 9:33
Original issue reported on code.google.com by
miguel.m...@gmail.com
on 29 May 2010 at 4:01