0

I am uploading ".xlsx" files to one of my web page in a calendar. While reading the file i am getting a message "Excel found unreadable content in 'test.xlsx' Do you want to recover the contents of the workbook? If i say YES then the content is loading properly. How to avoid this message while opening the xlsx files. I am able to open xls files normally. Here is my code. Can you guys advice on how to fix this issue? Thanks for your help.

If objDBReader.Read Then

                If objDBReader("UploadFileType") = "doc" Then
                    Response.ContentType = "application/msword"
                ElseIf objDBReader("UploadFileType") = "docx" Then
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
                ElseIf objDBReader("UploadFileType") = "htm" Then
                    Response.ContentType = "text/HTML"
                ElseIf objDBReader("UploadFileType") = "rtf" Then
                    Response.ContentType = "application/msword"
                ElseIf objDBReader("UploadFileType") = "txt" Then
                    Response.ContentType = "application/msword"
                ElseIf objDBReader("UploadFileType") = "xls" Then
                    Response.ContentType = "application/vnd.ms-excel"
                ElseIf objDBReader("UploadFileType") = "xlsx" Then
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                ElseIf objDBReader("UploadFileType") = "pdf" Then
                    Response.ContentType = "application/pdf"
                ElseIf objDBReader("UploadFileType") = "ppt" Then
                    Response.ContentType = "application/vnd.ms-powerpoint"
                ElseIf objDBReader("UploadFileType") = "pptm" Then
                    Response.ContentType = "application/vnd.ms-powerpoint"
                Else
                    Exit Sub
                End If

                Response.AppendHeader("content-disposition", "attachment;filename=" + objDBReader("FileName"))


                Response.Expires = 0
                Response.Buffer = True
                Response.Clear()

                Response.BinaryWrite(objDBReader("UploadFile"))
                objConn.Close()
                Response.End()
 End If
2
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by Begginnerdev
0

Guys,

Any idea on how to get rid of this message while opening the ".xlsx" file? Thanks

0

Do you have any generational specific formatting?

Example:

Any Excel 2003,2005,2007 formatting that is not compatible with your interopt?

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.