This is a migrated thread and some comments may be shown as answers.

Export to Excel and Word from Radgrid

7 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
trunghieu
Top achievements
Rank 1
trunghieu asked on 01 Jun 2011, 08:27 PM
Hello,i have a question about exporting to excel,i have i Radgrid (include Client Select Column) when i export , it will export from Radgrid (include client select column),but i don't want to that,i want to only get data from radgrid ( not get cilent select column or other columns such as template column ....)
this's demo :
http://nguy-hiem.co.cc/share/demo.png
please help me,THANK

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Jun 2011, 05:36 AM
Hello Trunghieu,

One suggestion to hide ClientSelectColumns/TemplateColumns when exporting to excel is by setting the ExportSettings as shown below which worked as expected in my end.
aspx:
<ExportSettings  Excel-Format="ExcelML"  ExportOnlyData="true">
</ExportSettings>

Another approach to hide the Template Columns in the Export button click event before you export the grid to Word or Excel by setting the Display property as false.

RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").Display = false;

Thanks,
Princy,
0
trunghieu
Top achievements
Rank 1
answered on 02 Jun 2011, 05:42 PM
Thank you,but now i have a problem,when i using ajax i can't export ? what should i do ?

THANK
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Jun 2011, 07:03 PM
0
trunghieu
Top achievements
Rank 1
answered on 09 Jun 2011, 08:32 AM
Thank you ! now i have a question,please help me
protected void btnword_Click(object sender, ImageClickEventArgs e)
        {
             
        
            r.MasterTableView.ExportToWord();
        }
        RadGrid r;
        protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            qt = new global::sieuthi.BUSINESS.B_quatang();
            try
            {
                if (e.CommandName == RadGrid.ExpandCollapseCommandName)
                {
                    
                     
                    r = (RadGrid)((GridDataItem)e.Item).ChildItem.FindControl("RadGrid2");
 
                    r.DataSource = qt.DanhSachDoiQua(makh.ToString());
                    r.DataBind();
 
                }
                lbloi.Text = "";
            }
            catch (Exception ex)
            {
                lbloi.Text = ex.Message;
            }
 
        }
in this code,i want export to word from Radgrid2 (Radgrid2 into Radgrid1) , i using global variable Radgrid r and then i using event itemcommand (when i expanded) with code r = (RadGrid)((GridDataItem)e.Item).ChildItem.FindControl("RadGrid2");
finnaly in  btnword_Click Event i using r.MasterTableView.ExportToWord() , but my code not run

(Object reference not set to an instance of an object.) 

i don't know why ? please me help
Thanks !
Trung Hiếu
0
trunghieu
Top achievements
Rank 1
answered on 10 Jun 2011, 03:27 PM
help me,please
0
Daniel
Telerik team
answered on 14 Jun 2011, 03:31 PM
Hello Trung,

Please try to set IgnorePaging and ExportOnlyData properties to false and let me know if the problem still persists.

Best regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
trunghieu
Top achievements
Rank 1
answered on 14 Jun 2011, 04:31 PM
Thank you,but i think,my problem  to relate with global variable that's Radgrid r;

Thank,
Trung Hieu
Tags
Grid
Asked by
trunghieu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
trunghieu
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or