Exporting a DataTable from WinForms to a docx file takes a lot of time
还没有人认领这个 Issue。
评估
调研方向
Reproduce the report using the shown DocX.Create, InsertSection, AddTable, and InsertTableAfterSelf flow, comparing behavior between versions 2.3.0 and 2.4.0. Inspect why table-cell paragraphs remain empty and why section header/footer warnings appear during export. Done means table contents are populated and the export time is no longer unexpectedly slow.
由索引模型根据 Issue 内容生成。
描述
Hi.
I've just updated from 2.3.0 to 2.4.0, because I just want to use the new parameter from Section page numeration. But now the exporting process takes a lot of time, and I don't know why, because I'm using the same code as I used on the previous version. What happened with the new version?
Edit: More than that, my all table is empty. Seems none of the paragraphs inside the table object are filled. But is the same code as in 2.3.0, what has been changed?
OK. I've started debugging this thing and I found the following:
After each line of code which is using some appending operation, or anything that involve an object on the file, I get the following lines of information in debugger:
This document contains more than 1 section. Consider using Sections[wantedSection].Headers.
This document contains more than 1 section. Consider using Sections[wantedSection].Headers.
This document contains more than 1 section. Consider using Sections[wantedSection].Headers.
This document contains more than 1 section. Consider using Sections[wantedSection].Footers.
This document contains more than 1 section. Consider using Sections[wantedSection].Footers.
This document contains more than 1 section. Consider using Sections[wantedSection].Footers.
My code is the following, what I'm doing wrong?
DocX doc = DocX.Create(filePath, DocumentTypes.Document);
while (doc.Sections.Count < numeGrup.Count)
{
// I need to insert sections for each group in "numeGrup" list
doc.InsertSection();
}
var sec = doc.Sections[0];
for (int k = 0; k < numeGrup.Count; k++)
{
sec = doc.Sections[k];
sec.PageLayout.Orientation = Orientation.Landscape;
sec.PageNumberType.PageNumberStart = 1;
sec.PageWidth = 800;
sec.MarginLeft = 20;
sec.MarginRight = 20;
sec.MarginTop = 20;
sec.MarginBottom = 20;
sec.InsertParagraph(numeGrup[k].Key.Nume).SpacingBefore(20d).Font("Arial").FontSize(10).Bold().SpacingAfter(10d);
var table = doc.AddTable(detaliiPeFirma.Count() + 1 + groups.Count, 9);
table.SetTableCellMargin(TableCellMarginType.left, 1);
table.SetTableCellMargin(TableCellMarginType.right, 1);
table.SetTableCellMargin(TableCellMarginType.top, 1);
table.SetTableCellMargin(TableCellMarginType.bottom, 1);
var p = sec.InsertParagraph();
p.InsertTableAfterSelf(table);
table.Design = TableDesign.LightGrid;
var headerRow = table.Rows.First();
headerRow.TableHeader = true;
headerRow.Cells[0].Paragraphs[0].Append("Field1").Bold().FontSize(10);
headerRow.Cells[1].Paragraphs[0].Append("Field2").Bold().FontSize(10);
headerRow.Cells[2].Paragraphs[0].Append("Field3").Bold().FontSize(10);
headerRow.Cells[3].Paragraphs[0].Append("Field4").Bold().FontSize(10);
headerRow.Cells[4].Paragraphs[0].Append("Field5").Bold().FontSize(10);
headerRow.Cells[5].Paragraphs[0].Append("Field6").Bold().FontSize(10);
headerRow.Cells[6].Paragraphs[0].Append("Field7").Bold().FontSize(10);
headerRow.Cells[7].Paragraphs[0].Append("Field8").Bold().FontSize(10);
headerRow.Cells[8].Paragraphs[0].Append("Field9").Bold().FontSize(10);
}
I put only a part of my code, the generation of tables and filling of headers of the tables. But no paragraph inside table's cells are filled. And it's working very slow now! Maybe because of those messages in the debugger?
- 主要语言
- C#
- 星标
- 1.9k
- 派生
- 482
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
xceedsoftware/DocX 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 48/100
xceedsoftware/DocX#489 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
xceedsoftware/DocX#488 · 1 条评论 · 1 个 reaction ·
-
keep format未关闭
难度 3/5 1-2 天 新手友好度 25/100
xceedsoftware/DocX#487 · 3 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
xceedsoftware/DocX#485 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
xceedsoftware/DocX#482 · 4 条评论 ·
查看 xceedsoftware/DocX 的全部 Issue
相似的 Issue
-
effort:S P3 refactor
难度 2/5 1-3 小时 新手友好度 72/100
nightscout/nocturne#3243 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
dasher-project/Dasher-Windows#84 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
libnativeapi/nativeapi#21 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 3 天内回复
-
enhancement P3 performance
难度 2/5 1-3 小时 新手友好度 75/100
thomhurst/TUnit#7380 · 2 条评论 ·
维护者通常 1 天内回复