We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue with CellsHelper CellNameToIndex

Spreadsheet has 26 columns from A to Z, but below method only returning 25 columns. where is the catch

protected virtual DataTable ExportDataTableTo(Workbook workbook, string worksheetName, string startCellRowColumIndex = “A1”, string endCellRowColumIndex = “A1”, bool IsColumnCaption = true)
{
Worksheet worksheet = workbook.Worksheets[worksheetName];

        int firstCellRowIndex, firstCellColumnIndex, lastCellRowIndex, lastCellColumnIdex, totalRows;
        CellsHelper.CellNameToIndex(startCellRowColumIndex, out firstCellRowIndex, out firstCellColumnIndex);
        CellsHelper.CellNameToIndex(endCellRowColumIndex, out lastCellRowIndex, out lastCellColumnIdex);
        totalRows = worksheet.Cells.MaxDataRow;
        if (totalRows > 0)
            return worksheet.Cells.ExportDataTableAsString(firstCellRowIndex, firstCellColumnIndex, totalRows, lastCellColumnIdex, IsColumnCaption);
        else
            return new DataTable();
    }

@vicage

Thanks for using Aspose APIs.

Excel column starts from 1. (Excel is 1-based)

Aspose.Cells column index starts from 0. (Aspose.Cells is 0-based)

So, if Aspose.Cells returns 25, it means 26 in Excel.

And when Aspose.Cells returns 0, it means 1 in Excel.

Column

A will be 0
B will be 1
C will be 2
D will be 3

etc.

This applies with rows as well.