Kirk Thomas
Top achievements
Rank 1
Kirk Thomas
asked on 28 Sep 2009, 08:54 PM
Hello,
I'm having some trouble with getting the header column of the datagrid I'm exporting to excell to display what I want. I have the grid display the header the way I want but when I export the grid the excel spread sheet has the header as the column names in my database table. Can I change that so the spreadsheet headers say what I want?
Thanks,
Kirk
I'm having some trouble with getting the header column of the datagrid I'm exporting to excell to display what I want. I have the grid display the header the way I want but when I export the grid the excel spread sheet has the header as the column names in my database table. Can I change that so the spreadsheet headers say what I want?
Thanks,
Kirk
8 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 29 Sep 2009, 04:44 AM
Hello Kirk,
You can set the HeaderText for the required column while exporting as shown below:
c#:
Thanks
Princy.
You can set the HeaderText for the required column while exporting as shown below:
c#:
protected void btnExport_Click(object sender, EventArgs e) |
{ |
RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").HeaderText = "Your Custom Text"; |
RadGrid1.ExportSettings.OpenInNewWindow = true; |
RadGrid1.ExportSettings.ExportOnlyData = true; |
RadGrid1.ExportSettings.IgnorePaging = true; |
RadGrid1.MasterTableView.ExportToExcel(); |
} |
Thanks
Princy.
0
Kirk Thomas
Top achievements
Rank 1
answered on 29 Sep 2009, 01:06 PM
This works for when the IgnorePaging is set to true but it doesn't when it is set to false. Why is that and is there a way to fix it?
0
Kirk Thomas
Top achievements
Rank 1
answered on 29 Sep 2009, 01:06 PM
This works for when the IgnorePaging is set to true but it doesn't when it is set to false. Why is that and is there a way to fix it?
0
Erick Burgess
Top achievements
Rank 1
answered on 14 May 2015, 07:15 PM
Luckily i stumbled upon this thread. I was trying to change the value of a gridboundcolumn in an export and was not able to do it. Of course I had IgnorePaging set to true. As soon as I commented that out, everything works.
Any news on this actually getting fixed?
0
Erick Burgess
Top achievements
Rank 1
answered on 14 May 2015, 07:15 PM
teset
0
Hello Erick,
Which event do you use to change the text?
Looking forward to your reply.
Regards,
Eyup
Telerik
Which event do you use to change the text?
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem && e.Item.ItemIndex == 5)
// custom condition
{
GridDataItem item = e.Item
as
GridDataItem;
item[
"Freight"
].Text =
"Success"
;
}
}
Looking forward to your reply.
Regards,
Eyup
Telerik
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 Feedback Portal
and vote to affect the priority of the items
0
Graeme
Top achievements
Rank 1
answered on 04 Jun 2015, 12:30 PM
01.
Protected
Sub
Button1btnPrintToWord_Click(sender
As
Object
, e
As
System.Web.UI.ImageClickEventArgs)
Handles
Button1btnPrintToWord.Click
02.
isExport =
True
03.
gvMain.MasterTableView.GetColumn(
"OReading"
).HeaderText =
"OReading"
04.
gvMain.MasterTableView.GetColumn(
"linkBtn"
).Display =
False
05.
gvMain.BorderStyle = BorderStyle.None
06.
gvMain.HeaderStyle.BackColor = System.Drawing.ColorTranslator.FromHtml(
"#178cc6"
)
07.
gvMain.HeaderStyle.ForeColor = Drawing.Color.White
08.
'gvMain.Style.Remove("border")
09.
For
Each
item
As
GridDataItem
In
gvMain.Items
10.
'item.Style("background-color") = "#888888"
11.
item.Style(
"border"
) =
"none"
12.
Next
13.
For
Each
item
As
GridDataItem
In
gvMain.Items
14.
'item.Style("background-color") = "#888888"
15.
item.Style(
"border"
) =
"none"
16.
Next
17.
gvMain.MasterTableView.ExportToPdf()
18.
End
Sub
01.
<
telerik:RadGrid
ID
=
"gvMain"
runat
=
"server"
CellSpacing
=
"-1"
GridLines
=
"None"
02.
ResolvedRenderMode
=
"Classic"
AutoGenerateColumns
=
"false"
Skin
=
"Web20"
>
03.
<
ExportSettings
ExportOnlyData
=
"true"
OpenInNewWindow
=
"true"
>
04.
<
Pdf
PageWidth
=
"297mm"
PageHeight
=
"210mm"
PageLeftMargin
=
"5px"
PageRightMargin
=
"5px"
05.
DefaultFontFamily
=
"Arial Unicode MS"
/>
06.
</
ExportSettings
>
07.
<
MasterTableView
TableLayout
=
"Auto"
GridLines
=
"Both"
AllowPaging
=
"false"
Width
=
"100%"
>
08.
<
CommandItemSettings
ShowAddNewRecordButton
=
"false"
ShowRefreshButton
=
"false"
/>
09.
<
Columns
>
10.
<
telerik:GridBoundColumn
DataField
=
"Size"
UniqueName
=
"Category"
HeaderText
=
"Category"
></
telerik:GridBoundColumn
>
11.
<
telerik:GridBoundColumn
DataField
=
"Model"
UniqueName
=
"Model"
HeaderText
=
"Model"
></
telerik:GridBoundColumn
>
12.
13.
<
telerik:GridTemplateColumn
HeaderText
=
"Rego"
UniqueName
=
"Rego"
>
14.
<
ItemTemplate
>
15.
<
asp:Label
ID
=
"lblRego"
runat
=
"server"
Text
=
""
></
asp:Label
>
16.
</
ItemTemplate
>
17.
</
telerik:GridTemplateColumn
>
18.
<
telerik:GridBoundColumn
DataField
=
"FleetNo"
UniqueName
=
"FleetNo"
HeaderText
=
"Fleet#"
></
telerik:GridBoundColumn
>
19.
<
telerik:GridBoundColumn
DataField
=
"Colour"
HeaderText
=
"Colour"
></
telerik:GridBoundColumn
>
20.
<
telerik:GridBoundColumn
DataField
=
"CurrentCity"
UniqueName
=
"CurrentCity"
HeaderText
=
"Located"
></
telerik:GridBoundColumn
>
21.
<
telerik:GridBoundColumn
DataField
=
"CurrentCity"
UniqueName
=
"CLocated"
HeaderText="Currently<br/>Located"></
telerik:GridBoundColumn
>
22.
<
telerik:GridBoundColumn
DataField
=
"CurrentCity"
UniqueName
=
"ALocated"
HeaderText
=
"Actual Location"
></
telerik:GridBoundColumn
>
23.
<
telerik:GridBoundColumn
DataField
=
"Mileage"
UniqueName
=
"OReading"
HeaderText
=
"Odometer Reading"
></
telerik:GridBoundColumn
>
24.
<
telerik:GridBoundColumn
DataField
=
"Mileage"
UniqueName
=
"ActualKMS"
HeaderText
=
""
></
telerik:GridBoundColumn
>
25.
<
telerik:GridBoundColumn
DataField
=
"Cleaned"
UniqueName
=
"Cleaned"
HeaderText="Vehicle<br/>Cleaned"></
telerik:GridBoundColumn
>
26.
<
telerik:GridBoundColumn
DataField
=
"Cleaned"
UniqueName
=
"CleanedStatus"
HeaderText="Actual Vehicle<br/>Cleaned Status"></
telerik:GridBoundColumn
>
27.
<
telerik:GridBoundColumn
DataField
=
"NextPickupDate"
UniqueName
=
"NextPickupDate"
HeaderText
=
"Next Pickup"
></
telerik:GridBoundColumn
>
28.
<
telerik:GridTemplateColumn
HeaderText
=
""
UniqueName
=
"linkBtn"
>
29.
<
ItemTemplate
>
30.
<
asp:HyperLink
ID
=
"lnkbtnRego"
Target
=
"_blank"
Text
=
"Update"
runat
=
"server"
/>
31.
</
ItemTemplate
>
32.
</
telerik:GridTemplateColumn
>
33.
34.
</
Columns
>
35.
</
MasterTableView
>
36.
</
telerik:RadGrid
>
Hello Team,
I have already checked http://www.telerik.com/forums/radgrid-ignorepaging-on-export but no sucess. I just want to format the pdf like remove or change the border thickness, add background to Headers and Items, Change the HeaderText for Export.
Please help urgent.
Thanks,
Mrinal
0
Hi Graeme,
You can check the following section:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/pdf-export#border-support
Hope this helps.
Regards,
Eyup
Telerik
You can check the following section:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/pdf-export#border-support
Hope this helps.
Regards,
Eyup
Telerik
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 Feedback Portal
and vote to affect the priority of the items