Hello,
I am using xml to bind the radgrid(datasource), i have many columns in xml but out of them i show the selected columns in radgid, but while exporting the csv i need to show all the columns, i have accomplished this but the problem is that i have a column(UserID and TweetID) which has integer value having 15+ digits and when i export it in csv i find the valuse in exponential form, do we have any way to show the values as they are ie. without exponantial form.
To track it easily i am attaching a sample screenshot of the
xml file which i use as datasource for my Radgrid and a screenshot of my Radgrid, the columns of radgrid will be exported the way they are.
Any quick help on this is highly appreciated as its urgent.
Thanks!
With regards,
Peeyush Pandey
I am using xml to bind the radgrid(datasource), i have many columns in xml but out of them i show the selected columns in radgid, but while exporting the csv i need to show all the columns, i have accomplished this but the problem is that i have a column(UserID and TweetID) which has integer value having 15+ digits and when i export it in csv i find the valuse in exponential form, do we have any way to show the values as they are ie. without exponantial form.
To track it easily i am attaching a sample screenshot of the
protected void btnExportToCSV_Click(object sender, EventArgs e)
{
radgridSentiment.ExportSettings.IgnorePaging = true;
radgridSentiment.MasterTableView.ExportToCSV();
radgridSentiment.MasterTableView.GetColumn("columnTweetID").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnBusinessAreas").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnLocation").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnAuthorLocationContinentCode").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnAuthorLocationStateCode").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnAuthorLocationRegionCode").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnAuthorLocationCountryCode").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnDataSourceIndustry").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnDataSourceCoverageArea").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnDataSourceBusinessArea").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnLifeStyle").Visible = true;
radgridSentiment.MasterTableView.GetColumn("DataURL").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnUserID").Visible = true;
radgridSentiment.MasterTableView.GetColumn("UserID").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnSelect").Visible = false;
radgridSentiment.MasterTableView.GetColumn("columnAction").Visible = false;
radgridSentiment.MasterTableView.GetColumn("columnTweetDataExport").Visible = true;
radgridSentiment.MasterTableView.GetColumn("columnTweetData").Visible = false;
}
Any quick help on this is highly appreciated as its urgent.
Thanks!
With regards,
Peeyush Pandey
9 Answers, 1 is accepted
0
Hello Peeyush,
You can try the workaround suggested in the online help topic:
CSV Export
Quote:
Daniel
the Telerik team
You can try the workaround suggested in the online help topic:
CSV Export
Quote:
Microsoft Excel parses the cell values automatically depending on the local settings. For example the string 19/05 might change to 19.May automatically. The only workaround would be to insert a sign of equality (=) before the relevant string. For example: "012" should be modified as ="012".
Kind regards,Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Peeyush
Top achievements
Rank 1
answered on 16 Sep 2012, 02:56 AM
Hello Daniel,
I tried this but was not able to accomplish it, i tried it in the griditemDataBound event
1- item["columnTweetID"].Text = "=" + item["columnTweetID"].Text;
can i not handle it in :
1- Data format string property of RadGrid column
2- OnGridExporting function
3- OnExportCellFormatting
or some other stuff so that i get the values as they are, it only happens when the column value exceeds 10 digit
eg: 247137197944348000 becomes 2.47137E+17
i just need to format the cell value to integer with zero decimal value, which i accomplish through formatting cells in MS Excel, it would be great if i do that from code by using any of the above mentioned metods or any other.
Please suggest.
Thanks in advance!
with regards,
Peeyush Pandey
I tried this but was not able to accomplish it, i tried it in the griditemDataBound event
1- item["columnTweetID"].Text = "=" + item["columnTweetID"].Text;
can i not handle it in :
1- Data format string property of RadGrid column
2- OnGridExporting function
3- OnExportCellFormatting
or some other stuff so that i get the values as they are, it only happens when the column value exceeds 10 digit
eg: 247137197944348000 becomes 2.47137E+17
i just need to format the cell value to integer with zero decimal value, which i accomplish through formatting cells in MS Excel, it would be great if i do that from code by using any of the above mentioned metods or any other.
Please suggest.
Thanks in advance!
with regards,
Peeyush Pandey
0

