openXML spreadsheetdocument return byte array for MVC file download

后端 未结 2 1643
无人及你
无人及你 2021-01-02 04:29

I\'m trying to return a openXML spreadsheetdocument as a byte[] which I can then use to allow my MVC to send that file to a user. here is my spreadsheetdocument method to re

2条回答
  •  情歌与酒
    2021-01-02 04:37

    I had a similar problem with a Word document. I solved this by using the byte array outsite the using, like:

    
    byte[] returnBytes = null;
    using (MemoryStream mem = new MemoryStream())
      {
        // your code
        returnBytes = mem.ToArray();
      }
    
    return returnBytes;
    

提交回复
热议问题