Wednesday, March 18, 2009

Mengubah Font, PaperSize,Orientation pada crystal report

Menggunakan VB.net

Mungkin banyak teman-teman yang belum tau bagaiman mengubah papersize, font, Orientation pada crystal report lewat Vb.net

Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.Section
Imports CrystalDecisions.CrystalReports.Engine.FieldObject
Imports CrystalDecisions.CrystalReports.Engine.TextObject
Imports CrystalDecisions.Shared

Public Class Cetakan
Private rpt As Engine.ReportDocument
Private sub Cetak

Public Structure CetakKePrinter
Public namaReport As String
Public namaDatabase As String
Public namaServerDb As String
Public namaUserId As String
Public namaPassw As String
End Structure
rpt=new Engine.ReportDokumen

Dim cr As CetakKePrinter
cr.namaDatabase = data_base
cr.namaPassw = passWord
cr.namaServerDb = sErver
cr.namaUserId = "sa"
cr.namaReport = App_Path() & "/" & Me.NamaLaporan & ".rpt"
rpt.Load(cr.namaReport, OpenReportMethod.OpenReportByDefault)


Dim header As Single = 215.9 - UkuranBuku.Text
Dim Top As Integer = CInt((1440 / 25.4 * header) + (1440 / 25.4 * tinggi.Text))
Dim Left As Integer = CInt(1440 / 25.4 * kiri.Text)


rpt.PrintOptions.PaperSize = PaperSize.PaperLegal
rpt.PrintOptions.PaperOrientation = PaperOrientation.Landscape
rpt.PrintOptions.ApplyPageMargins(New CrystalDecisions.Shared.PageMargins(Left, Top, 0, 0))


Dim Huruf As New Font(Me.TxtHuruf.Text, Me.txtukuranhuruf.Text)
'pengubahan Section
Dim mySection As Section = rpt.ReportDefinition.Sections.Item("Section3")
Dim Teks As FieldObject
For i As Integer = 0 To MySection.ReportObject.Item.Count-1
Teks = mySection.ReportObjects.Item(i)
Teks.ApplyFont(Huruf)
Next
End Select
crp.ReportSource = rpt ' crp adalah Crystal Report Dokumen
crp.RefreshReport()

2 comments:

Mutakin Bakti said...

Thanks Blog ini membantu aku buat program

Indranya I U said...

mksih ya pak....

blognya sangat membantu saya dlm belajar visual basic