Hi all,
i have some problems with the memorystream.
1) the program opens a Iworkbook
2) i fill this workbook/sheets
3) i send this workbook to the browser
workbook.SaveAs(sfile, Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2007);
this works fine...
But:
Save the workbook to the memory stream
MemoryStream ms = new MemoryStream();
workbook.SaveAs(ms);
and for testing back to file:
FileStream file = new FileStream(@"c:\test.xlsx", FileMode.Create, System.IO.FileAccess.Write);
byte[] bytes = new byte[ms.Length];
ms.Read(bytes, 0, (int)ms.Length);
file.Write(bytes, 0, bytes.Length);
file.Close();
ms.Close();
doesnt work. The filesize is exactly like the org file. But i cant open it.
But:
if i use this function:
workbook.SaveAs(@"C:\FromSaveAs.xlsx");
it works.
The point is - i want to save the file into a blob column of my database. My method of saving files/byte into my database works perfect on other projects/files. I think there is problem with the memorystream!?
Can someone help me?
Thanks
Markus