Hello!!
I need to allow exporting all the rows of my RadGrid to .CSV, however after i tested the exportToCSV button, it only exports the results of the first page(showed on the webpage).
It's possible to export all the GRID data ?? Can you tell me how?
Another thing I need to know, is how can i export only one column values to a pdf or excell..instead of all the collumns unformatted??
I need to allow exporting all the rows of my RadGrid to .CSV, however after i tested the exportToCSV button, it only exports the results of the first page(showed on the webpage).
It's possible to export all the GRID data ?? Can you tell me how?
Another thing I need to know, is how can i export only one column values to a pdf or excell..instead of all the collumns unformatted??
20 Answers, 1 is accepted
0

Jayesh Goyani
Top achievements
Rank 2
answered on 02 Aug 2011, 06:02 PM
Hello,
Please use below method if you used "OnNeedDataSource" event for binding datasource
Else use below method
Thanks,
Jayesh Goyani
Please use below method if you used "OnNeedDataSource" event for binding datasource
protected
void
RadGrid1_ItemCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if
(e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
{
RadGrid1.MasterTableView.Columns.FindByUniqueName(
"YourCoumnUniqueName"
).Visible =
false
;
// hide column before export
RadGrid1.ExportSettings.IgnorePaging =
true
;
}
}
Else use below method
protected
void
RadGrid1_ItemCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if
(e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
{
RadGrid1.MasterTableView.Columns.FindByUniqueName(
"YourCoumnUniqueName"
).Visible =
false
;
// hide column before export
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.DataSource =
""
;
// please set data source again.
RadGrid1.DataBind();
}
}
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 02 Aug 2011, 09:43 PM
Hello and thanks, what about export only the first column values to excell or pdf?
0

Jayesh Goyani
Top achievements
Rank 2
answered on 03 Aug 2011, 05:07 AM
Hello,
int count = 0;
foreach(GridColumn column in RadGrid1.Columns) {
If(count > 0)
column.Visible= false;
else if(column.Visible)
count ++;
}
Thanks,
Jayesh Goyani
int count = 0;
foreach(GridColumn column in RadGrid1.Columns) {
If(count > 0)
column.Visible= false;
else if(column.Visible)
count ++;
}
Thanks,
Jayesh Goyani
0
Accepted

Rakesh Gupta
Top achievements
Rank 2
answered on 03 Aug 2011, 09:10 AM
Hello Ricardo,
You can use the following code to Export only the First Column of the RadGrid.
The code given by Jayesh will also work but somtimes we are using some id columns which are generally first column and not visible on the Grid at that it will export blank.
So, i changed the Jayesh's code bit.
I think this is helpful to you.
Let me know for any concerns,
--
Thanks & Regards,
Rakesh Gupta
You can use the following code to Export only the First Column of the RadGrid.
The code given by Jayesh will also work but somtimes we are using some id columns which are generally first column and not visible on the Grid at that it will export blank.
So, i changed the Jayesh's code bit.
I think this is helpful to you.
int
count = 0;
foreach
(GridColumn column
in
radGrid.Columns)
{
if
(column.Visible)
{
if
(count > 0)
column.Visible =
false
;
else
count++;
}
}
Let me know for any concerns,
--
Thanks & Regards,
Rakesh Gupta
0

