2011-04-02 71 views

回答

0
foreach (ReportObject objReport in rpt.ReportDefinition.Sections["Section3"].ReportObjects) 
{ 
    FieldObject objField = (FieldObject)objReport; 
    objField.ApplyFont(new Font("Arial", 8.25F, FontStyle.Italic, GraphicsUnit.Point, ((byte)(0)))); 
} 

對於PDF,請參閱以下內容:

+0

謝謝brij ... il試試這個 – 2011-04-02 07:48:49

1
protected void Page_Load(object sender, EventArgs e) 
{ 
    ExportOptions objExOpt; 

    CrystalReportViewer1.ReportSource = (object)getReportDocument(); 
    CrystalReportViewer1.DataBind(); 
    // Get the report document 
     ReportDocument repDoc = getReportDocument(); 

    repDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; 
    repDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; 
    DiskFileDestinationOptions objDiskOpt = new DiskFileDestinationOptions(); 
    objDiskOpt.DiskFileName = @"c:\crystal report\TFA.pdf"; 
    repDoc.ExportOptions.DestinationOptions = objDiskOpt; 
    repDoc.Export(); 
} 

private ReportDocument getReportDocument() 
{ 
    // File Path for Crystal Report 
    string repFilePath = Server.MapPath("~/CrystalReport1.rpt"); 
    // Declare a new Crystal Report Document object 
    // and the report file into the report document 
    ReportDocument repDoc = new ReportDocument(); 

    repDoc.Load(repFilePath); 

    // Set the datasource by getting the dataset from business 
    // layer and 
// In our case business layer is getCustomerData function 
return repDoc; 
} 
0
ReportDocument reportobj = //Add code to return valid report document from a crystal report 
if (reportobj != null) 
{ 
    //Export to PDF 
    ((ReportDocument)reportobj).ExportToDisk(ExportFormatType.PortableDocFormat, file); 
    //Open using default app for PDF docs 
    if (System.IO.File.Exists(file)) 
     System.Diagnostics.Process.Start(file); 
} 
-2

水晶報表轉換爲PDF格式,您可以嘗試PDF庫,將打印水晶報告給pdf文件。