ASP.NET报表问题的解决方法
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,ASP.NET报表问题的解决方法,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。做ASP.NET项目都会碰到ASP.NET报表问题,中国式
千家信息网最后更新 2025年11月07日ASP.NET报表问题的解决方法
ASP.NET报表问题的解决方法,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
做ASP.NET项目都会碰到ASP.NET报表问题,中国式报表的繁琐让我很是反感,可没法子啊,客户有需求!自然而然想用DCOM直接操作EXCEL,马马虎虎算是成了,虽说安全性不好,资源浪费严重,毕竟在局域网中使用,凑合吧。
不过总是讨厌在服务端那个没有结束的EXCEL进程……一定要把敌人杀死!google了一把,原来当今中外都有这个ASP.NET报表问题。解决方案也有,Windows XP下搞定,但我在WINDOWS 2003下搞了整整一天也没杀死,得,真想自个杀了。后来有人推荐了个控件ASPOSE解决ASP.NET报表问题,这玩意强,服务端都不用装EXCEL,效果不错!想偷懒的用这玩意,一个字--爽!
private string subTotal(int row ,int num) { string r = (row+1).ToString(); if( num == 0)// { return "=C"+r+"+F"+r+"-I"+r; } else return "=E"+r+"+H"+r+"-K"+r; } private string sumTotal(string scol,int firstrow,int num){ string r = num.ToString(); string fr = firstrow.ToString(); return "=Sum("+scol+fr+":"+scol+r+")"; } private void CreateExcelWorkbook(DataRow[] rows) { string strCurrentDir = Server.MapPath("..") + "\\TempReports\\"; string licenseFile = MapPath("..") + "\\XML\\Aspose.Excel.lic"; Excel excel = new Excel(licenseFile, this); ; string designerFile = strCurrentDir+"cangku2.xls"; excel.Open(designerFile); Worksheet sheet = excel.Worksheets["Sheet1"]; sheet.Name = "wuzi"; Cells cells = sheet.Cells; int styleIndex; styleIndex = excel.Styles.Add(); Aspose.Excel.Style stylecell = excel.Styles[styleIndex]; stylecell.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin; stylecell.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin; stylecell.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin; stylecell.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin; int iRow =4; foreach(DataRow row in rows) { cells[iRow,0].PutValue(row[0].ToString()); cells[iRow,1].PutValue(row[1].ToString()); cells[iRow,2].PutValue(row[2]); cells[iRow,3].PutValue( row[3]); cells[iRow,4].PutValue(row[4]); cells[iRow,5].PutValue(row[5]); cells[iRow,6].PutValue(row[3]); cells[iRow,7].PutValue(row[6]); cells[iRow,8].PutValue(row[7]); cells[iRow,9].PutValue(row[3]); cells[iRow,10].PutValue(row[8]); cells[iRow,11].Formula=subTotal(iRow,0); cells[iRow,12].PutValue(row[3]); cells[iRow,13].Formula=subTotal(iRow,1); iRow++; } string zj="总计"; cells[iRow,3].PutValue(zj); cells[iRow,6].PutValue(zj); cells[iRow,9].PutValue(zj); cells[iRow,12].PutValue(zj); cells[iRow,4].Formula=sumTotal("E",5,iRow); cells[iRow,7].Formula=sumTotal("H",5,iRow); cells[iRow,10].Formula=sumTotal("K",5,iRow); cells[iRow,13].Formula=sumTotal("N",5,iRow); cells[1,8].PutValue(cpStartDate.SelectedDate.ToShortDateString()); cells[1,12].PutValue(cpEndDate.SelectedDate.ToShortDateString()); Range range = cells.CreateRange(4,0,iRow-4+1,14); range.Style = stylecell; for(int i = 0; i < excel.Worksheets.Count ; i ++) { sheet = excel.Worksheets[i]; if(sheet.Name != "wuzi") { excel.Worksheets.RemoveAt(i); i --; } } /*Response.Clear(); Response.Buffer= true; Response.Charset="GB2312"; this.Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");*/ excel.Save(HttpUtility.UrlEncode("物资进出库汇总.xls",Encoding.UTF8), SaveType.OpenInBrowser,FileFormatType.Default,this.Response); }看完上述内容,你们掌握ASP.NET报表问题的解决方法的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!
问题
报表
方法
内容
更多
玩意
服务
不错
安全
繁琐
束手无策
自然而然
为此
不好
不用
中国式
原因
安全性
客户
对此
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
山西通用软件开发性价比
新沃云网络安全
select连接数据库
下拉列表怎么加入数据库
数据库中关系图的交并差
长宁区无线网络技术费用
有意思的我的世界服务器
数据库导数据到hdfs的命令
app端如何调用数据库
在网络安全模式下如何打开qq
杭州棋牌软件开发培训
闲来麻将软件开发公司
网络安全政府单位最基本要求
订做存储服务器机箱多少钱
数据库vba代码大全
舞台特效主板硬件设计 软件开发
零基础学网络安全视屏教学哪里有
银行的数据库是什么类型
英国石油公司数据库官网
数据库著作
参观济南博赛网络技术公司
数据库表设计介绍
java数据库高阶面试题
网络安全培训基地二期
用电脑当服务器的图
武汉的软件开发
海南逸鑫网络技术有限公司地址
健康系统显示服务器错误
拌合站操作系统数据库连接失败
网络技术防范滞后