XlsReader,CurrentRecord problem.

9 views
Skip to first unread message
Message has been deleted

Norbert

unread,
Jun 16, 2008, 4:01:27 PM6/16/08
to CSVChat
If I set the HasHeaders to true and change the CurrentRecord from the
default or 0, the ReadRecord skips one record ahead (i.e. I want to
read from line 10 on.). This doesn't happen when HasHeaders is
false. I know under the CsvReader there is a SkipRecord method to
advance one position without changing the CurrentRecord in the reader,
how can this be done in the XlsReader or is this a bug?

Thanks.

shriop

unread,
Jun 16, 2008, 5:19:13 PM6/16/08
to CSVChat
I'm going to go with obscure bug. I'll have to verify what you're
seeing, but it roughly makes sense so I'm expecting that I'll get the
same results. My best suggestion would be to switch to using the
alternate syntax on XlsReader that uses x and y coordinates,
reader[x,y] in c# or reader.Item(x,y) in vb.net, to locate the cell
and you can substitute the return from the method GetIndex(header) for
x so that it will reference the column index by name instead of
position.

Bruce Dunwiddie

ssgil...@gmail.com

unread,
Jun 20, 2008, 1:43:07 PM6/20/08
to CSVChat
What do you think the timeframe for a fix might be?

Thanks.

On Jun 16, 5:19 pm, shriop <shr...@hotmail.com> wrote:
> I'm going to go with obscure bug. I'll have to verify what you're
> seeing, but it roughly makes sense so I'm expecting that I'll get the
> same results. My best suggestion would be to switch to using the
> alternate syntax on XlsReader that uses x and y coordinates,
> reader[x,y] in c# or reader.Item(x,y) in vb.net, to locate the cell
> and you can substitute the return from the method GetIndex(header) for
> x so that it will reference the column index by name instead of
> position.
>
> Bruce Dunwiddie
>
> On Jun 16, 3:01 pm, Norbert <norbs...@gmail.com> wrote:
>
> > If I set the HasHeaders to true and change theCurrentRecordfrom the
> > default or 0, the ReadRecord skips one record ahead (i.e. I want to
> > read from line 10 on.).  This doesn't happen when HasHeaders is
> > false.  I know under the CsvReader there is a SkipRecord method to
> > advance one position without changing theCurrentRecordin the reader,

shriop

unread,
Jun 22, 2008, 4:47:17 PM6/22/08
to CSVChat
I tried to verify what you were seeing and ended up seeing the
behavior I would expect and couldn't find an actual issue, so either
I'm not understanding the issue or something else. The logic of
CurrentRecord is not necessarily meant to match Excel's row numbers,
but instead match the logical record numbers of the other readers and
from an actual data perspective. Here was my test scenario. I have an
Office 95 style spreadsheet called test.xls and I'm using the
XlsReader. It's a couple of simple columns and rows with the data
below using pipes to show you where my columns are defined:

|col1|col2|
|a|d|g|
|b|e|
|c|

And here's my test code that currently passes not showing an issue
with the current code from my perspective anyhow:

using (XlsReader reader = new XlsReader("../../test.xls"))
{
reader.CurrentSheet = 0;

reader.Settings.HasHeaders = false;
// this should put it on the record starting with "a"
reader.CurrentRecord = 1;
// this should advance it to the record starting with "b"
Assert.IsTrue(reader.ReadRecord());

Assert.AreEqual("b", reader[0]);

// this should have it read the first record as headers and
// start everything else at the record starting with "b"
reader.Settings.HasHeaders = true;
// this should put it on the record starting with "b"
reader.CurrentRecord = 1;
// this should advance it to the record starting with "c"
Assert.IsTrue(reader.ReadRecord());

Assert.AreEqual("c", reader[0]);
}

Bruce Dunwiddie

On Jun 20, 12:43 pm, "norb...@carlislegroup.com"
> > > Thanks.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages