我正在尝试下载在sql server 2008R2中存储为varbinary的xlsx
Dim command2 As New SqlCommand("SELECT data FROM DocsTable WHERE ID = '" & Id.ToString() & "' ", con)
Response.AddHeader("Content-Disposition", "attachment;filename=Test.xlsx")
Dim command6 As New SqlCommand("SELECT DATALENGTH(data) FROM DocsTable WHERE ID = '" & Id.ToString() & "' ", con)
Dim length As String = command6.ExecuteScalar()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Length", length)
Response.BinaryWrite(dr(0))
Response.Flush()
Response.End()
当我尝试打开时,打开下载的文件,Excel给我一个错误 Excel在'Test.xlsx'中找到了不可读的内容。你想恢复这个工作簿的内容吗?如果您信任此工作簿的来源,请单击是
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error063040_01.xml</logFileName>
<summary>Errors were detected in file 'C:\Users\irstudent\Downloads\Test.xlsx'</summary>
<additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo>
</recoveryLog>
我比较了原始文件的内容和下载文件的文本差异,比如垃圾字符,但找不到任何