Free Support Forum -

How to apply a style to a set of columns


I am trying to apply a format style to a set of columns and to do that I am using

objWB.Worksheets(objWB.Worksheets.Count - 1).Cells.CreateRange("F:J").ApplyStyle(s1, New StyleFlag())

And when I debugg my application it takes alot to execute this instruction

my application crashes because it run out of memory I am wondering if the statment above is incorrect to achieve the goal of formatting columns F through J

s1 is actually

Dim s1 As Style = New Style

s1.Number = 14 'thas is mm/dd/yy;@"

I will appreciate any help


Please use the latest version:
Aspose.Cells for .NET (Latest Version)

Please try the following code and let us know your feedback.

StyleFlag flag = new StyleFlag();
flag.All = true;
objWB.Worksheets(objWB.Worksheets.Count - 1).Cells.CreateRange(“F:J”).ApplyStyle(s1, flag);


Also, check the topic for your complete reference:
Using Named Ranges

If you still find any issue, give us your sample code and template file(s) to show the issue, we will check your issue soon.

Also, we recommend you to try our latest versions:
Aspose.Cells for .NET (Latest Version)

Thank you.

I am still unable to make my report work it maybe a bug on my code

I will try your suggestions and follow up

Thank you for your response


OK, sure you may follow up our suggestions and see reference document.

As a side note, I recommend you to kindly create range specifying with complete rows details on which you need to apply style,

Range range = cells.CreateRange("F1:J100");

Thank you.