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

Free Support Forum - aspose.com

Regaring Range

Hi

I am having issue regarding range,
Attached is screen shot for example, could you please explain me like,
Range.FirstColumn = 11
Range.FirstRow = 2
Range.ColumnCount = 11

Range.RowCount = 2

this means it is single cell in 2nd Row and 11th Column? this is my understanding

Please advice.

Thanks & Regards,
Sanjeev

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please see the details of the Range properties as per your requirement.

Range.FirstColumn = The index of the cell from where the range starts.
Range.FirstRow = The index of the row from were cell starts.

Range.ColumnCount = The number of Columns in the r.ange.
Range.RowCount = The Number of Rows in the range.

In your provided range values, it means that your range start from 11th column and 2nd Row (L2) and Goes Up to V4, creating a rectangular group of the cells. This range include a total number of 22 Cells (Rows * Columns in Range).

Please see the following Sample Code and attached output file for further clarifications. The Range Cells are having Background color as Yellow in the output file.

Sample Code:

//Instantiate a new Workbook.

Workbook workbook = new Workbook();

//Get the first worksheet in the book.

Worksheet WS = workbook.Worksheets[0];

//Create a range of cells.

Range range = WS.Cells.CreateRange(2, 11, 2, 11);

//Name the range.

range.Name = "MyRange";

//Declare a style object.

Style stl;

//Create the style object with respect to the style of the first row.

stl = WS.Cells.Rows[0].Style;

//To Set the fill color of the range, you may use ForegroundColor with

stl.ForegroundColor = System.Drawing.Color.Yellow;

stl.Pattern = BackgroundType.Solid;

//Apply the style to the range.

range.Style = stl;

//Save the excel file.

workbook.Save("C:\\Ranges.xls");

Also, you can see the following link for further details on different Range Class’s methods and Properties,

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/aspose.cells.rangemembers.html

Thank You & Best Regards,

Hi,

Well, since Nausherwan has provided some detailed information already, I would like to explain your defined attributes of your defined range further:

Range.FirstColumn = 11 ----> Column "L" (column indexes are 0 (zero) based i.e.., 0-A, 1-B, 2-C etc.)
Range.FirstRow = 2 ---> Third row (row indexes are also 0 based)
Range.ColumnCount = 11 ---> if you add 11 columns and start counting from Column "L", you will get Column "V"
Range.RowCount = 2 ---> if you add 2 rows and start counting from 3rd row, you will get 4th row.

So your range criteria is: L3:V4, hopefully you got it now.

And, one minor mistake in Nausherwan's post (he might have missed), I will correct it here:

nausherwan.aslam:

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

In your provided range values, it means that your range start from 11th column and 2nd Row (L2) and Goes Up to V4, creating a rectangular group of the cells. This range include a total number of 22 Cells (Rows * Columns in Range).

In your provided range values, it means that your range starts from 11th column (0 based) and 2nd Row (0 based) (i.e.., L3 cell) and goes Up to V4, creating a rectangular group of the cells. This range include a total number of 22 Cells (Rows * Columns in Range).

Also, you may check for your reference:

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/named-ranges.html

Feel free to contact us any time, if you need further clarifications.

Have a good day!

Thank you.