Hi Guys,
I am having problems with styling on borders on a web application I have upgraded.
Some of the bordering issues appear to be down to merge cells.
The code for Merge Cells is below now, firstly do I need to apply a style to the range?
Is there anything else I need to do.
Any advice on this would be a help.
private void MergeCells(int rowFrom, int rowTo, int columnFrom, int columnTo)
{
_currentSheet.Cells.Merge(rowFrom - 1, columnFrom - 1, rowTo - rowFrom + 1, columnTo - columnFrom + 1);
Range r = _currentSheet.Cells[rowFrom - 1, columnFrom - 1].GetMergedRange();
r.SetOutlineBorder(BorderType.LeftBorder, _borderStyle, _borderColour);
r.SetOutlineBorder(BorderType.RightBorder, _borderStyle, _borderColour);
r.SetOutlineBorder(BorderType.TopBorder, _borderStyle, _borderColour);
r.SetOutlineBorder(BorderType.BottomBorder, _borderStyle, _borderColour);
}
Kind Regards,
Partridge
Hi,
I suspect it might be some issue with your code, please debug your codes and fix it accordingly.
I have tested your scenario/ case using the following sample code (runnable), it works fine. I got the merged cell’s range with outline borders, see the output file (attached). I am using our latest version/fix Aspose.Cells for .NET v7.6.0.x.
Sample code:
Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
//Merge B2:E3 cells to B2 cell
cells.Merge(1, 1, 2, 4);
//Get the merge cell (B2) range.
Range range = cells[“B2”].GetMergedRange();
range.SetOutlineBorder(BorderType.TopBorder, CellBorderType.Thin, Color.Red);
range.SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Thin, Color.Red);
range.SetOutlineBorder(BorderType.LeftBorder, CellBorderType.Thin, Color.Red);
range.SetOutlineBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Red);
workbook.Save(@“e:\test2\testrangeoutlineborders1.xlsx”);
If you still find the issue, kindly provide us sample runnable code to evaluate your issue properly with your template Excel file (if you have any), we will check your issue soon.
Thank you.