asp.net将内容导出到Excel,Table表格数据(html)导出EXCEL
代码:
/// <summary>
/// HTML Table表格数据(html)导出EXCEL
/// </summary>
/// <param name="tableHeader">表头</param>
/// <param name="tableContent">内容</param>
/// <param name="sheetName">文件名称</param>
public void ExportToExcel(string tableHeader,string tableContent,string sheetName)
{
string fileName = sheetName + DateTime.Now.ToString("yyyyMMddHHmmss");
string tabData = htmlTable;
if (tabData != null)
{
StringWriter sw = new System.IO.StringWriter();
sw.WriteLine("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><body>");
sw.WriteLine("<table>");
sw.WriteLine("<tr style=\"background-color: #e4ecf7; text-align: center; font-weight: bold\">");
sw.WriteLine(tableHeader);
sw.WriteLine("</tr>");
sw.WriteLine(tableContent);
sw.WriteLine("</table>");
sw.WriteLine("</body>");
sw.WriteLine("</html>");
sw.Close();
Response.Clear();
Response.Buffer = true;
Response.Charset = "UTF-8";
//Response.Charset = "GB2312";
//this.EnableViewState = false;
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls");
Response.ContentType = "application/ms-excel";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.Write(sw);
Response.End();
}
}
asp.net将内容导出到Excel,Table表格数据(html)导出EXCEL的更多相关文章
- poi 操作Excel 以及大数据量导出
maven 依赖 (版本必须一致,否则使用SXSSFworkbook 时程序会报错) <dependency> <groupId>org.apache.poi</grou ...
- excel表格数据导入导出
/** * 导出数据到excel表格 * Created by shenjianhua on 2018-12-28 */ package com.luer.comm.excel; import jav ...
- java中 Excel表实现数据导入导出
需要引入依赖: <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <dependency> < ...
- 干货--Excel的表格数据的一般处理和常用python模块。
写在前面: 本文章的主要目的在于: 介绍了python常用的Excel处理模块:xlwt,xlrd,xllutils,openpyxl,pywin32的使用和应用场景. 本文只针对于Excel表中常用 ...
- excel的表格数据插入到数据库
看到有excel保存insert的数据,自己照着教程弄了一下,可以的. 表格数据 接下来我们在d3的位置输入 =CONCATENATE("insert into user(code, nam ...
- oracle SQL Develop导出数据库中的表格数据到excel
首先打开oracle数据库 1.查询数据库, SELECT * FROM pub_attribute WHERE ELEMENT_CODE='bb382e10d7ce437b8a8c980ba20ac ...
- NPOI 通过excel模板写入数据并导出
private void ToExcel(string id) { //模板文件 string TempletFileName = Server.MapPath("template.xls& ...
- JAVAWEB导出word文档,遍历表格数据,导出图片
这是写的另一个导出word方法:https://www.cnblogs.com/pxblog/p/12790904.html 本次使用的是easypoi框架 官方教程:https://opensour ...
- 从html页面中抽取table表格数据
/** * [getDataFromTrElems 获取表格行元素数据] * @param {[Object]} trElems [trs dom] * @param {[String]} type ...
随机推荐
- 前端---HTML
HTML基础 本章内容: 简介 HTML定义 标签定义和属性 HTML5基本结构 HTML5字符集 <head>标签 <title> <base/> <lin ...
- 第一章 Mybtais的两种启动方式
Mybatis的两种启动方式如下: 1.xml实现: xml的实现方式中,主要是通过手动创建SqlSession,然后调用session.selectOne()方法实现来实现. 首先是创建Config ...
- lsslot
lsslot 命令 用途 显示动态可重新配置的插槽(比如热插拔)及其特性. 语法 lsslot -c ConnectorType [ -a | -o | -l DeviceName | -s Slot ...
- jquery上传图片插件plupload
官方网站:http://plupload.com/ jquery.plupload.queue插件,是上传图片组件很强大的插件.plupload 前端根据浏览器不同选择使用Html5. Gears, ...
- 反射中通过class标记来获取字段及方法
//这是通过class标记获取字段的代码 Field[] fields= classzz.getDeclaredFields(); //获取该class标记的表名代码,必须为,getSimpleNam ...
- Frogger
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...
- html5 上传图片.net实现
jQuery插件之ajaxFileUpload 搞了一夜,还没弄出来随copy了一篇博客... 一.ajaxFileUpload是一个异步上传文件的jQuery插件. 传一个不知道什么版本的上来, ...
- 用函数datepart获取当前日期、周数、季度
用函数datepart处理就可以了,示例:select datepart(weekday,getdate()) as 周内的第几日select datepart(week,getdate()) as ...
- Android性能优化方法(七)
Java从JDK1.2版本开始,就把对象的引用分为四种级别,从而使程序能更加灵活的控制对象的生命周期.这四种级别由高到低依次为:强引用.软引用.弱引用和虚引用. 这里重点介绍一下软引用和弱引用. 如果 ...
- Setting SVN Repository Using TortoiseSVN + Dropbox in 5 Minutes
SVN is a very common version control system in software development. However configuring SVN server ...