There is an issue with Radgrid excel exporting.
I have followed this example exactly http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/excelmlexport/defaultcs.aspx
except i make a call to the database on the code-behind rather than using a sqldatasource.
but on ExcelMLExportRowCreated i try to get a CellElement by cell name but it always comes back as null. i disabled autocreating columns because i create my own on the aspx page and i set a HeaderText, DataField, and UniqueName for each one. The datafield and UniqueName are the same and i use that when i call GetCellByName. Why is this not working?
What am i missing?
Please reply/fix asap.
Thanks.
4 Answers, 1 is accepted
but now i have another problem. After saving/opening the excel, the grid is locked in 'loading' phase...meaning it has the loading icon in front of the grid and everything is disabled.
How do i revert it back to a reusable grid?
I am glad to hear the first issue is resolved.
To the second one: I tried to replicate it on the Export to ExcelML demo, but to no avail.
If the problem persists, please send us a small working project, demonstrating your full setup and showing the unwanted behavior.
We will debug it locally and get back to you.
Thank you in advance for the cooperation.
All the best,
Mira
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
e.Row.Cells.GetCellByName inside ExcelMLExportRowCreated is always null even after putting UseAllDataFields="true". I am using Needdatasource to bind the data through datatable. I have correct column but still gives me null for the cellElement. Please provide me quick reply
protected void btnExportExcel_Click(object sender, EventArgs e)
{
radGridSuspect.MasterTableView.Caption = AddComplainantandLeaInfo(chkComplainant.Checked, chkLeaInfo.Checked);
radGridSuspect.ExportSettings.FileName =
"Suspect";
radGridSuspect.ExportSettings.Excel.FileExtension =
"xls";
radGridSuspect.ExportSettings.ExportOnlyData =
true;
radGridSuspect.ExportSettings.IgnorePaging =
true;
radGridSuspect.ExportSettings.OpenInNewWindow =
true;
radGridSuspect.MasterTableView.ExportToExcel();
}
#endregion
protected void radGridSuspect_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
{
if (e.RowType == GridExportExcelMLRowType.DataRow)
{
foreach (GridColumn col in radGridSuspect.MasterTableView.Columns)
{
CellElement xlCell = e.Row.Cells.GetCellByName(col.UniqueName);
if (col.UniqueName == "FromCallDtm")
{
xlCell.StyleValue =
"InvoiceDateStyleValue";
}
}
}
// e.Row.Cells.GetCellByName("FromCallDtm").StyleValue = "InvoiceDateStyleValue";
}
protected void radGridSuspect_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
{
StyleElement InvoiceStyle = new StyleElement("InvoiceDateStyleValue");
InvoiceStyle.NumberFormat.FormatType =
NumberFormatType.ShortDate;
e.Styles.Add(InvoiceStyle);
}
protected void radGridSuspect_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
this.radGridSuspect.DataSource = this.CaseTargetPhoneDataSuspect;
if (rbnSuspectShow.SelectedValue == "2")
{
try
{
GridGroupByExpression expression1 = GridGroupByExpression.Parse("SuspectName[Name],SuspectAddress1[Address1],SuspectAddress2[Address2],SuspectCity[City],SuspectStateCd[State],SuspectZip5[Zip] Group By SuspectPhoneNum Descending");
this.CustomizeExpression(expression1);
this.radGridSuspect.MasterTableView.GroupByExpressions.Add(expression1);
}
catch (Exception ex)
{
lblMessage.Text =
string.Format("<span style='color:red'>Cannot add group by expression: {0}</span>", ex.Message);
lblMessage.Visible =
true;
}
}
}
Thank you,
Vijender.
I have already answered your other forum thread, so I would suggest you to continue our conversation there and close this one.
Please note that opening multiple forum threads with the same issue makes tracking the forum threads history very hard. In this regard, I suggest you to stick to the first one. This will enable us to respond more quickly and efficiently to your posts.
Regards,
Kostadin
Telerik