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

[Solved] Suppress column from exporting

14 Answers 316 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lenny_shp asked on 15 Apr 2010, 07:32 PM
switched to 2010.1.706.35

1. When I export, this column has empty results.

2. Is there a way to suppress exporting of certain columns?  
Answer:  RadGrid1.Columns(Col.Status).Visible= False

                    <telerik:GridTemplateColumn HeaderStyle-Width="100px" UniqueName="Status" HeaderText="Status" DataField="Status" SortExpression="Status"
                        <ItemTemplate>  
                            <asp:Label ID="lblStatus" runat="server" Text='<%# Bind("Status") %>'></asp:Label>  
                        </ItemTemplate> 
                        <FilterTemplate> 
                            <telerik:RadComboBox runat="server" ID="StatusFilter" Width="90px" Skin="Simple"  
                                DataSource='<%# (New string() {"", "Active", "Completed", "Error"}) %>' 
                                CollapseAnimation-Type="None" ExpandAnimation-Type="None" 
                                SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Status").CurrentFilterValue %>' 
                                OnClientSelectedIndexChanged="StatusIndexChanged" >                  
                            </telerik:RadComboBox> 
                             
                            <telerik:RadScriptBlock ID="StatusScriptBlock" runat="server"
                                <script type="text/javascript"
                                    function StatusIndexChanged(sender, args) { 
                                        var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>"); 
                                        tableView.filter("Status", args.get_item().get_value(), "EqualTo"); 
                                    } 
                                </script> 
                            </telerik:RadScriptBlock>                            
                        </FilterTemplate>                                            
                    </telerik:GridTemplateColumn>    

14 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 19 Apr 2010, 09:38 PM
Hello Lenny_shp,

Could you please let us know which export format you use - PDF, ExcelML, HTML Excel, CSV or Word?

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
answered on 08 Jul 2010, 02:12 PM
<ExportSettings
   FileName="Export"
   HideStructureColumns="true"
   ExportOnlyData="true"
   IgnorePaging="true"
   OpenInNewWindow="true">
   <Excel FileExtension="XLS" Format="ExcelML" />
</ExportSettings>
2009.3.1210.35
0
Daniel
Telerik team
answered on 13 Jul 2010, 03:50 PM
Hello Lenny_shp,

1. When I export, this column has empty results.    How do I make it work?

Please try to set UseAllDataFields="true" as shown below:
<MasterTableView UseAllDataFields="true" ...

2. Is there a way to suppress exporting of certain columns?   I tried this prior to export but it still exports.
RadGrid1.Columns(Col.Status).Display = False
I recommend that you get the column by unique name and not by index.
protected void button1_Click(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.GetColumn("ProductName").Visible = false;
    RadGrid1.MasterTableView.ExportToExcel();
}

Best regards ,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
answered on 14 Jul 2010, 07:08 PM
Switched to 2010.1.706.35

1. UseAllDataFields="true" generates the error Column '' does not belong to table GroupedTable0.   For this report, I can use Format="Html" and it shows everything fine.   If I use ExcelML, it's blank.

2. Setting to visible=false works.

3. I have another report, when it's ExcelML or Html, the reports end up with the commanditems and filter boxes and links that would say "click here to sort" and a bunch of boxes (see report.png) even though I am setting it like the other one and in ItemCommand I also have:

                For Each commandItem As GridItem In Me.RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)
                    commandItem.Visible = False
                Next

<ExportSettings
   FileName="Export"              
   HideStructureColumns="true"
   ExportOnlyData="true"
   IgnorePaging="true"
   OpenInNewWindow="false">
   <Excel FileExtension="XLS" Format="Html" />
</ExportSettings>
0
Daniel
Telerik team
answered on 20 Jul 2010, 01:51 PM
Hello Lenny_shp,

1. I suppose this has something to do with the grouping but it is hard to guess the exact problem. If you provide a runnable demo I will be able to debug it locally.

3. This would happen only when exporting to HTML Excel. You can either set ExportOnlyData="true" or hide the item manually as explained in the documentation:
Word/Excel export (HTML-based)

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
answered on 20 Jul 2010, 03:10 PM
1. I don't have active grouping defined.

3. I do have ExportOnlyData="true".    That buttons, etc only show up under this report.   I have another report that exports to Excel Html and they don't have all the unwanted boxes/buttons and I could not see any difference that would cause this.    The configuration options are the same.  

The only difference is the report that does not work, have htmls in the detail table, but I am not exporting detail tables.

Currently I have to use csv.
0
Daniel
Telerik team
answered on 20 Jul 2010, 09:21 PM
Hello Lenny_shp,

