Bug with Open XML SDK
- Dominant language
- C#
- Stars
- 4.6k
- Forks
- 605
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Docx file generated with OpenXML isn't able to be exported by soffice in linux (has something to do with the content)
**To Reproduce**
```
using (MemoryStream memoryStream = new MemoryStream())
{
using (var doc = DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create(memoryStream, DocumentFormat.OpenXml.WordprocessingDocumentType.Document, true))
{
MainDocumentPart mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
var table = new Table();
TableProperties tableProperties = new TableProperties();
tableProperties.TableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };
table.AppendChild(tableProperties);
TableGrid tableGrid = new TableGrid(
new GridColumn(),
new GridColumn()
);
table.AppendChild(tableGrid);
TableRow tableRow = new TableRow();
TableCell tc1 = new TableCell(
new TableCellProperties(new TableCellWidth() { Width = "2500", Type = TableWidthUnitValues.Pct }),
new Paragraph(new Run(
new RunProperties(new FontSize() { Val = "56" }, new RunFonts() { Ascii = "Times New Roman" }),
new Text("Patient Hours Detail")
)
)
);
TableCell tc2 = new TableCell(
new TableCellProperties(new TableCellWidth() { Width = "2500", Type = TableWidthUnitValues.Pct }),
new Paragraph(new ParagraphProperties(new Justification() { Val = JustificationValues.Right }), new Run(new RunProperties(new FontSize() { Val = "34" }, new RunFonts() { Ascii = "Times New Roman" }), new Text(model.CaseName))),
new Paragraph(new ParagraphProperties(new Justification() { Val = JustificationValues.Right }), new Run(new RunProperties(new FontSize() { Val = "26" }, new RunFonts() { Ascii = "Times New Roman" }), new Text($"{model.StartDate.ToString("MM/dd/yyyy")} through {model.EndDate.ToString("MM/dd/yyyy")}")))
);
tableRow.Append(tc1);
tableRow.Append(tc2);
table.AppendChild(tableRow);
body.Append(table);
doc.Save();
memoryStream.Position = 0;
var byteArray = memoryStream.ToArray();
return byteArray;
```
then save the byteArray as "sdfomsef.docx" locally
then soffice --headless --convert-to pdf sdfomsef.docx
Error: source file could not be loaded
**Expected behavior**
If I try remove the 2nd table cell this works (this line tableRow.Append(tc2);)
**Desktop (please complete the following information):**
- OS: Docker mcr.microsoft.com/dotnet/aspnet:6.0
- Office version [e.g. 16.0.15427.20178]
- .NET Target: .net6
- DocumentFormat.OpenXml Version: 3.0.1
Contributor guide
Assessment
This issue has not been assessed yet.