当前位置:网站首页>Asp.net WebForm使用NPOI导出Excel
Asp.net WebForm使用NPOI导出Excel
2022-06-25 13:16:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
废话不多说,直接上代码
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);
//输出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();
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151689.html原文链接:https://javaforall.cn
边栏推荐
- 一次性讲清楚 Handler 可能导致的内存泄漏和解决办法 | 开发者说·DTalk
- 关于一个图书小系统的实现
- 关于三子棋游戏的简易实现与N子棋胜利判断方法
- Some knowledge of the initial C language
- 初始c语言时的一些知识
- [proteus simulation] 51 MCU +ds1302+lcd1602 display
- Deep parsing and implementation of redis stream advanced message queue [10000 words]
- Openstack learning notes (II)
- Cesium learning notes
- Cold migration and resize of Nova component source code analysis
猜你喜欢
Prototype and prototype chain - constructor and instanceof
网络远程访问的方式使用树莓派
Graph contractual learning with augmentations
删库跑路、“投毒”、改协议,开源有哪几大红线千万不能踩?
The priority of catch() and then (..., ERR) of promise
解决报错:Creating window glfw ERROR: GLEW initalization error: Missing GL version
[data visualization] antv L7 realizes map visualization, drilldownlayer drill asynchronously obtains data, and suspends the warning box
There is a problem with the date when MySQL imports and exports data to excel
Kubernetes cluster construction of multiple ECS
Simple realization of mine sweeping
随机推荐
NVM installation and use tutorial
Syntax 'trap'
Where can the brightness of win7 display screen be adjusted
Insight into heap and stack stored in new string() /string() in JS
Custom vertical table
QT mouse tracking
字符串各操作函数与内存函数详解
KVM script management - the road to dream
Explanation of a textbook question
The starting point for learning programming.
Nr-arfcn and channel grid, synchronous grid and GSCN
Gorm-- search you don't know
Cesium learning notes
1251- client does not support authentication protocol MySQL error resolution
OpenStack学习笔记(二)
Leetcode: Sword finger offer II 091 Painting house [2D DP]
“移动云杯”算力网络应用创新大赛火热报名中!
Stockage des données en mémoire
一次性讲清楚 Handler 可能导致的内存泄漏和解决办法 | 开发者说·DTalk
Using swiper to realize seamless rotation of multiple slides