Saving a workbook to memory stream

I`m saving the file to a memory stream and then to a database in an image type, when I try to open it again it throws an error : This file's format is not supported or you don't specify a correct format.

When I save it using Filestream it`s OK.

Hi,

Which version do you use?

Please try this fix.

If you still get the problem,please post your create file with FileStream. We will check it soon.

NO! same error

This doesn`t work

MemoryStream ms = new MemoryStream();

workbook.Save(ms, FileFormatType.Excel2003);

this works:

FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read);

then I pass it to a byte array and save it to the database. If I`ve saved it using memory stream it throws the error when trying to open it.

Hi,

Could you load the byte array (which saved by MemorStream) from the database ,save to disk and post it here ? We will check it soon.

OK. I uploaded the file.

Hi,

After checking your file, we found it's an ampty file.I tried following codes,it works fine.

Workbook workbook = new Workbook();

workbook.Open(@"F:\FileTemp\test.XLS");
MemoryStream ms = new MemoryStream();
workbook.Save(ms, FileFormatType.Excel2003);
byte[] arr = ms.ToArray();
FileStream fs = File.Create(@"F:\FileTemp\ddd.XLS");

fs.Write(arr, 0, arr.Length);
fs.Close();

Could post your sample project?