当前位置:网站首页>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
边栏推荐
- Prototype relationship between constructor and instance (1)
- 1024 hydrology
- 初始c语言时的一些知识
- QT display ffmpeg decoded pictures
- leetcode:456. 132 mode [monotone stack]
- 一次性讲清楚 Handler 可能导致的内存泄漏和解决办法 | 开发者说·DTalk
- Storage related contents of data in memory
- Use of bind() in JS and handwritten bind()
- 數據在內存中的存儲相關內容
- There is a problem with the date when MySQL imports and exports data to excel
猜你喜欢

Django framework - caching, signaling, cross site request forgery, cross domain issues, cookie session token

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

Implementation of a small book system

Scope of ES6 variable

Discuz仿今日头条模板/Discuz新闻资讯商业版GBK模板

关于数据在内存中存储的相关例题

[pit avoidance means "difficult"] to realize editable drag and drop sorting of protable

关于猜数字游戏的实现

历史上的今天:网易成立;首届消费电子展召开;世界上第一次网络直播

Shenzhen mintai'an intelligent second side_ The first offer of autumn recruitment
随机推荐
go---- mgo
Untiy force refresh UI
[proteus simulation] 51 MCU +ds1302+lcd1602 display
QT mouse tracking
How to solve SQL import
Is it safe for Guosen Securities to open a stock account? Excuse me?
Nova中的api
Error1822 and error1824 are displayed in the database
Shenzhen mintai'an intelligent second side_ The first offer of autumn recruitment
Discuz仿今日头条模板/Discuz新闻资讯商业版GBK模板
语法'陷阱'
.NET in China - What's New in .NET
学习编程的起点。
On the realization of guessing numbers game
Solution to Nacos' failure to modify the configuration file mysql8.0
Knowledge of initial C language 2.0
Django framework - caching, signaling, cross site request forgery, cross domain issues, cookie session token
À propos du stockage des données en mémoire
An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down
leetcode:剑指 Offer II 091. 粉刷房子【二维dp】