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

Free Support Forum - aspose.com

Range Styles

How do I set style for a range?


I used to be able to do it this way:

Style st1 = griddesktop.Worksheets[0].Cells[0, 0].GetStyle();
CellRange cr1 = new CellRange(0, 0, 0, 0);
st1.NumberFormat = 7;
griddesktop.Worksheets[0].Cells.SetStyle(cr1, st1);


Hi,


There is an issue with your code segment, please change your sample code to:
e.g
Sample code:

CellRange cr1 = new CellRange(0, 0, 0, 0);
for (var column = cr1.StartColumn; column <= cr1.EndColumn; column++)
{
for (var row = cr1.StartRow; row <= cr1.EndRow; row++)
{
var st1 = griddesktop.Worksheets[0].Cells[row, column].GetStyle();
st1.NumberFormat = 7;
griddesktop.Worksheets[0].Cells[row, column].SetStyle(st1);
}
}


Let us know if I can be of any further help.

Thank you.

Then you need to update your support documents. That is how I’ve been setting styles until this recent update.

Please see this:


This is what you support docs say

Hi,

Thanks for your posting and using Aspose.Cells.

We are sorry for inconvenience. We will update the document soon. It seems some of the older APIs have been deprecated or deleted so the code in the document does not work. For missing APIs, we will log issues so that they could be fixed in newer versions.

By the way, you can set the style of the range like this. I have tested it and it works fine at my end.

C#


sheet.Cells.SetStyle(“B7:E7”, style);

Hi,

Thanks for using Aspose.Cells for GridDesktop.

To update the article with newer code, some APIs need to be implemented so we have logged this task in our database to fix this issue.

This issue has been logged as

  • CELLSNET-43873 - Old code in the - Formatting a Range of Cells - article is not working

The issues you have found earlier (filed as CELLSNET-43873) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.