Word experienced an error trying to open the file

4 posts, 0 answers
  1. Evan
    Evan avatar
    13 posts
    Member since:
    Sep 2017

    Posted 14 Aug 2019 Link to this post

    I am trying to export my document but I am getting the error attached to the thread.

    I can fix this by going into the properties of the document and checking the unblock box. Is there a way to do this in the export to be able to just open the document without having to go into its properties? I get the same error on the demo page for generating word documents https://demos.telerik.com/aspnet-ajax/wordsprocessing/generate-documents/defaultcs.aspx

     

    Here is my code for export

    RadFlowDocument document = report.GenerateDoc();             

    DocxFormatProvider provider = new DocxFormatProvider();             

    MemoryStream ms = new MemoryStream();             

    provider.Export(document, ms);             

    byte[] byteArray = ms.ToArray();             

    ms.Dispose();             

    return File(byteArray, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "AAR.docx");

     

  2. Tanya
    Admin
    Tanya avatar
    877 posts

    Posted 19 Aug 2019 Link to this post

    Hello Evan,

    Using the provided code, I was able to successfully export a sample DOCX document. That is why my suggestion is that the error you are getting might be related to some content added to the document inside report.GenerateDoc(). Would it be possible to share its code so I can further investigate the case?

    Regards,
    Tanya
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Evan
    Evan avatar
    13 posts
    Member since:
    Sep 2017

    Posted 19 Aug 2019 in reply to Tanya Link to this post

    The code I have for generating the document is pretty long. I use sections for pages and I use paragraphs and tables. I do not think the error is related to the data that I am inserting because I get the same error from the demo page mentioned above. 

    From what I can tell it is more on the word document side not trusting the source of where the document came from. The fix that I saw was to enter the url as a trusted url and it will always be able to be opened without going into the properties. I dont want to have the user to have to change something on their computer to be able to open a document.

     

    If you have any more information about this it would be appreciated thanks.

  4. Tanya
    Admin
    Tanya avatar
    877 posts

    Posted 22 Aug 2019 Link to this post

    Hello Evan,

    As far as I understand, the file is being protected by MS Word due to security reasons. Please, correct me if I am wrong.

    This protection can be forced when the file is downloaded from the internet and placed in a temporary folder. However, this is a behavior of the Microsoft application and I am afraid that there is no any setting which can affect that on document level.

    Regards,
    Tanya
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top