Displaying Word & Excel 2007 documents from ASPX

Joined
Jul 21, 2010
Messages
1
Reaction score
0
I am loading documents into our Oracle database and then retrieving them for the users to view. So far PDF, DOC, XLS, CSV, etc. all perform as expected, however; DOCX, XLSX, etc. files have one annoyingly persistent issue.

When the document is downloaded by the user and they open it you get the first in a series of messages:

The file 'thefile.docx' cannot be opened because there are problems with the contents.

Details: The file is corrupt and cannot be opened.

and then:

Word found unreadable content in 'thefile.docx'. Do you want to recover the contents of this document? If you trust the source, click Yes.

After clicking yes the file opens and all of the content appears correct. Including images, formatting, tracked changeds and comments, equations, etc.

I have tried multiple methods along these lines to no avail. I simply want the files to open without the false-positive error messages.

I am using VS2010, with the website targeted at .Net Framework 2.0.

objConn = New OracleConnection(gstrConnectionString)

objConn.Open()

cmd =
New OracleCommand

cmd.Connection = objConn

cmd.CommandText =
"select DOCUMENT_NAME,DOCUMENT_TYPE,DOCUMENT from FTP_PERMIT_DOC where PERMIT_ID='" & strPermitID & "' and AMENDMENT_ID='" & strAmendmentID & "' and DOCUMENT_ID='" & strDocumentID & "'"

dr = cmd.ExecuteReader

dr.Read()

Dim blob As OracleBlob = dr.GetOracleBlob(2)

@

Response.Clear()

Response.ContentType = dr(
"DOCUMENT_TYPE")

Response.AppendHeader(
"Content-Disposition", "attachment;filename=" + dr("DOCUMENT_NAME"))

Response.BinaryWrite(blob.Value)

Response.End()

Response.Flush()



If anyone has any idea on how to avoid these annoying messages I would love to hear it!

-Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top