ReportPage.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:2k
源码类别:
OA系统
开发平台:
C#
- using System;
- namespace OThinker.H3.Portal
- {
- /// <summary>
- /// Summary description for ReportPage.
- /// </summary>
- public class ReportPage : PortalPage
- {
- public ReportPage()
- {
- }
- protected virtual string ReportTableSessionName
- {
- get
- {
- return null;
- }
- }
- protected System.Data.DataTable ReportTable
- {
- get
- {
- return (System.Data.DataTable)this.Session[this.ReportTableSessionName];
- }
- set
- {
- this.Session[this.ReportTableSessionName] = value;
- }
- }
- #region 导出
- protected void Export()
- {
- if(this.ReportTable != null)
- {
- byte[] content = this.Export(this.ReportTable);
- this.Response.ContentType = "application/vnd.ms-excel";
- // 显示内容
- this.Response.BinaryWrite(content);
- this.Response.End();
- }
- }
- public byte[] Export(System.Data.DataTable Table)
- {
- if (Table == null)
- {
- return null;
- }
- System.IO.MemoryStream stream = new System.IO.MemoryStream();
- System.IO.StreamWriter writer = new System.IO.StreamWriter(stream, System.Text.Encoding.Unicode);
- // 设置标题
- for (int columnCount = 0; columnCount < Table.Columns.Count; columnCount++)
- {
- if (columnCount > 0)
- {
- writer.Write("t");
- }
- writer.Write(Table.Columns[columnCount].ColumnName);
- }
- writer.WriteLine();
- // 设置内容
- for (int rowCount = 0; rowCount < Table.Rows.Count; rowCount++)
- {
- for (int columnCount = 0; columnCount < Table.Columns.Count; columnCount++)
- {
- if (columnCount > 0)
- {
- writer.Write("t");
- }
- writer.Write(Table.Rows[rowCount][columnCount].ToString());
- }
- writer.WriteLine();
- }
- writer.Write("