Reading ".xlsx" files from a web browser

saidev

Active member
Joined
Dec 22, 2005
Messages
27
Programming Experience
1-3
Posted - 05/11/2012 : 18:38:13
--------------------------------------------------------------------------------

Hi Guys,

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
 
Back
Top