当前位置:网站首页>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
边栏推荐
- Is it safe to open an account with tongdaxin stock?
- 關於數據在內存中的存儲下
- The priority of catch() and then (..., ERR) of promise
- Gorm-- search you don't know
- How to configure aliases for typescript + vite projects
- 多臺雲服務器的 Kubernetes 集群搭建
- OpenStack学习笔记-Glance组件深入了解
- Explain the possible memory leaks caused by the handler at one time and the solutions | the developer said · dtalk
- 多台云服务器的 Kubernetes 集群搭建
- Qt内存映射
猜你喜欢

删库跑路、“投毒”、改协议,开源有哪几大红线千万不能踩?

On the realization of guessing numbers game

What if the CPU temperature of Dell computer is too high

初始c语言的知识2.0

Rust, the best choice for programmers to start a business?

Knowledge of initial C language 2.0
![Leetcode: Sword finger offer II 091 Painting house [2D DP]](/img/d7/dc8a3522dbd58b4573cfd75497460c.png)
Leetcode: Sword finger offer II 091 Painting house [2D DP]

Stockage des données en mémoire

Gorm---- Association query

Some knowledge of the initial C language
随机推荐
[pit avoidance means "difficult"] actionref current. Reload() does not take effect
Use of bind() in JS and handwritten bind()
BACnet gateway bl103 for building automation
On the simple realization of Sanzi chess game and the method of judging the victory of n-zi chess
Numpy库使用入门
[data visualization] antv L7 realizes map visualization, drilldownlayer drill asynchronously obtains data, and suspends the warning box
Network remote access using raspberry pie
Storage related contents of data in memory
When the input tag type is number, the input of E, e, -, + is blocked
[pit avoidance means "difficult"] to realize editable drag and drop sorting of protable
Win7显示屏幕亮度在哪里可以调节
Websocket -- reverse proxy to solve cross domain problems
Kubernetes cluster construction of multiple ECS
Syntax 'trap'
Golang keyboard input statement scanln scanf code example
解决报错:Creating window glfw ERROR: GLEW initalization error: Missing GL version
[pit avoidance refers to "difficult"] halfcheckedkeys rendering problem in semi selected status of antd tree
turtlebot+lms111+gmapping实践
About data storage in memory
Class usage and inheritance in ES6