Is there a way to get byte[] from ExcelWorkBook without saving it to disk first
I'm using Microsoft.Office.Interop.Excel to create Excel file in C#, append data, change format and all. Now I save data into file, but what I want is to write bytes into stream, so basically I don't want to write it into file then open it and then write it into stream.
I just want to write data from Excel Workbook into byte array and then return it.
So what I do now is
xlWorkBook.SaveAs(path, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusi开发者_如何学运维ve, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
and I want to say something like this xlWorkBook.GetBytes();
. So byte[]
would be equal as byte[]
readed from excel file with FileStream
.
Thanks in advance.
There is no way to do this, except save as file then read it with filestream
精彩评论