none
Creating Word Doc takes a prox. 14 seconds RRS feed

  • Question

  • Hi,

    does anyone have any idea how to speedup the creation of a simple word doc?

    creating a blanc (empty) word doc have a duration of 14 seconds, the second time the document is created it takes only milliseconds,.......

    please reply your suggestions

     

    Thx

     


    Luc
    Tuesday, July 5, 2011 7:24 PM

Answers

  • Hi Luc Nuyts,

    How about the problem on your side? Does the suggestion help you to resolve your problem? If you still show any concern on the thread, just feel free to follow up and wish you a nice day.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Luc Nuyts Tuesday, July 12, 2011 8:31 AM
    Tuesday, July 12, 2011 8:25 AM

All replies

  • Hi Luc Nuyts,

    How did you create the simple word doc? Does your word document contain lots of data? Could you show us some code snippet? You can try to use the following code snippet: 

     

    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Wordprocessing;
    using DocumentFormat.OpenXml;
    
    namespace GenerateWordDocs
    {
     class Program
     {
      static void Main(string[] args)
      {
       HelloWorld("helloword.docx");
      }
    
      public static void HelloWorld(string docName)
      {
       // Create a Wordprocessing document. 
       using (WordprocessingDocument package = WordprocessingDocument.Create(docName, WordprocessingDocumentType.Document))
       {
        // Add a new main document part. 
        package.AddMainDocumentPart();
    
        // Create the Document DOM. 
        package.MainDocumentPart.Document =
         new Document(
         new Body(
          new Paragraph(
          new Run(
           new Text("Hello World!")))));
    
        // Save changes to the main document part. 
        package.MainDocumentPart.Document.Save();
       }
      }
     }
    }
    
    

     

    which runs fast on my side.

    Hope this can give you some hint.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Thursday, July 7, 2011 2:36 AM
  • Hi Luc Nuyts,

    How about the problem on your side? Does the suggestion help you to resolve your problem? If you still show any concern on the thread, just feel free to follow up and wish you a nice day.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Luc Nuyts Tuesday, July 12, 2011 8:31 AM
    Tuesday, July 12, 2011 8:25 AM