Category Archives: Crystal Report Tips and Tricks

Crystal Report Assign Variable – 如何在Crystal Report上 設定變數

由於太耐沒有使用crystal report的關係
所以忘了怎樣 Assign variable/設定變數
通常Developer都會使用”=“去 Assign variable/設定變數
今天也嘗試使用 “=” 來 Assign Variable 可惜得到不到想要的結果

以下是正確的方法 “:=
assign variable我們耐要使用 “:=“的


// Define Variable
StringVar s = "abc";
// Show Variable

Crystal Report - Formula Workshop - Formula Editor Failed to assign Variable Sample

Crystal ReportAssign Variable的正確方法是使用 “:=

// Define Variable
StringVar s := "abc";
// Show Variable

Crystal Report - Formula Workshop - Formula Editor Success to assign Variable Sample

這個Demo Designer ViewPreview
Crystal Report Designer Mode Preview - How to assign Variable

Crystal Report - Preview Mode - How to assign Variable

Hope you find it useful

Crystal Report Show page footer on first page only

這個報告是用Crystal Report XI R2 寫的..

由於只是需要方在首頁的Page Footer

我們可以使用Section Expert 中的Suppress 再加一個簡單的Formula便可以解決

Crystal ReportDesign Mode上 的邊邊上按右鍵..
之後選擇”Section Expert…
Crystal Report Section Expert...
Section Expert” Windows 便會彈出來
之後我們可以在”Sections:” 區域上選擇 “Page Footer” – 因為我們希望把資料/文字只顯示在 第一頁上
在右邊”Common tab” 入 按一下 “Suppress (No Drill-Down)“右方的 “Formula” 按鈕
在”Formula Editor – Suppress(No Drill Down)” Window上輪入 以下Formula

PageNumber >1

Crystal Report Section Expert Formula to show on First page footer only
這個意思是當Page Number大過1便Suppress 隱藏這個 Page Footer

Hope you find it useful

Crystal Report Bullet Points — 如何在Crystal Report 加入要點/Bullet Points

今日公司要更新公司其中某些Crystal Report檔案…
老闆希望我們可以在文件中加入一些Bullet Points/要點
令到Report 上的要點更加清澈..更加易看…

我找了很久也找不到Bullet Points的功能…
最後知道了…Crystal Report XI R2 是沒有Bullet Points 這個功能的
如果想做到這個效果便要自行找一些 像似是Bullet Points一樣字
來扮Bullet Points

其中一個方法是 用ALT KeyCode
就是說用你Keyboard 鍵盤上的 ALT鍵 加 一些數字去輸入一些符號字出來
ALT + 0149
按著 “ALT“鍵 [不可以方的] 之後按數字 NumberPad 上的數字 0149
便會出現這個 “” 符號了

Hope you find it useful

Crystal Report WCF Services 序

昨天公司有一個客戶希望我們可以在公司的客戶Portal 上加入一個新的功能…
很可惜公司還未開始使用Microsoft SQL ServerReporting Services [SSRS]..
而是使用Crystal Report 來做這個動作的…
但是…我們又沒有買Crystal Report Server來產生Report…
現在的做法是會在我們的電腦上安裝一個Crystal Report的Runtime
去令到所有同事都可以用我們的In-House Application 來生產Report…
就是寫一個WCF 的Service來負責生產Report…
之後再把生產出的的Report Path..
發送給Web Portal令到便用者可以Download這個Report…
再和大家分享如何寫一個WCF Service來解決這個 Crystal Report的問題
待續 =)

Crystal Report Helper Library on CodePlex

今天發佈了我另一個Library 到CodePlex 上…
這個Library 是我在.Net上使用Crystal Report XI R2 的元件時寫的
方便自己和其他朋友在.Net Application 中 使用Crystal Report的.rpt 檔 產生/導出報告成PDF

如果大家也是用.NetCrystal Report/或者將會考慮使用Crystal Report 的話..
可以嘗試使用這個Library, 看看能不能 令你在.Net [WinForm]中更方便地使用Crystal Report component 來 產生/導出PDF數據資料

以下是小小的Sample Code
首先我們要到CodePlex download


CrystalReportHelperLib.dll 加入到Project 上的參考上
以下的Sample Code 有一個例子, 解釋怎樣使用這個CrystalReportHelperLib

Imports CrystalReportHelperLib

Private Sub btn_GenerateReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_GenerateReport.Click
        '建立一個新的Crystal Report Helper
        Dim CReport As New CrystalReportHelper
        Using CReport
            CReport.SetDataSourceConnection("SQL Server Name", "SQL Database Name", "SQLUsername", "SQLPW")
            '將會用來Print 這個Report 的 Printer 名稱
            CReport.SetPrinter("Printer PathPrinter Name")
            '設定報告的 Variable
            CReport.SetParameter("@Period", "Database Variable1")
            CReport.SetParameter("@Period", "Database Variable1")

            'Export PDF
            CReport.ExportCrystalReport("PortableDocFormat", "C:CrystalReportExportShareChiWaiSample.pdf")

            'Print Report
            CReport = Nothing
        End Using
    End Sub

Hope you find it useful

Crystal Report Crashed When Opening .rpt file

I am having a problem on my crystal report 11.5. The application that I create cannot load the Crystal Report file, when i try to open a crystal report file(.rpt) that I created a year ago.[which i have edited last week.] 
All of sudden, it just started to crash the Crystal Report application as soon as I open it. 

I have asked my friend to open the same file on his machine and it works… (This .rpt is stored on the network drive). I guess it is something wrong on my computer.
However, i remember that I had silimar issue before, which is caused by the default printer.
Here it is my solution.
  1. Start-> Devices and Printers or [Printers and Faxes]
  2. Select an alternative printer as your default printer.
  3. Try to open up the .rpt again. It should works.
Hope this can help =)

Crystal report PDF font size get reduced/smaller

I just realised the font/text on PDF which I created by using Crystal report get resized. They displays fine on Crystal report preview screen and they were printed ok. When I try to print the same report from the PDF, the print out looks smaller.
After trying to fix it on the Crystal Report(Report option) and Adobe Reader(Print option). I realise that the only the Font get resized and all the Images/Box…etc they are all fine.
Finally, I found out that it is a bug on Crystal Report, it occurs since version 10, (or even eariler).
Here it is the solutions.
You need to modify your computer’s registry in order to fix it.
1) Press “Start” menu and click on “Run” (In Windows XP)
2) Type “regedit” and press Enter to open up Registry Editor
3) On the Registry Editor click on the “+” on “HKEY_CURRENT_USER
4) Then expand “Software”-> “Business Objects”-> “Suite 11.5
5) Click on “Export” and “PDF” if the PDF folder does not exist here
6) Right click on “Export” and Select “New”-> “Key” and rename it as “PDF”
7) After that right click on “PDF” and click on “New”->”DWORD” value and rename it to “ForceLargerFonts
8) Set 1 as the value of “ForceLargerFonts
9) Close Registry Editor and restart Crystal Report application
10) Try to export a PDF and see it the problem has been fixed
Hope this can help.