Spreadsheetlight: Border around cell range, no internal borders

1k Views Asked by At

Using SpreadsheetLight I want to add a border (only) around a cell range. There shouldn't be any borders inside that range.

What I want:

What I want

What I get:

enter image description here

Code I used:

var testDoc = new SLDocument();

var testStyle = testDoc.CreateStyle();
testStyle.Border.Outline = true;
testStyle.Border.SetLeftBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
testStyle.Border.SetRightBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
testStyle.Border.SetTopBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
testStyle.Border.SetBottomBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
testDoc.SetCellStyle("A3", "F5", testStyle);

return testDoc;

What am I doing wrong? I expected the option Border.Outline = true to result in only producing an outline. Setting it to false doesn't change anything in the output. I'm using SpreadsheetLight in the version 3.5.0 (most current version on NuGet).

1

There are 1 best solutions below

0
On BEST ANSWER

I couldn't fix the problem with the styles, but I found another option to draw borders, and this one actually draws an outline like I wanted. Maybe this helps others having the same problem:

testDoc.DrawBorder("A3", "F5", DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);