본문 바로가기
.NET

Telerik GridViewSpreadExport 이용 방법

by leo21c 2022. 6. 27.
SMALL

Telerik 버전 2022.1.222.40를 사용하고 있다.

RadGridView의 내용을 excel, csv 파일로 export 하는 기능을 제공한다고 예제에 있는데 참고 사이트와 같이 코드를 작성하면 참조를 추가하라는 dll이 없어서 당황을 했다.

 

추후 export 기능을 사용할 때 참고를 위해서 기록을 남긴다.

https://docs.telerik.com/devtools/winforms/controls/gridview/exporting-data/export-to-csv

 

Export to CSV - WinForms GridView Control | Telerik UI for WinForms

Controls / GridView / Exporting Data This method offers excellent export performance. It creates a csv file and supports formatting events to allow customizing exported data. The CSV export functionality is located in the TelerikData.dll assembly. You need

docs.telerik.com

위의 사이트에는 아래와 같은 내용으로 설명을 하고 있다.


The CSV export functionality is located in the TelerikData.dll assembly. You need to include the following namespaces in order to access the types contained in TelerikData:

  • Telerik.WinControls.Data
  • Telerik.WinControls.UI.Export

그런데 참조를 추가하려고 찾아보면 없다.

dll 폴더를 찾아보니 export 관련 dll이 존재한다.

 

이름은 TelerikExport 이다. 내가 등록한 버전은 v4.0.30319 이다.TelerikExport.dll을 참조에 추가하면 using Telerik.WinControls.Export; 이 정상적으로 활성화가 된다.

 

예제 소스는 참고 사이트와 크게 다르지 않다.


private void toolStripButtonSave_Click(object sender, EventArgs e)
{
    string extension = "xlsx";
    SaveFileDialog dialog = new SaveFileDialog()
    {
        DefaultExt = extension,
        Filter = String.Format("{1} files (*.{0})|*.{0}|All files (.)|.", extension, "Excel"),
        FilterIndex = 1
    };
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        GridViewSpreadExport export = new GridViewSpreadExport(this.radGridView);
        SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
        export.RunExport(dialog.FileName, exportRenderer); 
    }
}

radGridView의 내용을 excel 파일로 저장을 한다.

정상 작동이 되는 것을 확인했다.

LIST