Ricardo
Top achievements
Rank 1
answered on 05 Aug 2011, 03:19 PM
Hello again....i think something is missing...I tried the code bellow and when i click on the button to export csv....it export only the rows that are paged.......
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
{
RadGrid1.MasterTableView.Columns.FindByUniqueName("SequencialNumber").Visible = false; // hide column before export
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.DataSource = this.SapDocuments; // please set data source again.
RadGrid1.DataBind();
}
}
and aspx:
<
div
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Width
=
"97%"
enableajax
=
"True"
CssClass
=
"productsGrid"
CellSpacing
=
"0"
DataSourceID
=
"SqlDataSource1"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
GridLines
=
"None"
Width
=
"100%"
CommandItemSettings-ShowExportToCsvButton
=
"True"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemDisplay
=
"Top"
DataSourceID
=
"SqlDataSource1"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"SequencialNumber"
HeaderText
=
"SequencialNumber"
UniqueName
=
"SequencialNumber"
SortExpression
=
"SequencialNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Priority"
HeaderText
=
"Priority"
UniqueName
=
"Priority"
FilterControlAltText
=
"Filter Priority column"
SortExpression
=
"Priority"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Process"
HeaderText
=
"Staging"
UniqueName
=
"Process"
SortExpression
=
"Process"
FilterControlAltText
=
"Filter Process column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SupplierCode"
HeaderText
=
"SupplierCode"
UniqueName
=
"SupplierCode"
SortExpression
=
"SupplierCode"
FilterControlAltText
=
"Filter SupplierCode column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"MessageStatus"
HeaderText
=
"MessageStatus"
UniqueName
=
"MessageStatus"
SortExpression
=
"MessageStatus"
FilterControlAltText
=
"Filter MessageStatus column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DocumentType"
HeaderText
=
"DocumentType"
UniqueName
=
"DocumentType"
FilterControlAltText
=
"Filter DocumentType column"
SortExpression
=
"DocumentType"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
UniqueName
=
"InvoiceCreationDate"
DataField
=
"InvoiceCreationDate"
HeaderText
=
"InvoiceCreationDate"
FilterControlAltText
=
"Filter InvoiceCreationDate column"
SortExpression
=
"InvoiceCreationDate"
>
<
FilterTemplate
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker1"
runat
=
"server"
>
</
telerik:RadDatePicker
>
</
FilterTemplate
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridBoundColumn
DataField
=
"SupplierVatNumber"
FilterControlAltText
=
"Filter SupplierVatNumber column"
HeaderText
=
"SupplierVatNumber"
SortExpression
=
"SupplierVatNumber"
UniqueName
=
"SupplierVatNumber"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
ExpandCollapseColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"19px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
RowIndicatorColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:EscalonamentoFacturasConnectionString %>"
SelectCommand="SELECT [SequencialNumber], [Priority],[Process], [SupplierCode], [MessageStatus], [DocumentType],[InvoiceCreationDate], [SupplierVatNumber] FROM [SapDocuments]
WHERE [Process] IN ('S','SP');"></
asp:SqlDataSource
>
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 05 Aug 2011, 05:30 PM
Hello Ricardo
,
Let me know if any concern.
Thanks,
Jayesh Goyani
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Width
=
"97%"
enableajax
=
"True"
CssClass
=
"productsGrid"
CellSpacing
=
"0"
DataSourceID
=
"SqlDataSource1"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
onitemcommand
=
"RadGrid1_ItemCommand"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
GridLines
=
"None"
Width
=
"100%"
CommandItemSettings-ShowExportToCsvButton
=
"True"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemDisplay
=
"Top"
DataSourceID
=
"SqlDataSource1"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
UniqueName
=
"ID"
SortExpression
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
FilterControlAltText
=
"Name"
SortExpression
=
"PrioNamerity"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
ExpandCollapseColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"19px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
RowIndicatorColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [Name] FROM [TelerikTable1]"></
asp:SqlDataSource
>
protected
void
RadGrid1_ItemCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.ExportToCsvCommandName)
{
RadGrid1.MasterTableView.Columns.FindByUniqueName(
"ID"
).Visible =
false
;
RadGrid1.ExportSettings.IgnorePaging =
true
;
}
}
Let me know if any concern.
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 05 Aug 2011, 05:42 PM
Hello again, and thanks for you help...could you tell explain me the changes you did?
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 05 Aug 2011, 05:47 PM
Hello,
i removed below 2 line code because export command automatically bind datasource again when we used needDataSource or SqldataSource as for binding the datasource.
Please see below link.
http://www.telerik.com/help/aspnet-ajax/grid-commands-that-invoke-rebind-implicitly.html
Thanks,
Jayesh Goyani
i removed below 2 line code because export command automatically bind datasource again when we used needDataSource or SqldataSource as for binding the datasource.
RadGrid1.DataSource = this.SapDocuments; // please set data source again.
RadGrid1.DataBind();
Please see below link.
http://www.telerik.com/help/aspnet-ajax/grid-commands-that-invoke-rebind-implicitly.html
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 05 Aug 2011, 06:09 PM
Thanks but now it export all the columns data, but i only want to export the first column "SequencialNumber"...
0

Ricardo
Top achievements
Rank 1
answered on 05 Aug 2011, 06:15 PM
SOLVED!
0

