none
Performance issue when working with large Word file using Word SDK RRS feed

  • Question

  • I'm experiencing the performance significantly slow down on processing large data using Word SDK. My .Net Application processes repetitive data(Each iteration does the same thing) that sometimes generates over 100 pages of Word document, it works fine at the beginning(about 1 second per iteration), but it singificantly slow down(more than 1 minute per iteration when document gets to 100 pages) when the document gets larger.  Any ideas on how to keep the same speed regardless the growing size of Word document that being processed? Thanks.

    Sunday, May 29, 2011 3:51 PM

Answers

  • Hi Cindy, thanks for your time and help.

    I think I found the issue that caused the performance issue in my application. The issue was in one of the API function call(table.Rows.Add()). The function was called in each iteration, I removed it out of the loop and added all the empty rows first at the beginning, then accessing each row using table.Rows(idx) instead, suprisingly it works.

    • Marked as answer by feg2008 Tuesday, May 31, 2011 9:05 PM
    Tuesday, May 31, 2011 6:51 PM

All replies

  • Try saving the document periodically as your code loops thru its processes.
    Kind Regards, Rich ... http://greatcirclelearning.com
    Monday, May 30, 2011 2:30 AM
  • Hi feg

    Which version of Word (Word file format) is involved?

    For anything that can use the Word docx file format you'll probably be faster generating a file in the Open XML file format, independant of the Word application. See OpenXMLDeveloper.org for more information.


    Cindy Meister, VSTO/Word MVP
    Monday, May 30, 2011 7:29 AM
    Moderator
  • Periodically saving the document doesn't work unless creating a new empty file periodically.

    The Word file format can be 97 -2010 formats. Aslo if I move to using open xml file format, it means I need to rewrite the whole thing which probably is not a good solution for me now.

    I guess Word application significantly slow down when it contains large contents. I tried clearing contents periodically and it can keep up with the same speed. However, I need to keep all the contents in one final file. Is there any functions in Word SDK that can suppress the contents instead of clearing them which I believe it could potentially solve the issue I'm having now?


    Monday, May 30, 2011 5:58 PM
  • Hi feg

    It would help, at this point, to see what code it is you're using for the iteration...


    Cindy Meister, VSTO/Word MVP
    Tuesday, May 31, 2011 8:58 AM
    Moderator
  • Hi Cindy, thanks for your time and help.

    I think I found the issue that caused the performance issue in my application. The issue was in one of the API function call(table.Rows.Add()). The function was called in each iteration, I removed it out of the loop and added all the empty rows first at the beginning, then accessing each row using table.Rows(idx) instead, suprisingly it works.

    • Marked as answer by feg2008 Tuesday, May 31, 2011 9:05 PM
    Tuesday, May 31, 2011 6:51 PM