Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large Table building performance in v2.4 #452

Open
ghost opened this issue Feb 27, 2023 · 1 comment
Open

Large Table building performance in v2.4 #452

ghost opened this issue Feb 27, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 27, 2023

Hello,
I have been using this tool to generate large report documents (over 100 pages) that contain many large tables with data in them. This has worked until I recently attempted to upgrade from v2.3 to v2.4, and the time to generate these documents has dramatically increased to the point of rendering it unusable.

After investigating, I found that the time increases are all within rows that add the text to each cell, like this:

tbl.Rows[row].Cells[col].Paragraphs[0].Append(valueForCell);

If I remove or comment out these rows the document generation time is comparable to beforehand.

Looking at the changes since v2.3 in that function I see the new call to UpdateParagraphIndexesAndCurrentParagraphEndIndex:

public Paragraph Append( string text )
{
      var newRuns = HelperFunctions.FormatInput( text, null );
      this.Xml.Add( newRuns );

      _runs = this.Xml.Elements( XName.Get( "r", Document.w.NamespaceName ) ).Reverse().Take( newRuns.Count() ).ToList();

      this.UpdateParagraphIndexesAndCurrentParagraphEndIndex();
      return this;
}	

which in turn calls:

	this.Document.UpdateParagraphIndexes();

This new feature is not very performant when it comes to inserting data cell by cell into many larger tables. This appears to be already recognised somewhat as the Container function which has a way of internally disabling it via an internal member _preventUpdateParagraphIndexes:

internal void UpdateParagraphIndexes()
{
      if( this.Document._preventUpdateParagraphIndexes )
        return;

this internal member is used in a number of the ReplaceText methods to temporarily disable it.

Is there a way for us to disable this indexing feature temporarily ourselves until the entire table is built? If not, is this something that could be added in v2.5, as 2.4 is pretty much unusable at present?

@XceedBoucherS
Copy link
Collaborator

Hi,

thank you for your feedback.
This is a known issue and a fix has already been implemented. It will be included in v2.5.
It should improve your performance.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant