0

我正在尝试下载在 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>

我比较了原始文件的内容和下载文件的文本差异,如垃圾字符,但找不到任何

4

0 回答 0