MaxDataColumn

Hello,

I’m trying to read the columns values from the attached file (Data Source 4.xls). MaxDataColumn returns 1 but there are really 2 columns in the Worksheet. I also tried Cells.Columns.Count with the same results.

Following is my code snippet,

Workbook wb = new Workbook();

wb.Open(path);

Worksheet ws = wb.Worksheets[0];

int columnCount = ws.Cells.MaxDataColumn;//ws.Cells.Columns.Count;

int rowCount = ws.Cells.MaxDataRow;//ws.Cells.Rows.Count;

for (int i = 0; i < columnCount; i++) {

string column = (string)ws.Cells[0, i].Value;

...

I’m using Aspose.Cells 4.1.0.0 for .NET.

Is there something wrong with the code or the file?

Thanks,

Juno

Hi Juno,

MaxDataColumn returns column index of the right-most cell. It's zero based. So please plus it with 1.