开发者

Is there a way to get byte[] from ExcelWorkBook without saving it to disk first

开发者 https://www.devze.com 2023-04-11 10:13 出处:网络
I\'m using Microsoft.Office.Interop.Excel to create Excel file in C#, append data, change format and all.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号