Borders on empty cells
See original GitHub issueI’m trying to add borders on all cells, including empty ones. Here is the code I tried to use:
var borderStyles = {
top: { style: "thin" },
left: { style: "thin" },
bottom: { style: "thin" },
right: { style: "thin" }
};
worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
cell.border = borderStyles;
});
});
I thought that using { includeEmpty: true }
would do this for me, but it doesn’t seem to work, as you can see here:
I want the gaps in between the sections to have borders as well. I made those gaps by doing addRow
and passing it an empty object {}
, could that be causing an issue?
Or is there any other way to get borders to appear on all cells?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
empty-cells - CSS: Cascading Style Sheets - MDN Web Docs
The empty-cells CSS property sets whether borders and backgrounds appear around cells that have no visible content.
Read more >CSS Empty-cells Property - W3Schools
The empty-cells property sets whether or not to display borders on empty cells in a table. Note: This property has no effect if...
Read more >empty-cells - CSS-Tricks
The empty-cells property in CSS selects empty table cells for the purpose of specifying whether or not to display borders and backgrounds on ......
Read more >How to hide border and background on empty cells in a table ...
In this article, we will learn how to hide borders and backgrounds on empty cells in a table using CSS. The empty-cells property...
Read more >Apply or remove cell borders on a worksheet - Microsoft Support
On a worksheet, select the cell or range of cells that you want to add a border to, change the border style on,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I managed to get this working by tweaking the code locally. I hope to get a PR open by mid next week.
The basic problem is that there are several places in the codebase where it checks to see if a cell has a type of
Enum.ValueType.Null
and if it does, it doesn’t include it in the final render, presumably as an optimization. This is, of course, problematic when that cell still have styles applied to it, despite being empty.The short summary of my local changes is that I:
if (cell.type != Enum.ValueType.Null)
check in theget model()
accessor inrow.js
spans="<%=row.min%>:<%=row.max">
attribute in the row section ofsheet.xml
since I had a hard time getting the min and max there to actually work (spans is an optional optimization attribute anyway).default:
case to theswitch (cell.type)
statement inxlsx.js
to do the same thing it was already doing forcase Enums.ValueType.Merge
.I am facing the same problem… I found a workaround by placing empty strings to force values on cells. It works this way, although it’s causing me trouble with cell merging in MS Excel
if (!cell.value) { cell.value = ‘’; }