简体   繁体   English

Spreadsheetlight:单元格范围周围的边框,没有内部边框

[英]Spreadsheetlight: Border around cell range, no internal borders

Using SpreadsheetLight I want to add a border (only) around a cell range.使用 SpreadsheetLight 我想在单元格范围周围添加一个边框(仅)。 There shouldn't be any borders inside that range.该范围内不应有任何边界。

What I want:我想要的是:

我想要的是

What I get:我得到什么:

在此处输入图像描述

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.我希望选项 Border.Outline = true 只产生一个轮廓。 Setting it to false doesn't change anything in the output.将其设置为 false 不会更改 output 中的任何内容。 I'm using SpreadsheetLight in the version 3.5.0 (most current version on NuGet).我在 3.5.0 版(NuGet 上的最新版本)中使用 SpreadsheetLight。

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.我无法解决 styles 的问题,但我找到了另一种绘制边框的选项,这个选项实际上绘制了我想要的轮廓。 Maybe this helps others having the same problem:也许这可以帮助其他有同样问题的人:

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

Estableces tus estilos: Estableces tus estilos:

style.Border.LeftBorder.BorderStyle = BorderStyleValues.Thin;
style.Border.LeftBorder.Color = System.Drawing.Color.Black;
style.Border.RightBorder.BorderStyle = BorderStyleValues.Thin;
style.Border.RightBorder.Color = System.Drawing.Color.Black;
style.Border.BottomBorder.BorderStyle = BorderStyleValues.Thin;
style.Border.BottomBorder.Color = System.Drawing.Color.Black;
style.Border.TopBorder.BorderStyle = BorderStyleValues.Thin;
style.Border.TopBorder.Color = System.Drawing.Color.Black;

Defines el rango de celdas a aplicarle el estilo definido que incluyen los margenes定义 elrango de celdas a aplicarle el estilo definido que incluyen los margenes

slExcel.MergeWorksheetCells("B6","P6", style);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM