Exporting a DataTable from WinForms to a docx file takes a lot of time

Abierto
#448 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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?

Lenguaje dominante
C#
Estrellas
1.9k
Forks
482
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de xceedsoftware/DocX

Todos los issues de xceedsoftware/DocX

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.