Showing posts with label Crystal reports. Show all posts
Showing posts with label Crystal reports. Show all posts

Friday, 16 December 2016

CrystalDecisions Exception


If you get the error
The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception
in your project check the following

What bit your machine is x86 or 64 if 64 set the Target CPU to x86 and make sure you have the runtimes installed for x86



Thursday, 29 May 2014

Datepart in Crystal Reports

Crystal Reports datepart is slightly different than  SQL and VB



Interval type            Description
yyyy                          Extracts the year
q                               Quarter (the result is 1, 2, 3 or 4)
m                              Month (the result is from 1 to 12)
y                               Day of year (1 to 365 or 366 in a leap year)
d                               Day part of the date (1 to 31)
w                              Day of week (1 to 7 with the result depending on firstDayOfWeek)
ww                           Week of year (1 to 53 with firstDayOfWeek and firstWeekOfYear determining the exact days of the first calendar week of the year)
h                               Extracts the hour part of the given DateTime (0 to 23)
n                               Minute part (0 to 59)
s                                Second part (0 to 59)



Datepart ("yyyy", your value)


Thursday, 8 May 2014

Shade Alternate Lines


Repost from Crystal Report Tips and Trick  This was very useful and simple.

Shading Alternate Details Lines

  1. Right-click the Details section name.
  2. Select Section Expert.
  3. Click the color tab and click the Conditional Formatting button.

  4. To shade every other line, enter the formula
    If RecordNumber Mod 2 = 0 Then crSilver else crNoColor
    To shade every two lines, enter the formula
    If RecordNumber Mod 4 in 1 to 2 Then crSilver else crNoColor
  5. Click OK twice, and preview your report.

Wednesday, 23 April 2014

Export Crystal report to PDF

Please see below code on how to export a crystal report as a PDF file without using a viewer.



 Dim filename As String
     
        filename ="c:\labels.pdf"
        Dim cryRpt As New ReportDocument
        cryRpt.Load("c:\labesbooked.rpt")
        Try
            Dim CrExportOptions As ExportOptions
            Dim CrDiskFileDestinationOptions As New  _
            DiskFileDestinationOptions()
            Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
            CrDiskFileDestinationOptions.DiskFileName = filename
          
            CrExportOptions = cryRpt.ExportOptions
            With CrExportOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
                .DestinationOptions = CrDiskFileDestinationOptions
                .FormatOptions = CrFormatTypeOptions
            End With
            cryRpt.Export()
        Catch ex As Exception
'do somthing
        End Try

Wednesday, 13 February 2013

Hide show field on text value Crystal Reports

Need to suppress a  field in Crystal Reports when  a filed contains  part of some text  like

"Get some Text"  and you need to suppress the field when it says "text" then in the field to be suppressed

  1. goto format text
  2. check suppress
  3. Click  x-s
  4.  add  InStr ({field name},'text' )>0 
This will hide show the field when "text" is present

if there is more then one line say in the body then add 
or
InStr (previous ({filed name}),'text' )>0


Change the 0 to 1 or -1 as appropriate to hide or show depending on what match is made by instr()







Multi Point USB Charger

  USB Plug Charger, 4-Port USB Fast Charger Plug with 33W Intelligent Quick Charge 3.0 Wall Charger, Multi USBPower Adapter UK Fast Charging...