高手赐教报表问题!
目前在做一个预算系统,需要生成一大堆的报表,刚注册进来,不知道怎么插图片,没办法看到更直观的效果,我描述一下吧,报表列固定,但是行需要从数据库中动态读取,并且有的列是通过计算得到的,总共有多少行,是根据数据库记录动态增加的。里面类似的报表有好几张,并且每张都是成百上千行,而且还想导出成Excel,请问高手这种动态生成的报表用什么方式比较好实现?我刚注册,没分啊,这个问题困扰我好几天了,高手们同情我一下啊.
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Microsoft.Office.Interop.Excel; using System.Reflection; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Excel.Application exc; Workbooks workbooks; Sheets sheets = null; _Workbook workbook; exc = new Microsoft.Office.Interop.Excel.Application(); workbooks = exc.Workbooks; try { exc.Visible = false; exc.DisplayAlerts = false; exc.Interactive = false; DateTime beforeTime = DateTime.Now; string modePath = @"e:\a.xls"; string outputPath = @"e:\b.xls"; workbook = exc.Workbooks.Open(modePath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); sheets = workbook.Worksheets; _Worksheet worksheet = (_Worksheet)sheets[1]; worksheet.Activate(); Microsoft.Office.Interop.Excel.Range m_objRange = ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[12,Missing.Value]); //m_objRange.ColumnWidth = 1; m_objRange.EntireColumn.Delete(Microsoft.Office.Interop.Excel.XlDirection.xlToLeft); workbook.SaveAs(outputPath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, null, null, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, null, null, null, null, null); workbook.Saved = true; Response.Write("OK"); } catch (Exception exp) { Response.Write(exp.ToString()); } finally { //关闭和excel相关的东西 workbooks.Close(); exc.Quit(); workbooks = null; workbook = null; exc = null; } } }