Copy Style

Hi,

I have copied the style from one cell into a new style object, saved it in a collection and applied it to another cell using the collection, this worked with v4.4.1, i have upgraded to v4.4.2 where Hyperlinks at pictures work, but the code for copying styles don't work:

string stName = "rHd" + risk.ToString();

//Copy Style of current Cell to add Property Underline

//Changing the current Style will affect other Cells!!!

//Maybe the use of flags will work

if (!ExcelStyles.ContainsKey(stName))

{

styleNumber = wb.Styles.Add();

newStyle = wb.Styles[styleNumber];

newStyle.Copy(cells[rowCnt, z].Style);

newStyle.Name = stName;

newStyle.Font.Underline = FontUnderlineType.Single;

ExcelStyles.Add(newStyle.Name, newStyle);

}

cells[rowCnt, z].Style = ExcelStyles[stName];

Maybe the bug is somewhere else, i use the old version for this week, and search the bug later.

Hi,

In the newer version, we introduced Cell.SetStyle(styleobject) and Cell.GetStyle() methods, kindly use them for your need. And we also introduced the Style.Update() method, you may use it if you want to change an existing style e.g..,

Style style = workbook.Styles["mystyle"];

style.Number = 14;

style.Font.Color = System.Drawing.Color.Red;

style.Update();//the style of those cells will be changed whom this style was applied.

If you still find any problem, kindly create a sample console application with template file to show the issue, we will check it soon.

Thank you.