public void Print(string fileName)
{
// print disini
XSSFWorkbook xssfworkbook = CreateReport();
if (xssfworkbook != null)
{
string password = "123As";
MemoryStream mStream = new MemoryStream();
xssfworkbook.Write(mStream);
//to ensure memory stream can be expandable
Stream stream = new MemoryStream();
stream.Write(mStream.ToArray(), 0, mStream.ToArray().Length);
using (MemoryStream memOutput = new MemoryStream())
{
Context.Response.BinaryWrite(Utilities.SetPassword(stream, password));
Context.Response.ContentType = "application/pdf";
Context.Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", fileName));
Context.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Context.Response.End();
}
}
}
how to export workbook NPOI to excel file with password
Saturday, October 5, 2019 on Labels: NPOI, Write excel with password
code example how to write excel with NPOI library used password
No comments:
Post a Comment