顯示具有 CRYSTAL 標籤的文章。 顯示所有文章
顯示具有 CRYSTAL 標籤的文章。 顯示所有文章

2020年6月18日 星期四

crystal report 控制字體大小

1.請利用 CrystalReports 公式去判斷字數再去變更其字體大小
2.在欄位上右鍵 --> 格式物件 --> 字型(標籤) --> 大小 ,編輯其公式
3.參考以下公式
if length({@欄位名稱}) > 15 then 9 else 12

2020年2月26日 星期三

Crystal Report由指定印表機直接列印

Crystal Report由指定印表機直接列印

將Crystal Report報表直接由指定印表機輸出
事前:引用Crystal Report DLL(Visual Studio 2010 後沒有內建Crystal Report,需自行到SAP網站下載)
using CrystalDecisions.CrystalReports.Engine;

Step1:顯示Print Dialog讓User挑選印表機
PrinterSettings printerSettings = new PrinterSettings();
PrintDialog printDialog = new PrintDialog();
printDialog.PrinterSettings = printerSettings;
printDialog.AllowPrintToFile = false;
printDialog.AllowSomePages = true;             
printDialog.UseEXDialog = true;

Step2:指定Crystal Report輸出印表機
DataTable DT = new DataTable();//資料來源
ReportDocument rpDoc = new ReportDocument();
Rec.Load(string.Concat(System.Environment.CurrentDirectory, @"\RPT_FORM\檔名.rpt"));
Rec.SetDataSource(DT);
rpDoc.PrintOptions.PrinterName = printerSettings.PrinterName;
rpDoc.PrintToPrinter(printerSettings.Copies, false, 0, 0);

※ReportDocument.PrintToPrinter 方法※
public virtual void PrintToPrinter (int nCopies , bool collated , int startPageN , int endPageN );
參數:
nCopies       //指出列印份數。
collated        //指出是否自動分頁。
startPageN  //指出要列印的第一頁。參數設定為 0 即可列印所有頁面
endPageN   //指出要列印的最後一頁。參數設定為 0 即可列印所有頁面

2018年1月11日 星期四

Crystal Reports, Developer for Visual Studio 2010-2017

官方下載網址:
Crystal Reports, Developer for Visual Studio Downloads

Copy of Crystal Reports, developer version for Microsoft Visual Studio - Service Pack 22 - Fixed Issues
--
OS 裡面有 2010 , 2015  -- 結果安裝SP21 把 VS2015 工具OK了
現問題來了 , 原 2010 安裝 SP3 版本的;全被幹掉了
完全不能執行了報表了

code 遇到 CrystalDecisions.CrystalReports.Engine.ReportDocument  全部報錯

--
把SP21 移除 ,  重安裝 SP3 for vs2010 ...也是掛了
--
安裝 Crystal Report SP21 記錄:
1. VS2008 因內建Crystal Report , 完全不受影響;可以正常運作!
2. VS2010 掛
3.VS2015 雖裝上了,未測是否執行沒問題
--
待續... (等處理好,續文...)

---------------------------------------------------------------------------------------------------------

20180114 --總算找出問題,底下為解決方法:

*** 安裝順序:VS2008->VS2010->VS2015->CRforVS_13_0_21->CRforVS_redist_install_64bit_13_0_21
因專案有2008/2010/2015 , 所以必須一次安裝完成後;才安裝水晶報表套件

若已安裝舊版本,必須把SP ?? / 執行階段版本(OSx64->預設會安裝64)  ===均移除後,才能安裝新版本的SP
(我不確定移除後再安裝是否有效,因我已砍掉重練了...)


