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

Free Support Forum - aspose.com

Range Problem

Hi,

I’m just evaluating the Excel component and have hit an interesting problem with the range object. If I have:

Range range = worksheet.Cells.CreateRange(3, (byte)24, 1, 21);
int numRows = range.RowCount;
int numCols = range.ColumnCount;

numRows = 1 and numCols = 1. Why? I created the range with 21 columns!

If I do:

Range range = worksheet.Cells.CreateRange(3, (byte)21, 2, 21);
int numRows = range.RowCount;
int numCols = range.ColumnCount;

it says I have 2 rows and 2 columns.

What is going on?

Cheers,

Haydn

Dear Haydn,

Sorry, it’s a small bug that I have not realised. I fix it and you can get the fix no later than the start of next week.

Thanks.

Dear Haydn,

Now it’s fixed. Please download Hotfix 1.8.1

@Haydn,
Aspose.Excel is replaced with a new upgraded product Aspose.Cells which contains all the latest features of a spreadsheet and supports all the latest versions of MS Excel. This new product also contains features to create ranges as demonstrated in the following example:

Workbook workbook = new Workbook();
 
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
 
//Creating a named range
Range range = worksheet.Cells.CreateRange("A1", "B4");
 
//Setting the name of the named range
range.Name = "Test_Range";
 
for (int row = 0; row < range.RowCount; row++)
{
    for (int column = 0; column < range.ColumnCount; column++)
    {
        range[row, column].PutValue("Test");
    }
}
 
//Saving the modified Excel file in default (that is Excel 2003) format
workbook.Save("C:\\Test_Range.xls");

For more information on opening different versions of Excel files, please follow the link below:
Creating a Named Range

Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for .NET (Latest Version)

You can download the latest demos here.