Please submit a new support ticket and attach a simple, runnable copy of your project. This way I will be able to examine/debug it locally.

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
PRITESH
Top achievements
Rank 1
answered on 20 Jun 2014, 09:02 AM
Hello,

when i try to export RadGrid Groping in ExcelML format it always give me error saying'TotalResult' does not belongs to table while i am not using such column in RadGrid nor it is in my DB,
I am using GridCalculated Columns to display Group wise total.

The Export works well for HTML Excel and Biff

I tried and found that if i remove  
 RadGrid1.ExportSettings.Excel.Format = (GridExcelExportFormat)Enum.Parse(typeof(GridExcelExportFormat), "ExcelML");

this line than it allows to export in ExcelML but the format seems like HTML export

Please Provide necessary solution.
0
Princy
Top achievements
Rank 2
answered on 24 Jun 2014, 11:16 AM
Hi Pritesh,

Please try the following code snippet to set the Excel export format. If this doesn't help, provide your full code snippet.

C#:
RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;

Thanks,
Princy
0
Daniel
Telerik team
answered on 24 Jun 2014, 02:25 PM
Hello Pritesh,

Please have in mind that calculated columns won't be exported to ExcelML. I'm afraid this functionality is not supported although the aforementioned limitation should not be the causing an exception.
If you post your RadGrid declaration here I will try to reproduce the problem on my end.

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
PRITESH
Top achievements
Rank 1
answered on 25 Jun 2014, 05:57 AM
Hi Princy and Daniel

I tried code suggested by Princy but still the same error occurs,

