Free Support Forum - aspose.com

Ranges that span multiple rows / columns- and individual cell formatting

Hi guys, for a single cell, is it possible to call a single method that returns all formatting?

I understand that the Name.HtmlString property returns a nicely formatted representation of the contents of a single cell. But a single cell also has other attributes to it not explicitly defined within the cell contents, but implicitly defined. For example a cell has a certain width and height, borders around the cell, alignment within it, etc.

Is there any other API that could be called to return a representation of a cell as actually shown in the Excel with all of those attributes?

If this exists, does it also exist at the entire range level? I.e. say I have a range that is 10 cells x 10 cells, can I invoke a method at the Range API level that will return a rendering of that complete 10 x 10 matrix that looks as close as possible to the actual Excel contents?

Thanks
Shan

Hi Shan,

“But a single cell also has other attributes to it not explicitly
defined within the cell contents, but implicitly defined. For example a
cell has a certain width and height, borders around the cell, alignment
within it, etc.”

Well, you may try additionally.
Cells.GetColumnWith(cell.Column) method - to get the width of the column of a cell.
Cells.GetRowHeight(cell.Row) method - to get the height of the row of a cell.
Similarly he may use:
cell.Style.Borders[BorderType.LeftBorder].LineStyle - to get the line style for certain borders.
cell1.Style.HorizontalAlignment attribute - to get the horizontal alignment. etc.


For named ranges,
Well, suppose there is named range
of cells defined: A1:C4. So the matrix would make 4 * 3 = 12 cells and the
individual range cells are arranged sequentially i.e.,
Range[0,0],Range[0,1],Range[0,2],Range[1,0],Range[1,1],Range[1,2],Range[2,0],Range[2,1],Range[2,2],Range[3,0],Range[3,1],Range[3,2].
Aspose.Cells provides you some useful Properties of Range class to access the individual cells in the range. You may use the following properties to identify the cells in the ranage
Check the document to know how to get/access or browse the individual cells in a named range: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/named-ranges.html


And, you may use Cells.GetColumnWith(range[i,j].Column) method - to get the width of the column for a range cell. Moreover, you may use Cells.GetRowHeight(range[i,j].Row) method - to get the height of the row for a range cell.
You may also use Range.Style. attribute to get the formatting for the range.


Thank you.