Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
I have got some really weird behavior generating tables. I'm wondering
if I'm using your library wrong and need to be doing something a little
different or if this is actually bad with the library/docx standard. If this
is a problem then I'm not sure if it's on your radar to support with the
target of this library. If you have any feedback on where to look further
then I would appreciate hearing it.
The image shows the top portion of a larger table.
The code used to merge the cells is below.
private static void LabelCell(ICollection<WordProcessingML.TableCell> cells, string text, int x, int y, int xspan, int yspan, int size=8)
{
var cellParts = new List<WordProcessingML.DocumentPart>();
var run = new WordProcessingML.Run(true, false, false, false, "000000", text, "Times New Roman", size);
var runs = new List<WordProcessingML.Run> {run};
cellParts.Add(Api.IntoPart(Api.Paragraph(runs), null, null, null));
cells.Add(Api.Cell(xspan, yspan, cellParts, x, y));
}
...
var cells = new List<WordProcessingML.TableCell>();
LabelCell(cells, "Test Report (A)", 0, 0, 2, 2, 12);
...
var table = Api.Table(10, 8, cells, WordProcessingML.Alignment.Center);
I first thought that merged cell was somehow unsetting only a portion of the border.
This isn't the case since I am going through every cell in the table and setting a border
style. Now I'm remembering behavior where I was able to make a single cell have the
shape of a "U", I'm wondering if maybe that is going on here where each individual cell
below is inadvertently merged up using OfficeIMO. I looked through the source and saw
that you were only setting some values in the xml. I'm not sure what the problem is exactly,
But I can say that in the earliest versions of this library when I was using OpenXML directly
I was getting the behavior and I believe that I noticed MS Word and LibreOffice interpreting
the structure of the table slightly differently so this might be some kind of undocumented
behavior in docx.
Discount most of this, I think that I found the bug in my code. However I'm leaving this open because maybe you should be aware that this behavior exists if it's undesired.
I have got some really weird behavior generating tables. I'm wondering if I'm using your library wrong and need to be doing something a little different or if this is actually bad with the library/docx standard. If this is a problem then I'm not sure if it's on your radar to support with the target of this library. If you have any feedback on where to look further then I would appreciate hearing it.
WordTableCellBorders Source WordTableCell Source WordTable Source
Library File The file will be renamed later. Library C# API File
The image shows the top portion of a larger table. The code used to merge the cells is below.
I first thought that merged cell was somehow unsetting only a portion of the border. This isn't the case since I am going through every cell in the table and setting a border style. Now I'm remembering behavior where I was able to make a single cell have the shape of a "U", I'm wondering if maybe that is going on here where each individual cell below is inadvertently merged up using OfficeIMO. I looked through the source and saw that you were only setting some values in the xml. I'm not sure what the problem is exactly, But I can say that in the earliest versions of this library when I was using OpenXML directly I was getting the behavior and I believe that I noticed MS Word and LibreOffice interpreting the structure of the table slightly differently so this might be some kind of undocumented behavior in docx.
Thanks