Hi,
When I tried to change the number formatting of cells and copy/paste the range afterwards, I noticed borders of the cells were also changed unexpectedly.
Code:
var workbook = new Workbook(@".\test.xlsx"); var fromRange = workbook.Worksheets[0].Cells.CreateRange(1, 0, 5, 1).EntireRow; // copy rows 1 - 10 var toRange = workbook.Worksheets[1].Cells.CreateRange(11, 0, 1, 1); toRange.Copy(fromRange); // copy the data from the range workbook.Save(@".\out-before-number-format-change.xlsx"); foreach (var cell in fromRange.GetCells()) { var style = cell.GetStyle(); style.Custom = "0.000"; var styleFlag = new StyleFlag(); styleFlag.NumberFormat = true; // only number format should be changed cell.SetStyle(style, styleFlag); } toRange.Copy(fromRange); // copy the data from the range workbook.Save(@".\out-after-number-format-change.xlsx");
Supposedly, the difference between the two output xlsx files should only be the number formatting, but there were extra borders added in some cells.
I also tried to do it in Excel and did not see this issue after I re-applied number formats manually.
I’ve attached the test files and a screenshot for your reference. Could you please help me take a look?
test.zip (60.9 KB)
image.png (62.1 KB)
Thanks,