表格匯出Excel資料隱藏欄位也要匯出

摘要:表格匯出Excel資料隱藏欄位也要匯出

如果有用Telerik RadControl的人,不知道你有沒有使用過他的RadGrid,其中有一個匯出資料的API,可以讓你直接將表格上看到的資料匯出成為CSV、Excel、Word及PDF等檔案,可是如果表格中有隱藏欄位,匯出的時候也不會看到,如果在畫面上因為版面的問題不想看到,但是匯出資料要看到呢?

 

1 表格名稱.MasterTableView.Columns.FindByUniqueName("欄位名稱").Visible = true;
2
3 表格名稱.ExportSettings.ExportOnlyData = true;//是否只將資料匯出
4 表格名稱.ExportSettings.IgnorePaging = true;//是否忽略分頁
5 表格名稱.ExportSettings.OpenInNewWindow = true;//是否新開視窗
6 表格名稱.MasterTableView.ExportToExcel();//匯出成為Excel