1. 組件
CrystalDecisions.CrystalReports.Engine / 內嵌:False (版本:10.5.3700.0) /特定:Ture  (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.CrystalReports.Engine.dll

CrystalDecisions.Enterprise.Framework / 內嵌:Ture (版本:10.5.3700.0) /特定:Ture  (執行:v1.0.3705)
C:\Windows\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5.3700.0__692fbea5521e1304\CrystalDecisions.Enterprise.Framework.dll

CrystalDecisions.Enterprise.InfoStore / 內嵌:Ture (版本:10.5.3700.0) /特定:Ture  (執行:v1.0.3705)
C:\Windows\assembly\GAC\CrystalDecisions.Enterprise.InfoStore\10.5.3700.0__692fbea5521e1304\CrystalDecisions.Enterprise.InfoStore.dll

CrystalDecisions.ReportSource / 內嵌:False  (版本:10.5.3700.0) /特定:Ture  (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.ReportSource.dll

CrystalDecisions.Shared / 內嵌:False  (版本:10.5.3700.0) /特定:Ture  (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.Shared.dll

CrystalDecisions.Windows.Forms / 內嵌:False  (版本:10.5.3700.0) /特定:Ture (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.Windows.Forms.dll
---
有發現組件竟都是舊版本嗎? (全引用VS2008的組件==>是否因跟不上微軟一直更新產生的問題?全改回基本)
已實測過,VS2008 在任何windows版本上均不會有問題(不管windows怎update)
真的是沒砍掉重練,真的問題永遠不知道在哪...
所以客戶端,必須安裝 CRRedist2008_x86.msi + CRRedist2008_x86_cht.msi
----
***原本的專案組件必須重新參考引用跟上列表一樣的組件***
----
2.執行後,發生錯誤: crystal reports SetDataSource 未知的查詢引擎錯誤

APP.config 加入:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

------
原舊產品 , 若原是安裝 CRforVS_13_0_21(以下)的版本 ; 必須重新引用參考: (不可引用VS2008的組件)
CrystalDecisions.CrystalReports.Engine
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.CrystalReports.Engine.dll

CrystalDecisions.ReportSource
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.ReportSource.dll

CrystalDecisions.Shared
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.Shared.dll

CrystalDecisions.Windows.Forms
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.Windows.Forms.dll


2016年4月23日 星期六

Crystal reports 依群組來編細目裡項目的編號

引用來源:[Crystal reports]依群組來編細目裡項目的編號..?
--
請在 報表新增一個 累加值欄位
會出現 一個 視窗 [建立累加值欄位]
裡面請選取設定
摘要欄位 : 請從左方選一個顯示在細項裡的欄位
摘要類型 : 計數
驗算 : 每個資料錄
重設 : 群組變更時
將此 累加值欄位放到細項區塊

2015年12月12日 星期六

vbnet vshost32.exe 已經停止運作

VS2010/VS2012等以上 , 會出現這問題 : vshost32.exe 已經停止運作
這是因為 Crystal Report 的原因
若OS 是 64 bit , 那程式設定環境是x86 , 那在安裝Crystal Report 預設安裝是裝 x64 的驅動
必須補安裝 x86 的版本 (例: CRRuntime_32bit_13_0_5.msi )

這樣就不會再出現 vshost32.exe 停止運作 的錯誤訊息


2015年6月8日 星期一

2014年9月4日 星期四

Crystal Report X1 動態存取相片檔

參考引用來源
--

想要尋找在 crystal report 8.5 中動態秀相片檔的方法,可是一直試不出來,不過在測試中卻發現在 crystal report X1 版,有提供這個功能,方法如下:

1.插入圖片,調整好大小
2.點右鍵,選取 [圖片格式設定]
3.點選 [圖片] , 編輯 [公式] 如下圖


4.將圖片路徑打入公式, [儲存並關閉]


5.這樣在 X1 版,就可以使用動態相片檔了
6.至於本來想在行政系統使用,只有等待升級,不難需要時只好借用 X1 版,或是那天有找到使用 8.5 版的方法

2014年8月30日 星期六

VB.NET Crystal Reports Load Dynamically for mssql login

參考引用來源:VB.NET Crystal Reports Load Dynamically
---
使用 crystal report 設計階段階沒問題! 但電腦關機後,再次使用時;卻出現須要登入的問題
底下的範例即可解決!

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        Dim crtableLogoninfos As New TableLogOnInfos
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table

        cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")

        With crConnectionInfo
            .ServerName = "YOUR SERVER NAME"
            .DatabaseName = "YOUR DATABASE NAME"
            .UserID = "YOUR DATABASE USERNAME"
            .Password = "YOUR DATABASE PASSWORD"
        End With

        CrTables = cryRpt.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next

        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class

2014年8月25日 星期一

VB.NET Crystal Reports for Beginners (mssql )

請參考來源:VB.NET Crystal Reports for Beginners
--

Crystal Reports Without Database

請參考來源:Crystal Reports Without Database
--
基本的 datatable 用法

Crystal Reports - 設計 Master / Detail 報表

請參考來源:Crystal Reports - 設計 Master / Detail 報表
--

VB.Net crystal report connection string

參考引用來源:VB.Net crystal report connection string
--
 Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
        SetReportDb(My.Settings.colorlabConnectionString, CrystalReportViewer1, rpt_inwardreport1)
    End Sub



Public Sub SetReportDb(ByVal ConnectionString As String, ByRef CrystalReportViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer, ByRef reportDocument As ReportClass)
        'Get SQL Server Details
        Dim builder As New System.Data.Common.DbConnectionStringBuilder()

        builder.ConnectionString = ConnectionString


        Dim zServer As String = TryCast(builder("Data Source"), String)
        Dim zDatabase As String = TryCast(builder("Initial Catalog"), String)
        Dim zUsername As String = TryCast(builder("User ID"), String)
        Dim zPassword As String = TryCast(builder("Password"), String)

        Dim ciReportConnection As New ConnectionInfo

        ciReportConnection.ServerName = zServer
        ciReportConnection.DatabaseName = zDatabase
        ciReportConnection.UserID = zUsername
        ciReportConnection.Password = zPassword

        'Assign data source details to tables

        For Each table As Table In reportDocument.Database.Tables
            table.LogOnInfo.ConnectionInfo = ciReportConnection
            table.ApplyLogOnInfo(table.LogOnInfo)
        Next

        For Each subrep As ReportDocument In reportDocument.Subreports
            For Each table As Table In subrep.Database.Tables
                table.LogOnInfo.ConnectionInfo = ciReportConnection
                table.ApplyLogOnInfo(table.LogOnInfo)
            Next
        Next

        'Assign data source details to the report viewer
        If CrystalReportViewer.LogOnInfo IsNot Nothing Then
            Dim tlInfo As TableLogOnInfos = CrystalReportViewer.LogOnInfo
            For Each tbloginfo As TableLogOnInfo In tlInfo
                tbloginfo.ConnectionInfo = ciReportConnection
            Next
        End If
        reportDocument.VerifyDatabase()
        reportDocument.Refresh()
        CrystalReportViewer.ReportSource = reportDocument
        CrystalReportViewer.Refresh()
    End Sub

Creating a Report Connected to a Secure SQL Server Database

請參考來源:MSDN Creating a Report Connected to a Secure SQL Server Database
--
1.In Solution Explorer, right-click the project name that is in bold type, point to Add, and then click Add New Item.
2.In the Add New Item dialog box, in the Templates view, select the Crystal Report template.
3.In the Name field, enter the name "NorthwindCustomers.rpt", and then click Open.
Note   If you have not registered before, you may be asked to register. To find out how to register, see Crystal Reports Registration and Keycode.
4.In the Create New Crystal Report Document panel of the Crystal Reports Gallery dialog box, select Using a Report Wizard.
5.In the Choose an Expert panel, select Standard. Click OK.
The Standard Report Creation Wizard window appears.
6.In the Available Data Sources panel, expand the Create New Connection folder.
7.From the subfolder that opens, expand the OLE DB (ADO) folder.
The OLE DB (ADO) window appears.
8.Select Microsoft OLE DB Provider for SQL Server, and then click Next.
9.Enter the values for your database server, user id and password into the Server, User ID and Password fields.
10.From the Database drop down list, select "Northwind."
11.Leave the Integrated Security checkbox unchecked because you are using SQL Server authentication instead of NT authentication.
Click Finish.
The OLE DB folder is now expanded, showing your database server, and within it, the Northwind database.
12.Expand the nodes Northwind, dbo, and Tables, and then select the Customers table.
13.Click the > symbol to move the table into the Selected Tables panel, and then click Next.
14.Expand the Customers table, and then hold down the Ctrl key while you click CompanyName, ContactName and City.
15.Click the > symbol to move these fields into the Fields to Display panel, then click Next.
16.In the Available Fields panel, under Report Fields, select Customer.City, then click the > symbol to move the field into the Group By panel, and then click Finish.
The NorthwindCustomers report is created and loaded into the main window of Visual Studio.

2013年12月18日 星期三

2013年11月8日 星期五

crystal report 續下頁

應同事要求,要生出分類多頁時自動"續下頁"的字
例:
1.分類:醬油  page:1/1
2.分類:麵類  page:1/2 , 2/2   --->1/2 這頁的頁尾就要顯示:續下頁
3.分類:餅乾  page:1/1  

從來沒用報表弄這個,思考了一下;還是有解的!
----
結果: