Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4076064
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:22:40+00:00 2026-05-20T17:22:40+00:00

I have built a word document with Word 2007 and saved it. Then i

  • 0

I have built a word document with Word 2007 and saved it. Then i used OpenXML productivity tool and used code reflection to grab the C# code.

The next step I did was build a function that returns a tableRow object.
I would use my list I had built with LINQ to populate the text fields of
the row. I copied the row generation code from 1 of the built in rows of the
table, and filled in the fields in a loop, using

foreach(ClassForLinqResult lr in LinqResult)
{
  Table1.Append(CreateRow(lr.param1,lr.param2..etc));
}

The problem remains, when the server responds back with the file,
I get an error from word trying to open it:

"The file is corrupt and cannot be opened".

Was there some part of the code I missed that needs to be added somewhere
else for the rows I add? As it turns out when I use word to try to recover
the file, my rows are showing correctly.

The corrupted file has a package folder with a file in it like this:

package\services\metadata\core-properties\edf684ae4e35438dacc06cb66c0afad2.psmdcp

after it corrects the file it removes that and adds a core.xml file to the
“docProps” folder.

some other files are changed

customXML\item.xml changes to customXML\item1.xml after recovery
customXML\itemProps.xml changes to customXML\itemProps1.xml after recovery
customXML\item.xml.rels changes to customXML\item1.xml.rels after recovery
word\footer.xml changes to word\footer1.xml after recovery
word\theme\theme.xml changes to word\theme\theme1.xml

Anyway, if anyone has some tools that point out the problem for me I’d appreciate it.
I have tried

OpenXmlPackageValidationSettings validationSettings = new OpenXmlPackageValidationSettings();
validationSettings.EventHandler += new EventHandler<OpenXmlPackageValidationEventArgs>(PackageValidationEventHandler);
CreateParts(package,LicenseToPrint);
package.Validate(validationSettings);

This never hits any code indicating there was problem with the validation.
I have not been able to figure out the problem with the word document.
Can anyone help with an idea how to figure out the problem? Or perhaps I missed a step
that is causing my problem?

Additional Information:

This code is how I am rendering the docx file in asp.net

GeneratedClass c = new GeneratedClass();
        using (MemoryStream generatedStream = new MemoryStream())
        {
            c.CreatePackage(generatedStream,LicenseToPrint);
            ValidateDocument(generatedStream);
            Response.ClearHeaders();
            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment; FileName=\"License.docx\"");
            Response.ContentType = "application/msword";
            //Response.ContentType = "application/vnd.ms-word.document";
            generatedStream.WriteTo(Context.Response.OutputStream);
            Context.Response.Flush();
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:22:40+00:00Added an answer on May 20, 2026 at 5:22 pm

    I am not sure what was the cause, but I repeated my steps again and now have a file with no more errors with MS word. Copying from the Open XML tool into my code screwed up somewhere. If this happens to anyone doing similar steps, my suggestion is to repeat your steps, it may have been a slip up somewhere doing the copying of the code. The problem is if you have a lot of code written already and there’s too many steps to trace back. A versioning system should help in such a case. Thank you all

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a MS Access 2007 application that can create reports files in
I have built a windows service application in VB.net 2008, and used the Setup
I have a requirement to build an MS Word 2007 plugin that provides a
I have built an MSI that I would like to deploy, and update frequently.
I have built a simple C#.Net app on a M/C with only .Net FX
I have built a web page which contains a Crystal Report built using the
I have built an application in C# that I would like to be optimized
I have built a number of asp.net servercontrols into a class library, & I
I have built a .dll under WinXP that claims it can't find DWMAPI.DLL when
I have built a CFC designed to serve as a dynamic, aging cache intended

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.