使用aspx 直接生成excel
<%@ Page Language="C#" EnableEventValidation="false" ResponseEncoding="gb2312" ContentType="application/vnd.ms-excel" %> <%@ Import Namespace="IriskingAttend.Web" %>
<%@ Import Namespace="System" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=gb2312">
<meta name="ProgId" content="Excel.Sheet">
<meta name="Generator" content="Microsoft Excel 11">
</head>
<body>
<%
Response.ContentType = "application/vnd.ms-excel"; Response.Charset = "utf-8"; Response.AddHeader("Content-Disposition", "inline; filename=" + "luanma.xls");
Response.Write("<meta http-equiv=Content-Type content=text/html;charset=utf-8>");
%>
<div>
<table x:str border="1" cellpadding="0" cellspacing="0" style='border-collapse: collapse;
text-align: center; table-layout: fixed; width: 1000pt; height: 102px;'>
<%
DateTime beginTime = Convert.ToDateTime(Request.QueryString["beginTime"]);
DateTime endTime = Convert.ToDateTime(Request.QueryString["endTime"]);
string departName = Request.QueryString["departName"];
int length = (int)endTime.AddDays(1).Subtract(beginTime).TotalDays;
%>
<tr>
<td colspan="<%=(length+15) %>" rowspan="2" align="center">
郭二庄月出勤明细报表 <span style='mso-spacerun: yes'> </span>
<%=beginTime.ToString("yyyy-MM-dd")%>
至
<%=endTime.ToString("yyyy-MM-dd")%> <span>部门:<%=departName %></span>
</td>
</tr>
<tr> </tr>
<tr>
<td rowspan="2" align="center">
姓名
</td>
<td rowspan="2" align="center">
考勤号
</td>
<td rowspan="2" align="center">
工数
</td>
<td colspan="2" class="style2" align="center">
其中
</td>
<% for (DateTime mindate = beginTime; mindate <= endTime; mindate = mindate.AddDays(1))
{ %>
<td rowspan="2" class="style1" align="center">
<%=mindate.Day.ToString("d2")%>
</td>
<% } %>
<td colspan="3" class="style1" align="center">
对比数据
</td>
<td colspan="2" class="style2" align="center">
对比后
</td>
<td colspan="2" class="style2" align="center">
有工数
</td>
<td rowspan="2" class="style2" align="center">
有工数
</td>
<td colspan="2" class="style2" align="center">
其中:夜班
</td>
</tr>
<tr>
<td rowspan="1" align="center">
工数
</td>
<td rowspan="1" align="center">
工数
</td>
<td rowspan="1" align="center">
工数
</td>
<td rowspan="1" align="center">
异常
</td>
<td colspan="1" align="center">
异常
</td>
<td rowspan="1" align="center">
工数
</td>
<td rowspan="1" align="center">
工数
</td>
<td rowspan="1" align="center">
有资
</td>
<td colspan="1" align="center">
有资
</td>
<td rowspan="1" align="center">
井上工数
</td>
<td rowspan="1" align="center">
井下工数
</td>
</tr>
<%
for (int i = 0; i < DomainServiceIriskingAttend._monthAttendList.Count; i++)
{%>
<tr height="19" style='height: 14.25pt'>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].PersonName%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].AttendSn%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].WorkConut%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].WorkCount%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].WorkCount%>
</td>
<% for (int j = 0; j < length; j++)
{ %>
<td>
<%= DomainServiceIriskingAttend._monthAttendList[i].DailySign[j]??"" %>
</td>
<% } %>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].NormalWorkCount%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].Exception%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].LocationException%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].AfterOn%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].AfterIn%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].YouZi%>
</td>
<td>
<%=DomainServiceIriskingAttend._monthAttendList[i].YouZi%>
</td>
<td class="style2">
<%=DomainServiceIriskingAttend._monthAttendList[i].WorkCountable%>
</td>
<td class="style1">
<%=DomainServiceIriskingAttend._monthAttendList[i].NightOn%>
</td>
<td class="style1">
<%=DomainServiceIriskingAttend._monthAttendList[i].NightIn%>
</td>
</tr>
<%}%>
</table>
</div>
</body>
</html>
//使用contentType 直接将输出格式改成application/vnd.ms-xls, 页面导向到这里直接下载。比较菜也是相对简单的一种方法
//在IE下 中文文件名乱码问题解决
string filename = "中文名称乱码.xls";
// IE浏览器乱码问题,只能采用URLEncoder编码
filename = HttpUtility.UrlEncode(filename, Encoding.UTF8);
Response.ContentType = "application/vnd.ms-excel"; Response.Charset = "utf-8"; Response.AddHeader("Content-Disposition", "inline; filename=" + filename);
使用aspx 直接生成excel的更多相关文章
- asp.net 生成 excel导出保存时, 解决迅雷下载aspx页面问题
网络上搜索,一大堆废话,以下为简单的导出生成Excel代码: string excelFile = Server.MapPath("~/SB/UpFile/20151104111008/Bo ...
- Asp.net MVC 简单实现生成Excel并下载
由于项目上的需求,需要导出指定条件的Excel文件.经过一翻折腾终于实现了. 现在把代码贴出来分享 (直接把我们项目里面的一部份辅助类的代码分享一下) 我们项目使用的是Asp.Net MVC4.0模式 ...
- 两种方式实现java生成Excel
Web应用中难免会遇到需要将数据导出并生成excel文件的需求.同样,对于本博客中的总结,也是建立在为了完成这样的一个需求,才开始去了解其实现形式,并且顺利完成需求的开发,先将实现过程总结于此.本博文 ...
- 使用node.js生成excel报表下载(excel-export express篇)
引言:日常工作中已经有许多应用功能块使用了nodejs作为web服务器,而生成报表下载也是我们在传统应用. java中提供了2套类库实现(jxl 和POI),.NET 作为微软的亲儿子更加不用说,各种 ...
- Python实战 :2017国考职业表excel转数据库,再查询生成excel
最近看2017年国考的职业表,多而杂,不好过滤我想要的信息,特此把它转成Sqlite3数据库,再从数据库里把查询结果导出成excel,方便找职业. (后附上整套代码) 环境:python2.7 x ...
- asp.net+nopi生成Excel遇到设置单元格值null问题
Npoi 生成excel报表功能很不错,功能也不用给大家介绍了.首先看遇到的问题吧! FileStream file = new FileStream(Server.MapPath("Tem ...
- phpexcel生成excel并下载
Loader::import('PHPExcel.Classes.PHPExcel'); // tp5中只需将phpexcel文件放入extend文件夹中,即可采用该方法引入,需要先 use thin ...
- java动态生成excel打包下载
@SuppressWarnings("unchecked") public String batchExport() throws DBException{ @SuppressWa ...
- JAVA利用JXL导出/生成 EXCEL
/** * 导出导出采暖市场部收入.成本.利润明细表 * @author JIA-G-Y */ public String exporExcel(String str) { String str=Se ...
随机推荐
- Dev TreeList 添加节点图标问题
1. 在设计界面添加imageCollection控件,在属性页设置图标(可Load from disk,也可从Load from dev gallery) 2. TreeList控件有一个叫做Cus ...
- TCP三次握手四次挥手最通俗理解
工作过程TCP标志位:TCP共有6个标志位,分别是: SYN(synchronous),建立联机.ACK(acknowledgement),确认.PSH(push),传输.FIN(finish),结束 ...
- swust oj 971
统计利用先序遍历创建的二叉树的深度 10000(ms) 10000(kb) 3331 / 8436 利用先序递归遍历算法创建二叉树并计算该二叉树的深度.先序递归遍历建立二叉树的方法为:按照先序递归遍历 ...
- andorid简易定位
权限: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></use ...
- 用ImageJ快速分析和处理图像
ImageJ是一款由美国国立卫生研究院(NIH)开发的软件,原名NIH Image,适用于McIntosh.Windows和Linux等系统.ImageJ旨在对图像进行更好的分析和处理,可以下载或在线 ...
- Spring Boot2.1.3全局跨域
/** * 配置跨域访问 * * @author Terwer */ @Bean public WebMvcConfigurer corsConfigurer() { return new WebMv ...
- 来自一个电子狂的stm32学习历程
文章尾部有学习时的一些视频资料在学的可以看看那么我们就进入今天的主题我stm32的学习历程 在学习了51单片机之后,早已经对单片机这个东西甚有了解了,所有不管是从内部资源,还是一些常见应用,都可以说的 ...
- Git branch && Git checkout常见用法
https://www.cnblogs.com/qianqiannian/p/6011404.html git branch 和 git checkout经常在一起使用,所以在此将它们合在一起 1.G ...
- Typora极简教程
Typora极简教程 ” Markdown 是一种轻量级标记语言,创始人是约翰·格鲁伯(John Gruber).它允许人们 “使用易读易写的纯文本格式编写文档,然后转换成有效的 HTML 文档.” ...
- extundelete数据恢复
需要安装的依赖包: 1. e2fsprogs软件包已安装2. e2fsprogs-libs软件包已安装3. e2fsprogs-devel软件包已安装4. gcc软件包已安装5. gcc-c++ 软件 ...