顯示具有 報表工具-Crystal Reports 標籤的文章。 顯示所有文章
顯示具有 報表工具-Crystal Reports 標籤的文章。 顯示所有文章

2014年2月7日 星期五

[Crystal Report] 應用程式中發生伺服器錯誤。無法載入檔案或組件 'CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' 或其相依性的其中之一。系統找不到指定的檔案。

說明:用VS 2008 (.NET Framework 3.5)內建的Crystal Report開發web-based報表 (import CrystalDecisions.CrystalReports.Engine),將ASP.NET佈到.NET Framework 2.0的Server上,出現該錯誤訊息:

應用程式中發生伺服器錯誤。
無法載入檔案或組件 'CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' 或其相依性的其中之一。 系統找不到指定的檔案。

也就是web.config裡註記要載入Crystal Report的相關dll找不到。


解決方法:
到網路上下載CRRedist2008_x86.msi檔案,並安裝到Server上,確認C:\Windows\assembly內相關dll安裝成功後,重試即可。


參考資料:
http://social.msdn.microsoft.com/Forums/zh-TW/80764698-46a4-43ba-87fb-094911442fea/aspnet-crystal-reports-vs-2008-ok-iisruntime?forum=236
http://code.google.com/p/crystaldelivery/downloads/detail?name=CRRedist2008_x86.zip&can=2&q

2014年1月26日 星期日

[Cystal Report] DateAdd與DateDiff函式使用記錄

語法:
DateDiff (intervalType, startDateTime, endDateTime)
DateAdd (intervalType, nIntervals, startDateTime)
Year (CurrentDate) //取得Date之西元年

例:
DateDiff ("m", CDate (Mid({?Cycle}, 1, 10)), DateAdd ("d", 1, CDate (Mid({?Cycle}, 12, 10))))


參考資料:
http://pic.dhe.ibm.com/infocenter/rsawshlp/v7r5m0/index.jsp?topic=%2Fcom.businessobjects.integration.eclipse.designer.doc%2Fhtml%2Ftopic682.html


2013年12月27日 星期五

[Crystal Report] 設定公式欄位

說明:有時候需要user輸入數值到報表做運算,這時可使用Crystal Report內建的公式欄位來進行後續的運算處理。
例:

原價 100
折數 user輸入
售價 100*折數並四捨五入到整數位


做法:
1. 在xxx.rpt上的欄位總管->公式欄位按右鍵->新增->輸入公式名稱->使用編輯器(個人prefer)
2. 參考Crystal Report提供之運算子或函式視窗,輸入公式:
例:Round (CDbl ({Product.Price}) * {?Rate}, 0) //使用CDbl轉換為數字型別

也可使用If then Else等流程控制函式,例:
if CDbl ({Product.Price}) > 10000
 then Round ((CDbl ({Product.Price})*0.3, 0)
else if  CDbl ({Product.Price}) > 5000
 then Round ((CDbl ({Product.Price})*0.2, 0)
else Round ((CDbl ({Product.Price})*0.1), 0)

也可使用Mid函式來分割字串,例:
Mid ({Test.Item}, 1, 5)
Item為abcdefg=>公式參數顯示為abcdf


參考資料:
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20060703143341LX6
http://blog.marksgroup.net/2010/03/crystal-reports-sorting-by-substring.html

2013年12月17日 星期二

[Crystal Report] 參數欄位設定

說明:有時需取得Client端的變數值,該怎麼把值塞到報表上?


作法:
1. 在test.rpt檔上欄位總管->參數欄位->右鍵新增->輸入名稱與選取數值類型->拉到報表上
2. 在test.aspx.cs
     //建構一ReportDocument object
     private ReportDocument rdTest = new ReportDocument();
     string strRptName = Page.MapPath("test.rpt");
   
     //Load
     rdTest.Load(strRptName);
   
     //設定參數欄位的現值
     rdTest.SetParameterValue(string name, object val);
   
     //Bind
     CrystalReportViewer1.ReportSource = rdTest;
     CrystalReportViewer1.DataBind();


參考資料:
http://www.wretch.cc/blog/JohnDX/14586953