当前位置:网站首页>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
边栏推荐
- An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down
- When the input tag type is number, the input of E, e, -, + is blocked
- Gorm---- Association query
- SSH secret free function for # scripting
- Explication d'un problème de manuel
- Openstack learning notes (II)
- On the realization of guessing numbers game
- Insight into heap and stack stored in new string() /string() in JS
- Stockage des données en mémoire
- go---- mgo
猜你喜欢

Which Chinese virtual human is better? Sullivan, IDC: Xiaobing Baidu Shangtang ranks in the first echelon

用NumPy实现神经网络(Mysteries of Neural Networks Part III)

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

[pit avoidance refers to "difficult"] antd cascader implements new customized functions

An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down

Kubernetes cluster construction of multiple ECS

AGCO AI frontier promotion (6.25)

sql导入这样怎么解决

一次性讲清楚 Handler 可能导致的内存泄漏和解决办法 | 开发者说·DTalk

Knowledge of initial C language 2.0
随机推荐
Solution to Nacos' failure to modify the configuration file mysql8.0
Optimization of lazyagg query rewriting in parsing data warehouse
Cold migration and resize of Nova component source code analysis
An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down
Openstack learning notes -grace component insight
Nova组件源码分析之冷迁移与Resize
À propos du stockage des données en mémoire
Introduction to mongodb chapter 01 introduction to mongodb
一次性讲清楚 Handler 可能导致的内存泄漏和解决办法 | 开发者说·DTalk
1024 hydrology
Syntax 'trap'
Using swiper to realize seamless rotation of multiple slides
数据采集系统网关采集工厂效率
Is it safe for Guosen Securities to open an account?
Restful and RPC
[pit avoidance refers to "difficult"] halfcheckedkeys rendering problem in semi selected status of antd tree
There is a problem with the date when MySQL imports and exports data to excel
字符串各操作函数与内存函数详解
. NET in China - What's New in . NET
QT mouse tracking