Peeyush
Top achievements
Rank 1
answered on 19 Sep 2012, 09:03 AM
The ExportCellFormatting event handler does not appear to fire when
exporting to CSV like it does for Excel. I believe this event is
supposed to be a replacement for the deprecated
ExcelExportCellFormatting event, but I would think based off the name
and the deprecation of its predecessor that this should fire for CSV as
well.
ExportCellFormatting is the only event that I've found thus far where i can format the cells of csv while exporting.
any urgent help will be highly appreciated.
Thanks!
ExportCellFormatting is the only event that I've found thus far where i can format the cells of csv while exporting.
any urgent help will be highly appreciated.
Thanks!
0
Hello Peeyush,
To achieve your desired functionality, Excel will need to recognize your data content not as a numeric type, but as a string object. Could you please try the following approach:
Please note that this approach is not appropriate with Template Columns.
I hope this will prove helpful. Please give it a try and let me know about the result.
All the best,
Eyup
the Telerik team
To achieve your desired functionality, Excel will need to recognize your data content not as a numeric type, but as a string object. Could you please try the following approach:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.ExportToCsvCommandName)
{
foreach
(GridDataItem dataItem
in
RadGrid1.MasterTableView.Items)
{
GridTableCell cell = dataItem[
"OrderID"
]
as
GridTableCell;
cell.Text = cell.Text+
"\nr"
;
}
}
}
Please note that this approach is not appropriate with Template Columns.
I hope this will prove helpful. Please give it a try and let me know about the result.
All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Peeyush
Top achievements
Rank 1
answered on 26 Sep 2012, 09:04 AM
Hello Eyup,
Thanks for your help, the column is gridboundcolumn but still the thing did not work,,
<telerik:GridBoundColumn DataField="TweetID" HeaderText="TweetID" UniqueName="columnTweetID"
Visible="false">
<HeaderStyle />
</telerik:GridBoundColumn>
Please suggest.
FYI, i used the code but the if condition was not fulfilled (ie. if (e.CommandName == RadGrid.ExportToCsvCommandName)), so i commented the if condition, still the things did not work.
protected void radgridSentiment_ItemCommand(object sender, GridCommandEventArgs e)
{
//if (e.CommandName == RadGrid.ExportToCsvCommandName)
//{
foreach (GridDataItem dataItem in radgridSentiment.MasterTableView.Items)
{
GridTableCell cell = dataItem["columnTweetID"] as GridTableCell;
cell.Text = cell.Text + "\nr";
}
//}
}
Thanks!
with regards.
Peeyush
Thanks for your help, the column is gridboundcolumn but still the thing did not work,,
<telerik:GridBoundColumn DataField="TweetID" HeaderText="TweetID" UniqueName="columnTweetID"
Visible="false">
<HeaderStyle />
</telerik:GridBoundColumn>
Please suggest.
FYI, i used the code but the if condition was not fulfilled (ie. if (e.CommandName == RadGrid.ExportToCsvCommandName)), so i commented the if condition, still the things did not work.
protected void radgridSentiment_ItemCommand(object sender, GridCommandEventArgs e)
{
//if (e.CommandName == RadGrid.ExportToCsvCommandName)
//{
foreach (GridDataItem dataItem in radgridSentiment.MasterTableView.Items)
{
GridTableCell cell = dataItem["columnTweetID"] as GridTableCell;
cell.Text = cell.Text + "\nr";
}
//}
}
Thanks!
with regards.
Peeyush
0
Hi Peeyush,
The suggested approach needs CSV export command to be fired in order to work. Could you please verify that the event handler is configured correctly and your export command triggers RadGrid ItemCommand event as expected?
Greetings,
Eyup
the Telerik team
The suggested approach needs CSV export command to be fired in order to work. Could you please verify that the event handler is configured correctly and your export command triggers RadGrid ItemCommand event as expected?
Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Peeyush
Top achievements
Rank 1
answered on 03 Oct 2012, 02:23 PM
Thanks for your reply!
I tried few things so that csv export command fires, but could not achieve, the event( radgrid_itemcommand) fires but on export button click the commandname comes blank.
Can you please suggest how can i achieve it, it would be of great help?
Thanks!
with regards,
Peeyush Pandey
I tried few things so that csv export command fires, but could not achieve, the event( radgrid_itemcommand) fires but on export button click the commandname comes blank.
Can you please suggest how can i achieve it, it would be of great help?
Thanks!
with regards,
Peeyush Pandey
0
Hi Peeyush,
I am afraid we are not able to reproduce the issue on our end. Please open a support ticket and attach a sample runnable application demonstrating the problematic behavior or provide us the steps to reproduce the issue. Thus, we will be able to further debug the project and provide a proper solution.
Greetings,
Eyup
the Telerik team
I am afraid we are not able to reproduce the issue on our end. Please open a support ticket and attach a sample runnable application demonstrating the problematic behavior or provide us the steps to reproduce the issue. Thus, we will be able to further debug the project and provide a proper solution.
Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Peeyush
Top achievements
Rank 1
answered on 05 Oct 2012, 12:38 PM
Hello Eyup,
Thanks for your help, i figured it out, and the problem is resolved.
item["columnTweetID"].Text = item["columnTweetID"].Text + "\nr";
i did this thing in the itemdatabound event of radgrid instead of itemcommand event and it worked.
Thanks a tonne!
with regards,
Peeyush Pandey
Thanks for your help, i figured it out, and the problem is resolved.
item["columnTweetID"].Text = item["columnTweetID"].Text + "\nr";
i did this thing in the itemdatabound event of radgrid instead of itemcommand event and it worked.
Thanks a tonne!
with regards,
Peeyush Pandey