Ricardo
Top achievements
Rank 1
answered on 05 Aug 2011, 06:20 PM
Hello again...
It's possible to format the value of the column i wanto to export??
I have values like "200800000109215" and on the .csv it appears like :
It's possible to export like 200800000109215??
It's possible to format the value of the column i wanto to export??
I have values like "200800000109215" and on the .csv it appears like :
2,01E+14 |
It's possible to export like 200800000109215??
0

Jayesh Goyani
Top achievements
Rank 2
answered on 06 Aug 2011, 05:30 AM
Hello,
please try below code.
Thanks,
Jayesh Goyani
please try below code.
protected
void
RadGrid1_GridExporting(
object
sender, GridExportingArgs e)
{
e.ExportOutput = e.ExportOutput.Replace(
"\"\r\n\""
,
"\"\r\n\"'"
);
}
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 08 Aug 2011, 09:18 AM
HELLO Jayesh,
Wich are the name of that event?? I'm trying to find it on RadGrid Properties/Events and i can't find it....
Wich are the name of that event?? I'm trying to find it on RadGrid Properties/Events and i can't find it....
0

Ricardo
Top achievements
Rank 1
answered on 08 Aug 2011, 09:23 AM
Hello Jayesh,
your code works but i have a "'" before the number
EX:
'201100000384244
I tried :
but them the number is again :
your code works but i have a "'" before the number
EX:
'201100000384244
I tried :
protected void RadGrid1_GridExporting(object sender, GridExportingArgs e)
{
e.ExportOutput = e.ExportOutput.Replace("\"\r\n\"", "\"\r\n\"");
}
but them the number is again :
2,01E+14
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 08 Aug 2011, 09:26 AM
Hello,
please see attached image.
Thanks,
Jayesh Goyani
please see attached image.
Thanks,
Jayesh Goyani
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 08 Aug 2011, 09:35 AM
Hello Ricardo,
You have to put ( ' ) symbol because in Csv file if you add this symbol then it will convert your value/text/Number to string.
Because we are not able to add formatstring on export of CSV so.
Let me know if any concern.
for more information please see below link.
http://www.telerik.com/help/aspnet-ajax/grid-csv-export.html
http://www.telerik.com/help/aspnet-ajax/grid-html-export.html
Thanks,
Jayesh Goyani
You have to put ( ' ) symbol because in Csv file if you add this symbol then it will convert your value/text/Number to string.
Because we are not able to add formatstring on export of CSV so.
Let me know if any concern.
for more information please see below link.
http://www.telerik.com/help/aspnet-ajax/grid-csv-export.html
http://www.telerik.com/help/aspnet-ajax/grid-html-export.html
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 08 Aug 2011, 09:41 AM
ALright...But if we export to excell??
0

Yogesh
Top achievements
Rank 1
answered on 18 Apr 2012, 01:01 PM
Hi,
We are using all the export features i.e. Excel, word, Csv and PDF through javascript.
By default we get output for Excel, PDF and Word but in case of CSV we only get the headers.
When we set the "ExportOnlyData" property to false in the aspx, we get values in CSV too.
But, when we do this, the output of other three formats get distorted. We start getting the filter box in the output of Excel.
Is there a way out so that the "ExportOnlyData" property is set only for CSV?
We do not intend to move this code to the .cs file.
Thanks & Regards
Yogesh Lotlikar
We are using all the export features i.e. Excel, word, Csv and PDF through javascript.
By default we get output for Excel, PDF and Word but in case of CSV we only get the headers.
When we set the "ExportOnlyData" property to false in the aspx, we get values in CSV too.
But, when we do this, the output of other three formats get distorted. We start getting the filter box in the output of Excel.
Is there a way out so that the "ExportOnlyData" property is set only for CSV?
We do not intend to move this code to the .cs file.
Thanks & Regards
Yogesh Lotlikar
0

soumen
Top achievements
Rank 1
answered on 12 Aug 2015, 06:48 AM
I have a radgrid which has an image column.When I am exporting in excel format the image is showing in excel file,but when I am exporting it to csv file it is only showing the image url instead of the image.Is there anyway to embed the image in csv file?
Anyone can help me please
0

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Aug 2015, 04:25 PM
Hello,
CSV is a text based file format, where as an images are binary data, the two don't mix well.
You'd be better of supplying a reference to the images (relative path and name) and bundling them together.
Thanks,
Jayesh Goyani