当前位置:网站首页>Asp. Net webform exporting excel using npoi
Asp. Net webform exporting excel using npoi
2022-06-25 13:47:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
I don't say much nonsense , Go straight to the code
public void ExportExcel()
{
string datefrom = Request.QueryString["datefrom"];
string dateto = Request.QueryString["dateto"];
string ID = Request.QueryString["ID"];
Report_AgentModel model = new Report_AgentModel();
string strSql = model.getExcelSql(datefrom, dateto, ID);
string sort = "createtime desc";
string sheetName = "Report_Agent";
ExcelHelper help = new ExcelHelper();
ExcelHelper.NpoiMemoryStream ms = help.ExportExcel(sheetName, strSql, sort);
// Output Excel
string filename = "Report_Agent_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Length", ms.Length.ToString());
Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Server.UrlEncode(filename)));
Response.BinaryWrite(ms.GetBuffer());
Response.Flush();
Response.End();
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151689.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢

Implementation of a small book system

Application of tactile intelligent sharing-rk3568 in financial self-service terminal

Rust, le meilleur choix pour un programmeur de démarrer une entreprise?

Gorm---- Association query

数据在内存中的存储相关内容

算力&NFT交易平台F3.xyz旗下独家权益NFT项目Hash Eagle将盛大发行

關於一道教材題的講解

“移动云杯”算力网络应用创新大赛火热报名中!

The starting point for learning programming.
![[open source Hongmeng system display] the rk3568 development board is equipped with openharmony 3.1 release](/img/c4/0bfb380d38b5205a02a10175ee6888.png)
[open source Hongmeng system display] the rk3568 development board is equipped with openharmony 3.1 release
随机推荐
Application of tactile intelligent sharing-rk3568 in financial self-service terminal
国信证券股票账户开户安全吗?请问。
Some knowledge about structure, enumeration and union
API in Nova
Assemble relevant knowledge points of flag bit (connected)
权益NFT开创者Hash Eagle如何重新定义NFT,用权益赋能长续价值?
关于猜数字游戏的实现
Parabolic motion in unity 2D games
go---- mgo
VGA display of de2-115 FPGA development board
[pit avoidance means "difficult"] the antd form dynamic form is deleted, and the first line is displayed by default
QT mouse tracking
Kubernetes cluster construction of multiple ECS
Vscode--- format setting configuration
Prototype and prototype chain - constructor and instanceof
戴尔电脑cpu温度过高怎么办
Pointer, it has to say that the subject
Is it safe for Guosen Securities to open an account?
Confusion caused by the ramp
Simple realization of mine sweeping