当前位置:网站首页>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
边栏推荐
- [proteus simulation] 51 MCU +ds1302+lcd1602 display
- Parabolic motion in unity 2D games
- 初始c语言时的一些知识
- Websocket -- reverse proxy to solve cross domain problems
- 楼宇自动化专用BACnet网关BL103
- How to solve SQL import
- Prototype and prototype chain - constructor and instanceof
- Cesium model Daquan glb/glft format
- Is it safe for Guosen Securities to open an account?
- [pit avoidance refers to "difficult"] halfcheckedkeys rendering problem in semi selected status of antd tree
猜你喜欢

论文阅读:Graph Contrastive Learning with Augmentations

楼宇自动化专用BACnet网关BL103

关于一道教材题的讲解

On the simple realization of Sanzi chess game and the method of judging the victory of n-zi chess

golang键盘输入语句scanln scanf代码示例

Introduction to mongodb chapter 01 introduction to mongodb

How to solve SQL import

多台云服务器的 Kubernetes 集群搭建

關於一道教材題的講解

数据在内存中的存储相关内容
随机推荐
Always maintain epidemic prevention and control and create a safe and stable social environment
QT display ffmpeg decoded pictures
Drago Education - typescript learning
Implementation of a small book system
Is it safe to open an account with tongdaxin stock?
Some knowledge of the initial C language
关于一道教材题的讲解
Openstack learning notes (I)
Regular match the phone number and replace the fourth to seventh digits of the phone number with****
C# 切换中英文输入法
Stockage des données en mémoire
Leetcode: Sword finger offer II 091 Painting house [2D DP]
Kubernetes cluster construction of multiple ECS
Rust, le meilleur choix pour un programmeur de démarrer une entreprise?
Using swiper to realize seamless rotation of multiple slides
leetcode:918. 环形子数组的最大和【逆向思维 + 最大子数组和】
BACnet gateway bl103 for building automation
Uncover gaussdb (for redis): comprehensive comparison of CODIS
戴尔电脑cpu温度过高怎么办
OpenStack学习笔记(二)