簡體   English   中英

在使用telerik程序集的C#winforms中,參考了如何將radGridView導出為pdf(我不使用MCV或WPF,而是在常規winforms中實現)

[英]In C# winforms using telerik assembly references how to export radGridView to pdf ( Im not using MCV or WPF, implementing in normal winforms)

    using Telerik.WinControls.Data;
    using Telerik.WinControls.UI.Export;

  namespace Directory
  {
  public partial class radForm : Form
  {
    public radForm()
    {
        InitializeComponent();
    }

    private void radForm_Load(object sender, EventArgs e)
    {

// TODO:這行代碼將數據加載到“ directoryDataSet.DirDetails”表中。 您可以根據需要移動或刪除它。

        this.dirDetailsTableAdapter.Fill(this.directoryDataSet.DirDetails);

    }

//點擊按鈕

    private void button1_Click(object sender, EventArgs e)
    {
        ExportToPDF exporter = new ExportToPDF(this.radGridView1);

// FileExtension屬性允許您更改導出文件的默認(* .pdf)文件擴展名

        exporter.FileExtension = "pdf"; 

        exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;

//使網格適合PDF頁面寬度

        exporter.FitToPageWidth = true;

//通過ExportToPDF對象的RunExport方法將數據導出為PDF

        string fileName = "c:\\Directory-information.pdf";
        exporter.RunExport(fileName);


     }


  }
}

我在這里缺少某些東西的某些信息以及我的gridview不會導出為pdf,並且不會進行文件創建。

private void button1_Click(object sender, EventArgs e)
    {


        ExportToPDF exporter = new ExportToPDF(this.radGridView1);
        exporter.FileExtension = "pdf";
        exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
        exporter.ExportVisualSettings = true;
        exporter.PageTitle = "Directory Details";
        exporter.FitToPageWidth = true;

        string fileName = "c:\\Directory-information.pdf";
        exporter.RunExport(fileName);

        MessageBox.Show("Pdf file created , you can find the file c:\\Directory-informations.pdf");                     
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM