Copying Excel File Problem

G

Guest

Hello,

I'm trying to the following scenario in Excel2007:

1) Reading binary data for an Excel workbook file and saving these binary
data in Database
2) Reading the binary data from the database and saving it to a file by
using File.Write mehtod of .Net
3) When openning the file in Excel2007, i get the following message "Excel
completed file level validation and repair. Some parts of this workbook may
have been repaired or discarded"

Why I'm getting this message even in the simple workbook which contain only
one value in one cell?
 
N

NickHK

Raja,
You mean that you are storing the Excel file as a BLOB in a database ?

If so, it would seems that you are creating corruption somewhere during the
read/write process.

NickHK
 
G

Guest

yes I'm storing the excel file(.xlsm) as a BLOB in a database, and here is my
code

Dim lStream As System.IO.FileStream = System.IO.File.OpenRead("myFile")
ReDim lByte(CInt(lStream.Length))
Call lStream.Read(lByte, 0, CInt(lStream.Length))
lFile = System.IO.File.Create("newFile")
Call lFile.Write(lByte, 0, lByte.Length)
Call lFile.Close()
 
N

NickHK

Raja,
I don't use .Net, so can't say if it is correct or not. However, are you
sure this is working with binary data, rather some text form, similar to FTP
transfer where you have a choice of modes.
This work in VB/VBA:

Private Sub CommandButton2_Click()
Dim arrByte() As Byte

Open "C:\Book2.xls" For Binary As #1
ReDim arrByte(LOF(1))
Get #1, , arrByte
Close #1

Open "C:\Out.xls" For Binary As #1
Put #1, , arrByte
Close #1

End Sub

Maybe asking in one of the .net groups or a group for your database would be
better, as this is not really an Excel matter.

NickHK
 
G

Guest

Hi the .Net code is ok and works fine with Excel2003. the problem occurs only
in .xlsm file format which is added in Excel 2007

Regards,
Raja
 
G

Guest

I've tested the code you've written, and i got the same problem with
Excel2007 xlsm file format

Thanks,
Raja
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top