Using EPPlus with a MemoryStream

Using EPPlus with a MemoryStream

Asked on January 11, 2019 in Excel.
Add Comment


  • 3 Answer(s)

    Use this following command for Using EPPlus with a MemoryStream :

    using (var package = new ExcelPackage())
    {
        var worksheet = package.Workbook.Worksheets.Add("Worksheet Name");
     
        worksheet.Cells["A1"].LoadFromCollection(data);
     
        var stream = new MemoryStream(package.GetAsByteArray());
    }
    
    Answered on January 11, 2019.
    Add Comment

    Working the below code In VB.NET:

    Dim stream As New MemoryStream
    Using package As New ExcelPackage(stream)
       //Here goes the ExcelPackage code etc
       package.Save()
    End Using
    

    Working the below code In C#:

    MemoryStream stream = new MemoryStream();
    using (ExcelPackage package = new ExcelPackage(stream))
    {
        //Here goes the ExcelPackage code etc
        package.Save()
    }
    

    For a streams, The ExcelPackage has built-in support .

    Answered on January 11, 2019.
    Add Comment

    Use this alternative method :

          In case to keep at utilizing a stream for example. Response.OutputStrea, By using the SaveAs(Stream OutputStream) method, so now can make an Excel Package along with an null constructor.

    Answered on January 11, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.