Note that there are some explanatory texts on larger screens.

plurals
  1. POError opening Office files downloaded from sql server
    primarykey
    data
    text
    <p>The original office file is working with no problems (I tried word and excel), but when I upload the file to a database as binary and then download it from there to my PC and open the downloaded file, I get warning messages "excel found content cannot read" etc. and the file is getting plainer compared to the original file.</p> <p><strong>The exact error message is;</strong> "Excel found unreadable content in filename.xls. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes."</p> <p>How I upload the file:</p> <pre><code>'UPLOAD FILE Dim fi As New FileInfo(FilePath) Dim s As Stream = fi.OpenRead() Dim buffer(fi.Length) As Byte 'I put the buffer in database in varbinary(max) format s.Read(buffer, 0, fi.Length) s.Close() </code></pre> <p>How I download and open the file:</p> <pre><code>'DOWNLOAD FILE Dim fi As New FileInfo(FilePath) Dim s As Stream = fi.OpenWrite() Dim buffer As Byte() = reader("Binary") s.Write(buffer, 0, buffer.Length) s.Close() 'OPEN FILE Dim p As New Process p.StartInfo = New ProcessStartInfo(FilePath) p.Start() </code></pre> <p><strong>UPDATE:</strong></p> <p>As suggested, I tried simply copying the file, taking SQL completely out of the mix. Here is the code I tried, which also failed:</p> <pre><code>Private Sub CopyFile(ByVal filePath As String) Dim fi As New FileInfo(filePath) Dim s As Stream = fi.OpenRead() Dim buffer(CType(fi.Length, Integer) - 1) As Byte s.Read(buffer, 0, CType(fi.Length, Integer)) s.Close() Dim fi2 As New FileInfo(filePath &amp; " Copy") Dim s2 As Stream = fi2.OpenWrite() s2.Write(buffer, 0, buffer.Length) s2.Close() End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload