[英]Spreadsheetlight: Border around cell range, no internal borders
使用 SpreadsheetLight 我想在單元格范圍周圍添加一個邊框(僅)。 該范圍內不應有任何邊界。
我想要的是:
我得到什么:
我使用的代碼:
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;
我究竟做錯了什么? 我希望選項 Border.Outline = true 只產生一個輪廓。 將其設置為 false 不會更改 output 中的任何內容。 我在 3.5.0 版(NuGet 上的最新版本)中使用 SpreadsheetLight。
我無法解決 styles 的問題,但我找到了另一種繪制邊框的選項,這個選項實際上繪制了我想要的輪廓。 也許這可以幫助其他有同樣問題的人:
testDoc.DrawBorder("A3", "F5", DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
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;
定義 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.