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

Recommended Answers

All 2 Replies

Guys,

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

Do you have any generational specific formatting?

Example:

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.