Following is my code snipeet
<td>

                    <telerik:RadGrid ID="RadGrid1" runat="server" PageSize="20" AllowSorting="True" AllowMultiRowSelection="True"                       AllowPaging="True" ShowGroupPanel="True" OnNeedDataSource="radGrid1_NeeddatSource" AllowFilteringByColumn="true"

                        OnExcelMLWorkBookCreated="RadGrid1_ExcelMLWorkBookCreated"  ShowFooter="true" OnItemCreated="RadGrid1_ItemCreated"
                        OnHTMLExporting="RadGrid1_HtmlExporting" OnBiffExporting="RadGrid1_BiffExporting"
                        AutoGenerateColumns="False" GridLines="none"  ClientSettings-Resizing-AllowResizeToFit = "true" >
                        <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
                        <GroupingSettings RetainGroupFootersVisibility = "true" GroupByFieldsSeparator="Zone_Name" GroupSplitFormat="Zone_Name" />
                         
                        <MasterTableView Width="100%" ShowGroupFooter="true" AllowMultiColumnSorting="true">
                            <GroupByExpressions>
                                <telerik:GridGroupByExpression>
                                    <SelectFields >
                                        <telerik:GridGroupByField FieldAlias="Zone_Name" FieldName="Zone_Name"  HeaderValueSeparator="Zone::-"/>
                                    </SelectFields>
                                    <GroupByFields>
                                        <telerik:GridGroupByField FieldName="Zone_code" SortOrder="Ascending"   />       
                                    </GroupByFields>
                                </telerik:GridGroupByExpression>                             
                                 
 
 
                            </GroupByExpressions>
                             
                            <Columns >
                                <telerik:GridBoundColumn DataField="Zone_Name" Visible="false">
                                </telerik:GridBoundColumn>
                               
                                <telerik:GridBoundColumn DataField="SubjectIndexNumber" HeaderStyle-Width="150px" HeaderStyle-Wrap="true" HeaderText="SubjectIndexNumber" FooterText="Total:-" ColumnGroupName = "SubjectIndexNumber">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="English" HeaderText="English" Aggregate="Sum"  FilterControlWidth="40px"  >
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Gujarati" HeaderText="Gujarati" Aggregate="Sum" FilterControlWidth="40px" >
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Hindi" HeaderText="Hindi" Aggregate="Sum" FilterControlWidth="40px" >
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Marathi" HeaderText="Marathi" Aggregate="Sum" FilterControlWidth="40px" >
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Urdu" HeaderText="Urdu" Aggregate="Sum" FilterControlWidth="40px" >
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Telugu" HeaderText="Telugu" Aggregate="Sum" FilterControlWidth="40px" >
                                </telerik:GridBoundColumn>
                              
                                <telerik:GridCalculatedColumn HeaderText="Total" DataFields="English,Gujarati,Hindi,Marathi,Urdu,Telugu"  FilterControlWidth="40px"
                                Expression="{0}+{1}+{2}+{3}+{4}+{5}" DataType="System.Int32" UniqueName="Total" FooterText="Total:" Aggregate="Sum">
                                </telerik:GridCalculatedColumn>  
                                 
                                                       
                 
 
 
                                <telerik:GridBoundColumn DataField="Gujarati" HeaderText="GUJ" Aggregate="Sum" FilterControlWidth="40px">
                                </telerik:GridBoundColumn>
                                <telerik:GridCalculatedColumn DataFields="Gujarati" HeaderText="PackG" Expression="iif({0}%20= 0,{0}/20,({0}/20)+1)"
                                DataType="System.UInt32" UniqueName="PackG" Aggregate="Sum" FilterControlWidth="40px"></telerik:GridCalculatedColumn>
                                 <telerik:GridBoundColumn DataField="English" HeaderText="ENG" Aggregate="Sum">
                                </telerik:GridBoundColumn>
                                <telerik:GridCalculatedColumn DataFields="English" HeaderText="PackE" Expression="iif({0}%20= 0,{0}/20,({0}/20)+1)"
                                DataType="System.UInt32" UniqueName="PackE" Aggregate="Sum" FilterControlWidth="40px"></telerik:GridCalculatedColumn>
                                 
                                <telerik:GridCalculatedColumn HeaderText="Oth" DataFields="Hindi,Marathi,Urdu,Telugu" 
                                Expression="{0}+{1}+{2}+{3}" DataType="System.Int32" UniqueName="Oth" FooterText="Total:" Aggregate="Sum" FilterControlWidth="40px">
                                </telerik:GridCalculatedColumn
                                  <telerik:GridCalculatedColumn DataFields="Hindi,Marathi,Urdu,Telugu" HeaderText="PackO" FilterControlWidth="40px" Expression="iif(({0}+{1}+{2}+{3})%20= 0,({0}+{1}+{2}+{3})/20,(({0}+{1}+{2}+{3})/20)+1)"
                                DataType="System.UInt32" UniqueName="PackO" Aggregate="Sum"></telerik:GridCalculatedColumn>
                                 
 
                                <telerik:GridCalculatedColumn HeaderText="Total" DataFields="English,Gujarati,Hindi,Marathi,Urdu,Telugu"  FilterControlWidth="40px"
                                Expression="{0}+{1}+{2}+{3}+{4}+{5}" DataType="System.Int32" UniqueName="Total1" FooterText="Total:" Aggregate="Sum">
                                </telerik:GridCalculatedColumn>
                                 
                                    <telerik:GridCalculatedColumn HeaderText="TotalPack" DataFields="English,Gujarati,Hindi,Marathi,Urdu,Telugu" FilterControlWidth="40px" 
                                Expression="iif(({0})%20= 0 and ({1})%20=0 and ({2}+{3}+{4}+{5})%20=0,({0}+{1}+{2}+{3}+{4}+{5})/20,(({0}+{1}+{2}+{3}+{4}+{5})/20)+1)" DataType="System.Int32" UniqueName="TotalP" FooterText="Total:" Aggregate="Sum">
                                </telerik:GridCalculatedColumn>
                                 
                                                             
 
                               
 
                            </Columns>
                        
                             
                             
                        </MasterTableView>
                        <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
                            <Selecting AllowRowSelect="True"></Selecting>
                            <Resizing AllowRowResize="True" AllowColumnResize="True" EnableRealTimeResize="True"
                                ResizeGridOnColumnResize="False"></Resizing>
                        </ClientSettings>
                        <GroupingSettings ShowUnGroupButton="true"></GroupingSettings>
                    </telerik:RadGrid>
                   
                </td>

 


Following is code i am using to export
RadGrid1.ExportSettings.Excel.Format = (GridExcelExportFormat)Enum.Parse(typeof(GridExcelExportFormat), alternateText);
// RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
            RadGrid1.ExportSettings.IgnorePaging = true;           
            RadGrid1.ExportSettings.ExportOnlyData = true;
            RadGrid1.ExportSettings.FileName = "Patrak2";
            RadGrid1.ExportSettings.OpenInNewWindow = true;                
            RadGrid1.MasterTableView.ExportToExcel();

I have attached error screenshot
0
Princy
Top achievements
Rank 2
answered on 25 Jun 2014, 08:26 AM
Hi Pritesh,

Can you try setting the EnableLinqExpressions="false" for your RadGrid and check if the issue exist.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" EnableLinqExpressions="false">

Thanks,
Princy
0
PRITESH
Top achievements
Rank 1
answered on 25 Jun 2014, 08:57 AM
Hi Princy,

I tried it and I got error saying "The given key was not present in the dictionary"

Thanks.
0
Kostadin
Telerik team
answered on 27 Jun 2014, 01:08 PM
Hi Pritesh,

I am afraid that this is a bug and I already logged it in our system. You could track the progress of the item in our Ideas&Feedback portal. In order to export the calculated column I would suggest you to use some of the rest export formats.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Answers by
Daniel
Telerik team
PRITESH
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Kostadin
Telerik team
Share this question
or