Opening a client-side Excel file using EPPlus

自闭症网瘾萝莉.ら 提交于 2019-12-04 15:29:16

Right, I believe I've found the answer:

1) Get the file details from a fileupload control 2) Convert this to a memory stream 3) Create the package using the memory stream

And the code is as follows:

if (FileUpload1.HasFile)
        {

            HttpPostedFile file = Request.Files[0];
            myLabel.Text = file.FileName;
            MemoryStream mem = new MemoryStream();
            mem.SetLength((int)file.ContentLength);

            file.InputStream.Read(mem.GetBuffer(), 0, (int)file.ContentLength);

            ExcelPackage package = new ExcelPackage(mem);


            ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
            myLabel.Text += " " + worksheet.Name;

        }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!