Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution to the problem of ASP.NET report

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

ASP.NET report problem solution, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Do ASP.NET projects will encounter ASP.NET report problems, Chinese-style reports of the tedious let me very disgusted, but there is no way ah, customers have demand! Naturally want to use DCOM to directly operate EXCEL, just so-so, although the security is not good, serious waste of resources, after all, used in the local area network, make do.

But always hate the unfinished EXCEL process on the server side. The enemy must be killed! Google, it turns out that there is this ASP.NET reporting problem both at home and abroad. There is also a solution, which can be done under Windows XP, but I haven't killed it all day under WINDOWS 2003, so I really want to kill myself. Later, someone recommended a control ASPOSE to solve the ASP.NET report problem, this thing is strong, the server does not have to install EXCEL, the effect is good! Want to use this thing lazily, one word-cool!

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 = 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= "Total" 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", 5co iRow) Cells [iRow,7] .Formula = sumTotal ("H", 5pjr Row); cells [iRow,10] .Formula = sumTotal ("K", 5pr iRow); cells [iRow,13] .Formula = sumTotal ("N", 5pr iRow); cells [1jue 8] .PutValue (cpStartDate.SelectedDate.ToShortDateString ()); cells [1m12] .PutValue (cpEndDate.SelectedDate.ToShortDateString ()) Range range = cells.CreateRange; 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 ("material in and out of warehouse summary .xls", Encoding.UTF8), SaveType.OpenInBrowser,FileFormatType.Default,this.Response);} after reading the above, have you mastered the solution to the problem of ASP.NET report? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 224

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report