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

[Solved] Export RadGrid to Excel. Column header align always = center

3 Answers 544 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kyle Roche
Top achievements
Rank 1
Kyle Roche asked on 26 Feb 2008, 05:09 AM
Hello, I am trying to export a grid to Excel. I can't seem to get the headers to not center. Even if I align left, they still export centered.

Is this a bug? Please see below. I"m using VS2008, .net 3.5 and Prometheus

<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="FullName"

FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Name"

UniqueName="FullName">

<HeaderStyle HorizontalAlign="Left" />

</telerik:GridBoundColumn>

<telerik:GridTemplateColumn CurrentFilterFunction="NoFilter"

FilterListOptions="VaryByDataType" ForceExtractValue="None"

HeaderText="Vehicle" UniqueName="TemplateColumn">

<ItemTemplate>

<asp:Label ID="Label1" runat="server"

Text='<%# DataBinder.Eval(Container.DataItem, "VehicleYear") + " " + DataBinder.Eval(Container.DataItem, "MakeLabel") + " " + DataBinder.Eval(Container.DataItem, "Model") %>'></asp:Label>

</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" />

</telerik:GridTemplateColumn>

<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Phone1"

FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Phone"

UniqueName="Phone1">

<HeaderStyle HorizontalAlign="Left" />

</telerik:GridBoundColumn>

<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="StepLabel"

FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Step"

UniqueName="StepLabel">

<HeaderStyle HorizontalAlign="Left" />

</telerik:GridBoundColumn>


And have this in my code-behind....

RadGridCallList.DataBind();

RadGridCallList.ExportSettings.ExportOnlyData =

false;

RadGridCallList.ExportSettings.OpenInNewWindow =

false;

RadGridCallList.ExportSettings.IgnorePaging =

true;

RadGridCallList.MasterTableView.ExportToExcel();

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 28 Feb 2008, 01:43 PM
Hi Kyle,

Do you use one of the embedded grid skins by chance? If so, try disabling the grid skin prior to the export action to see whether this helps.
Alternatively, use the native export to Excel supported by our Prometheus RadGrid which allows you to customize the appearance of the exported document prior to the actual export operation. See this topic for more info on this subject.

Finally, I recommend you use advanced programmatic binding intercepting the NeedDataSource event:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/NeedDataSource/DefaultCS.aspx

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rajib
Top achievements
Rank 1
answered on 30 Apr 2008, 11:07 AM

Dear Friends,

I am trying to export RadGrid data to excel format. I have this problem -
Suppose i have 5 pages in the grid, each page contain 15 records. i am able to export only the current page, whcih contains 15 records. For the second page i have to go 2nd page and click for export , then it will export the records between 16th to 30 .

Please help me to export all the records in the Grid.
I have written the following code in the click event -

protected void ImgExcel_Click(object sender, ImageClickEventArgs e)

{
    rgUsers.ExportSettings.ExportOnlyData = true;
    rgUsers.ExportSettings.IgnorePaging =  true;
    rgUsers.ExportSettings.OpenInNewWindow = true;
    //rgUsers.MasterTableView.ExportToPdf();
    rgUsers.MasterTableView.ExportToExcel();
}

Am i missing something ?

Thank & Regards,

Rajib

0
Konstantin Petkov
Telerik team
answered on 30 Apr 2008, 03:42 PM
Hi Rajib,

The exporting demo linked below seem to export all the Grid data with IgnorePaging="true":

http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/GeneralFeatures/Exporting/DefaultCS.aspx

The "Classic" controls version is available here:

http://www.telerik.com/demos/aspnet/Grid/Examples/GeneralFeatures/Exporting/DefaultCS.aspx

which functions correctly with the latest v5.1.3 of RadGrid.

Regards,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Kyle Roche
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Rajib
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Share this question
or