使用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 ...
随机推荐
- Gparted Live分区调整
由于年少无知,在安装ubuntu系统的时候,以为/temp是软件包安装时解压的缓冲,所以给/temp留了10G,而以为/var只是记录一些log而已,因此把仅存的1G分配给了它.随后在安装软件时出现“ ...
- Python基础之列表深浅复制和列表推导式
一.列表深浅复制: 浅拷贝内存图如下: 深拷贝内存图如下: 二.列表推导式: 实例: """ 列表推导式 练习:exercise01 """ ...
- Ehcache 3.7文档—基础篇—JCache aka JSR-107
一. 概述JCache Java临时缓存API(JSR-107),也被称为JCache,它是一个规范在javax.cache.API中定义的.该规范是在Java Community Process下开 ...
- 使用Xilinx UART-LITE IP实现串口--逻辑代码实现
`timescale 1ns / 1ps /////////////////////////////////////////////////////////////////////////////// ...
- css学习_css布局案例
1.中间栏先加载 !!!(若不是这个条件的话 ,那可以用 calc 或者flex布局来实现 中间栏自适应,左右栏定宽) 2.中间栏自适应 width:100% 3.左右栏固定宽 左中右 ...
- VUE错误码Attribute ':sizeOpts' must be hyphenated
Attribute ':sizeOpts' must be hyphenated 因为属性有大写,需要添加 - 来取代 例如 tampData 换成 tamp-data 就可以了
- keras,tensorflow,numpy,jupyter
docker-tensorflow:https://segmentfault.com/a/1190000015053704 pip install scipy pip install keras do ...
- 点击按钮如何改变当前窗口的url
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- opencart分类筛选逻辑修改为并且条件
opencart分类筛选模式默认是或的逻辑,满足条件1或条件2都展现出来,如果想要改成既满足条件1又满足条件2要怎么改呢?有一个插件可以实现,FixFilter OC2x,可以修改默认的筛选条件 1. ...
- Tea for Mac(mac笔记软件)中文版
为大家分享一款好用且免费的mac笔记软件,Tea for Mac提供了实时渲染的Markdown,功能全面,支持各种快捷键,使用tea mac版时,在段首打@即可快速插入图片.标题.列表等元素,非常便 ...