Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Commented Unassigned: CloneStyleFrom not working as expected [13369]

$
0
0
Hi,
I'm trying to clone a cellstyle using CloneStyleFrom however, it doesn't appear to be working as expected.
When I modify the 'cloned' style, the original cell style is also modified.

FYI - I'm using Version 2.1.3.0

Other than that - excellent work and thanks!

Code snippet...
```
private void Test()
{
IWorkbook workbook = new XSSFWorkbook();
sheet = workbook.CreateSheet("Sheet A1");
ICell cell = sheet.CreateRow(0).CreateCell(0);
cell.SetCellValue(1.00);
ICellStyle cellStyle = workbook.CreateCellStyle();
IDataFormat fmt = workbook.CreateDataFormat();
short xx = fmt.GetFormat("0.00");
cellStyle.DataFormat = xx;
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thick;
cellStyle.BottomBorderColor = 8;
cell.CellStyle = cellStyle;

ICellStyle cellStyle2 = workbook.CreateCellStyle();
cellStyle2.CloneStyleFrom(cellStyle);

//Below change also affects cellStyle...
cellStyle2.BorderBottom = NPOI.SS.UserModel.BorderStyle.None;

FileStream sw = File.Create("cellStyler.xlsx");
workbook.Write(sw);
sw.Close();
}

```
Comments: ** Comment from web user: tonyqus **

maybe something wrong with the instance object. A new object should be created. I'll check.


Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>