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

[Solved] RadGrid export to excel produces extra columns

5 Answers 328 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DogEars
Top achievements
Rank 2
DogEars asked on 22 Feb 2008, 03:34 AM
Using the latest version of RadGrid Prometheus and I have the following settings applied to my export.

'Make all columns visible to the export 
        RadGrid1.MasterTableView.ExportToExcel() 
 
        'setup properties for the data export 
        RadGrid1.ExportSettings.IgnorePaging = True 
        RadGrid1.ExportSettings.ExportOnlyData = True 
        RadGrid1.ExportSettings.OpenInNewWindow = True 
        'Set default file name of export file 
        RadGrid1.ExportSettings.FileName = "type your file name here" 
 

The export turns out well except for the fact that something is plugging in 2 empty columns in front of all my exported data. Is this a known bug of some kind and if so is there a workaround?

I do have 2 columns that have Display="false" in their properties...is it linked to this?

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 22 Feb 2008, 10:41 AM
Hello DogEars,

Please try using the Visible property instead like shown in this help article. I believe there was such a problem and we have addressed it for the SP2 release.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
DogEars
Top achievements
Rank 2
answered on 22 Feb 2008, 01:05 PM
The suggestions in that article didn't make any difference.

When my grid is exported it is showing all of the columns, even the ones I have Display="false" on and there are no command columns on the grid at this time.

Everything looks perfect, except those two columns in the very front.

I'll include my grid code as well here.

        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="False" AllowSorting="True" 
            GridLines="None" Skin="Default2006" PageSize="15" AutoGenerateColumns="False" 
            AllowAutomaticUpdates="True" ShowDesignTimeSmartTagMessage="False" DataSourceID="SDS_Report" 
            CssClass="imHand" AllowFilteringByColumn="True"
            <ExportSettings FileName="Buyer Export" IgnorePaging="True" OpenInNewWindow="True"
                <Pdf PaperSize="Letter" FontType="Subset"></Pdf> 
            </ExportSettings> 
            <PagerStyle Mode="NextPrevAndNumeric" /> 
            <MasterTableView CurrentResetPageIndexAction="SetPageIndexToFirst" Dir="LTR" Frame="Border" 
                TableLayout="Auto" CommandItemDisplay="None" DataKeyNames="item" DataSourceID="SDS_Report"
                <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
                    Visible="False"
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
                    Visible="False" Resizable="False"
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="HdrBuyFromBP" 
                        FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="HdrBuyFromBP" 
                        UniqueName="HdrBuyFromBP" Display="false"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="item" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="Item" UniqueName="item"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="OrdNumb" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="Order Number" UniqueName="OrdNumb"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="POS" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="POS" UniqueName="POS"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="DueOnDock" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="Due on Dock" UniqueName="DueOnDock"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="chngDelDate" 
                        FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Change Delivery Date" 
                        UniqueName="chngDelDate"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="OriginalOrdQty" 
                        FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Original Order Qty" 
                        UniqueName="OriginalOrdQty"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="BalanceDue" 
                        FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Balance Due" 
                        UniqueName="BalanceDue"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="StockOut" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="Stock Out" UniqueName="StockOut"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="BoeingBuyerCode" 
                        FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Boeing Buyer Code" 
                        UniqueName="BoeingBuyerCode"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="BoeingBuyerName" 
                        FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Boeing Buyer Name" 
                        UniqueName="BoeingBuyerName"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="RCVCode" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="RCV Code" UniqueName="RCVCode"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Inspection" 
                        FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Inspection" 
                        UniqueName="Inspection"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="OOR_NOTES" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="Status" UniqueName="OOR_NOTES"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="NewOrder" FilterListOptions="VaryByDataType" 
                        ForceExtractValue="None" HeaderText="New Order" UniqueName="NewOrder" Display="false"
                    </telerik:GridBoundColumn> 
                </Columns> 
                <EditFormSettings> 
                    <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
                    </EditColumn> 
                </EditFormSettings> 
            </MasterTableView> 
            <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"
                <ClientEvents OnRowClick="RowClick" /> 
                <Selecting AllowRowSelect="True" /> 
            </ClientSettings> 
        </telerik:RadGrid> 

0
Steve
Telerik team
answered on 26 Feb 2008, 12:39 PM
Hello DogEars,

After further investigation, it seems that this problem existed with the official SP1 release and I have tested locally with a more recent build. Anyway the problem is resolved now - please download Q3 SP2 from your Client.net account and let us know of the outcome.

All the best,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
DogEars
Top achievements
Rank 2
answered on 26 Feb 2008, 12:51 PM
I am using version 2007.3 1425, this is the latest one yes? At least that is what the licensing page tells me.

If it works for you...perhaps I am doing something wrong somewhere?

Code-behind I'm using:
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
        'Make all columns visible to the export 
        RadGrid1.MasterTableView.ExportToExcel() 
 
        RadGrid1.MasterTableView.Columns.FindByUniqueName("HdrBuyFromBP").Visible = False 
 
        'setup properties for the data export 
        RadGrid1.ExportSettings.IgnorePaging = True 
        RadGrid1.ExportSettings.ExportOnlyData = True 
        RadGrid1.ExportSettings.OpenInNewWindow = True 
        'Set default file name of export file 
        RadGrid1.ExportSettings.FileName = "type your file name here" 
 
    End Sub 

0
Steve
Telerik team
answered on 28 Feb 2008, 02:46 PM
Hello DogEars,

Indeed 2007.3 1425 is the latest version and it works correctly. I am attaching a sample project that has 2 columns with display="none" as your initial case. Exporting to excel will export only the two visible columns and not the ones with Display="false. Give it a spin and let me know how it goes.

All the best,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
DogEars
Top achievements
Rank 2
Answers by
Steve
Telerik team
DogEars
Top achievements
Rank 2
Share this question
or