导出带有模板的repeator
来源:互联网 发布:单片机节日彩灯设计 编辑:程序博客网 时间:2024/04/28 11:40
#region 创建单元格
private HtmlTableCell CreatCell(string innertext)
{
return this.CreatCell(1,innertext);
}
private HtmlTableCell CreatCell(int type,string innertext)
{
return this.CreatCell(type,0,0,innertext);
}
private HtmlTableCell CreatCell(int type,int colspan,string innertext)
{
return this.CreatCell(type,0,colspan,innertext);
}
private HtmlTableCell CreatCell(int type,int rowspan,int colspan,string innertext)
{
HtmlTableCell htc;
htc=new HtmlTableCell();
htc.ColSpan=colspan;
htc.RowSpan=rowspan;
htc.InnerText=innertext;
if(type==0)//表头
{
htc.Style.Add("color","#CCCCFF");
htc.Style.Add("FONT-WEIGHT","true");
htc.BgColor="#003399";
}
return htc;
}
#endregion
#region 获取表
private HtmlTable GetHtmlTableFromRepeater(Repeater rp)
{
/*<tr style="FONT-WEIGHT: bold; COLOR: #ccccff; BACKGROUND-COLOR: #003399">
<td rowspan="3">地区</td>
<td rowspan="3">月份</td>
<td rowspan="3">工号</td>
<td rowspan="3">人员归属</td>
<td rowspan="3">营销模式</td>
<td rowspan="3">新增用户数</td>
<td colspan="6">客户评测系统监控情况</td>
<td colspan="2">其他方式监控情况</td>
<td colspan="2">合计违规情况</td>
<td colspan="12">扣罚结果</td>
<tr style="FONT-WEIGHT: bold; COLOR: #ccccff; BACKGROUND-COLOR: #003399">
<td rowspan="2">准确度80%以上单数</td>
<td rowspan="2">比例</td>
<td rowspan="2">准确度40%-80%单数</td>
<td rowspan="2">比例</td>
<td rowspan="2">合计监控单数</td>
<td rowspan="2">比例</td>
<td rowspan="2">违规单数</td>
<td rowspan="2">比例</td>
<td rowspan="2">合计违规单数</td>
<td rowspan="2">比例</td>
<td colspan="4">客户评测系统</td>
<td colspan="4">其他监控模式</td>
<td colspan="4">合计情况</td>
</tr>
<tr style="FONT-WEIGHT: bold; COLOR: #ccccff; BACKGROUND-COLOR: #003399">
<td>涉及人数</td>
<td>辞退人数</td>
<td>取消佣金(提成)单数</td>
<td>扣罚总金额</td>
<td>涉及人数</td>
<td>辞退人数</td>
<td>取消佣金(提成)单数</td>
<td>扣罚总金额</td>
<td>涉及人数</td>
<td>辞退人数</td>
<td>取消佣金(提成)单数</td>
<td>扣罚总金额</td>
</tr>*/
System.Web.UI.HtmlControls.HtmlTable htable=new HtmlTable();
htable.Border=1;
htable.BorderColor="#3366CC";
htable.CellPadding=1;
htable.CellSpacing=0;
HtmlTableRow htr;
htr=new HtmlTableRow();
htr.Align="center";
htr.Cells.Add(this.CreatCell(0,3,0,"地区"));
htr.Cells.Add(this.CreatCell(0,3,0,"月份"));
htr.Cells.Add(this.CreatCell(0,3,0,"工号"));
htr.Cells.Add(this.CreatCell(0,3,0,"人员归属"));
htr.Cells.Add(this.CreatCell(0,3,0,"营销模式"));
htr.Cells.Add(this.CreatCell(0,3,0,"新增用户数"));
htr.Cells.Add(this.CreatCell(0,6,"客户评测系统监控情况"));
htr.Cells.Add(this.CreatCell(0,2,"其他方式监控情况"));
htr.Cells.Add(this.CreatCell(0,2,"合计违规情况"));
htr.Cells.Add(this.CreatCell(0,12,"扣罚结果"));
htable.Rows.Add(htr);
htr=new HtmlTableRow();
htr.Align="center";
htr.Cells.Add(this.CreatCell(0,2,0,"准确度80%以上单数"));
htr.Cells.Add(this.CreatCell(0,2,0,"比例"));
htr.Cells.Add(this.CreatCell(0,2,0,"准确度40%-80%单数"));
htr.Cells.Add(this.CreatCell(0,2,0,"比例"));
htr.Cells.Add(this.CreatCell(0,2,0,"合计监控单数"));
htr.Cells.Add(this.CreatCell(0,2,0,"比例"));
htr.Cells.Add(this.CreatCell(0,2,0,"违规单数"));
htr.Cells.Add(this.CreatCell(0,2,0,"比例"));
htr.Cells.Add(this.CreatCell(0,2,0,"合计违规单数"));
htr.Cells.Add(this.CreatCell(0,2,0,"比例"));
htr.Cells.Add(this.CreatCell(0,4,"客户评测系统"));
htr.Cells.Add(this.CreatCell(0,4,"其他监控模式"));
htr.Cells.Add(this.CreatCell(0,4,"合计情况"));
htable.Rows.Add(htr);
htr=new HtmlTableRow();
htr.Align="center";
htr.Cells.Add(this.CreatCell(0,"涉及人数"));
htr.Cells.Add(this.CreatCell(0,"辞退人数"));
htr.Cells.Add(this.CreatCell(0,"取消佣金(提成)单数"));
htr.Cells.Add(this.CreatCell(0,"扣罚总金额"));
htr.Cells.Add(this.CreatCell(0,"涉及人数"));
htr.Cells.Add(this.CreatCell(0,"辞退人数"));
htr.Cells.Add(this.CreatCell(0,"取消佣金(提成)单数"));
htr.Cells.Add(this.CreatCell(0,"扣罚总金额"));
htr.Cells.Add(this.CreatCell(0,"涉及人数"));
htr.Cells.Add(this.CreatCell(0,"辞退人数"));
htr.Cells.Add(this.CreatCell(0,"取消佣金(提成)单数"));
htr.Cells.Add(this.CreatCell(0,"扣罚总金额"));
htable.Rows.Add(htr);
System.Web.UI.WebControls.Label lbTemp=new Label();
LinkButton lbtnTemp=new LinkButton();
foreach(RepeaterItem item in rp.Items)
{
htr=new HtmlTableRow();
htr.Align="center";
foreach(Control ctr in item.Controls)
{
if(ctr is Label)
{
lbTemp=(System.Web.UI.WebControls.Label)ctr;
htr.Cells.Add(this.CreatCell(lbTemp.Text));
}
else if(ctr is LinkButton)
{
//string name=ctr.GetType().ToString();
lbtnTemp=(LinkButton)ctr;
htr.Cells.Add(this.CreatCell(lbtnTemp.Text));
}
}
htable.Rows.Add(htr);
}
return htable;
}
#endregion
#region 从HtmlTable导出
public static void ExpReport(string reportname,System.Web.UI.HtmlControls.HtmlTable ht,Encoding content,Encoding filename)
{
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Buffer=true;//缓冲输出
System.Web.HttpContext.Current.Response.ContentType="application/vnd.ms_excel";//输出流的HTTP MIME类型
System.Web.HttpContext.Current.Response.ContentEncoding=content;//输出流的HTTP字符集
System.IO.StringWriter oStringWriter=new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter=new HtmlTextWriter(oStringWriter);//在WEB窗体写出一系列连续的HTML特定字符和文本
ht.RenderControl(oHtmlTextWriter);//将DataGridPMG控件的内容输出到oHtmlTextWriter对象中
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+System.Web.HttpUtility.UrlEncode(reportname,filename)+".xls"); //将HTTP头添加到输出流
System.Web.HttpContext.Current.Response.Write(oStringWriter.ToString());//向HTTP输出内容流写入一个字符数组
System.Web.HttpContext.Current.Response.Flush();//向客户端发送当前所有缓冲的输出
System.Web.HttpContext.Current.Response.End();//将当前所有缓冲的输出发送到客户端,并停止该页的执行
}
#endregion
- 导出带有模板的repeator
- excel导出模板带有下拉的模板
- Eclipse导出带有keystore的APK
- Sublime 导出带有颜色的代码
- 导出的Excel带有下拉框
- 带有模板参数的函数指针
- 带有两个通用类型的模板
- AndroidStudio创建带有toolbar的模板
- 比较GridView,DataList,Repeator ,DetailsView,FormView 的区别
- 比较GridView,DataList,Repeator ,DetailsView,FormView 的区别
- 我的导出模板
- java使用freemarker模板导出word(带有合并单元格)文档
- LWUIT使用带有混淆器导出时的注意事项
- LWUIT使用带有混淆器导出时的注意事项
- 使用eclipse导出带有完整目录的文件
- 去掉powerdesigner 导出sql中带有的双引号
- linux编写带有导出函数的so文件
- 将带有checkbox的Datagrid直接导出到exec
- 网页乱码问题ASP.NET
- 三层架构各层关系分析比较及其约定
- 我的蓝色之路有多远?
- 零碎的记录
- 关于进行Asp.net窗体验证的过程说明
- 导出带有模板的repeator
- ASP.NET页面提前处理问题
- Javascript的IE和Firefox兼容性汇编
- ASP.NET运行机制和图片盗链问题
- 读书笔记一则
- Java正则表达式
- Universal Share Downloader v 1.3.4 Beta 3
- 一个封装的QQ面板控件(HTC)
- 客户端拖动控件封装(让拖动变得更简单)