Comments (4)
No feedback about this issue?
Seems that first section is filled very fast, but starting with the second section, the fill of the table is very slow.
No one encountered this issue?
Am I doing something wrong?
from docx.
Hi,
Try using the table insertion in the docx after filling the table's Paragraph :
var p = sec.InsertParagraph(); p.InsertTableAfterSelf( table );
after the Append of "FieldX".
It should works.
I don't see this table filling being slow.
Thank you.
from docx.
I've tried your solution, but the table is append with all those rows as empty rows. But if I add the table in the doc before starting the population-loop, the paragraphs are displaying correctly after opening the docx file. Only that the populating job is very slow for the second section. And even slower for the next section, and so on...
Please make a test, with some random data. Fill a table with 1000 records, and group them in three sections, like three sub-tables. And try to populate after that a docx table for each datatable, in separate sections. For me it works very slow from the second section to the last one. And if I don't find a solution, I must find another way to save the data to a docx file, unfortunatelly, because I cannot wait 5 minutes for 1000 rows in a datatable. Is too much for me. 🙏
PS: I think something is happening with the latest version, because if I remember well, the version before didn't had the same lag.
from docx.
Hi,
I agree with you, 5 min of waiting is not acceptable. There could be something different in the latest version.
Could you build up the test you are talking about in the preceding post?
This way, I would test the same sample as you.
When I test something like the initial post of this thread, I don't see anything slow. Here's my sample :
`var doc = DocX.Create( "test.docx" );
var counter = -1;
while( ++counter < 4 )
{
doc.InsertSection();
}
var sec = doc.Sections[ 0 ];
for( int k = 0; k < 4; 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( "test" + k ).SpacingBefore( 20d ).Font( "Arial" ).FontSize( 10 ).Bold().SpacingAfter( 10d );
var table = doc.AddTable( 2, 9 );
table.SetTableCellMargin( TableCellMarginType.left, 1 );
table.SetTableCellMargin( TableCellMarginType.right, 1 );
table.SetTableCellMargin( TableCellMarginType.top, 1 );
table.SetTableCellMargin( TableCellMarginType.bottom, 1 );
//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 );
var p = sec.InsertParagraph();
p.InsertTableAfterSelf( table );
}
doc.Save();`
Thank you for your help
from docx.
Related Issues (20)
- Inserting hyperlinks completes yet resulting file is corrupted HOT 3
- replancetextwithobject error HOT 1
- System.OutOfMemoryException HOT 3
- Writing a long docx file HOT 1
- ReplaceText in Header/Footer broke in v 2.5.0 HOT 3
- KeepWithNextParagraph() is not working with table rows HOT 1
- Inserting HTML not supported HOT 1
- how to insert a audio or other binary files HOT 2
- [Table] Lost cell with InsertRow() fuction HOT 1
- Does the library support "if" conditions?
- Support for multi-type series icons HOT 3
- DocX.ConvertToPdf() does not convert inserted html content. HOT 5
- [question] Loop through document items HOT 7
- Replace Tag to image not work HOT 1
- InsertContent as append from Paragraph HOT 3
- Table.IndentFromLeft not working? HOT 4
- Issue Loading ListParagraph when using Document template HOT 1
- No way to add parallel images HOT 1
- Cannot Detect true page count HOT 1
- InsertParagraphAfterSelf throws an error after update to v2.5.0 or v3.0.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docx.