Search code examples
npoi

NPOI border styles appear differently in macOS / iOS Preview


The following style

var style1 = (XSSFCellStyle)workbook.CreateCellStyle();
var pink = new XSSFColor(new byte[] { 228, 52, 145 });
style1.SetBorderColor(BorderSide.TOP, pink);
style1.BorderTop = BorderStyle.Medium;

Renders correctly in Excel

enter image description here

But not in macOS / iOS Preview

enter image description here

How could I make the borders appear correctly?


Solution

  • Finally, applying borders everywhere fixed the issue in macOS / iOS Preview. I added:

    var grayColor = new XSSFColor(new byte[] { 210, 210, 223 });
    style1.SetBorderColor(BorderSide.RIGHT, grayColor);
    style1.BorderRight = BorderStyle.Thin;
    style1.SetBorderColor(BorderSide.LEFT, grayColor);
    style1.BorderLeft = BorderStyle.Thin;
    style1.SetBorderColor(BorderSide.BOTTOM, grayColor);
    style1.BorderBottom = BorderStyle.Thin;