How to reuse style settings in Aspose.Cells

Hello:

I am setting several styles for a spreadsheet, but I would like to put all these styles in a separate class or method so that I can resuse them from several different methods. I can't figure out how to make this work.

Could you please explain how I can to this?

Thanks,

Mark

Hi,

Please create Style objects and save them in your List or Array object and whenever you need to reuse any of them, just access them from array and pass it as a parameter to .SetStyle() method.

e.g


//Create a new style

Style yourExistingStyle = workbook.CreateStyle(…)

//Set style’s different properties/settings



//Save it in a list

list.Add(yourExistingStyle);


//Do your rest of work




//Access it from your list

yourExistingStyle = list[index];


Cell cellA1…

cellA1.SetStyle(yourExistingStyle); //which you retrieved from your list