ExportSettings.IgnorePaging = false, then I don't get any detail tables, but I also only get the page of the grid that I am currently on. Is there a way to get all pages, but not the detail tables?
I have played with the MasterTableView.HierarchyDefaultExpanded property, but I have found that it does nothing at all for me so it does not matter what I set it to.
7 Answers, 1 is accepted
Try disabling the paging temporarily using the AllowPaging property of the MasterTableView while exporting as shown below and see if it helps:
c#:
protected void Button1_Click(object sender, EventArgs e) |
{ |
RadGrid1.ExportSettings.OpenInNewWindow = true; |
RadGrid1.MasterTableView.AllowPaging = false; |
RadGrid1.MasterTableView.HierarchyDefaultExpanded = false; |
RadGrid1.MasterTableView.Rebind(); |
RadGrid1.MasterTableView.ExportToExcel(); |
} |
Hope this helps..
Princy.
MasterTableView.AllowPaging = false; |
MasterTableView.HierarchyDefaultExpanded = false; |
ExportSettings.ExportOnlyData = true; |
ExportSettings.IgnorePaging = true; //true - exports detail tables. false - does not |
ExportSettings.OpenInNewWindow = true; |
foreach (GridTableView lDetailGrid in base.MasterTableView.DetailTables) |
{ |
lDetailGrid.HierarchyDefaultExpanded = false; |
} |
MasterTableView.ExportToExcel(); |
I also don't rebind that grid on export as it was doubling my footer totals. I did try the rebind again, but it didn't change the outcome.
Any other ideas would be appreciated. Thanks!
I'm not sure that I understand what causes this behavior - could you please attach (in support ticket) a runnable project that demonstrate the problem?
In the meantime you could try this approach:
protected
void
RadGrid1_ExcelExportCellFormatting(
object
source, ExcelExportCellFormattingEventArgs e)
{
GridItem item = e.Cell.Parent
as
GridItem;
if
(item.OwnerTableView.Name !=
"MyMasterTableView"
)
item.OwnerTableView.Visible =
false
;
}
<MasterTableView Name="MyMasterTableView"....
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
protected void RadGrid1_ExcelMLExportStylesCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e)
{
foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles)
{
style.Attributes["BorderColor"] = "black";
if (style.Id == "headerStyle")
{
style.FontStyle.Bold = true;
style.FontStyle.Color = System.Drawing.Color.Black;
style.InteriorStyle.Color = System.Drawing.Color.Wheat;
style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
}
else if (style.Id == "itemStyle")
{
style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke;
style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
}
else if (style.Id == "alternatingItemStyle")
{
style.InteriorStyle.Color = System.Drawing.Color.LightGray;
style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
}
}
Telerik.Web.UI.GridExcelBuilder.StyleElement myStyle = new Telerik.Web.UI.GridExcelBuilder.StyleElement("MyCustomStyle");
myStyle.FontStyle.Bold = true;
myStyle.FontStyle.Italic = true;
myStyle.InteriorStyle.Color = System.Drawing.Color.Gray;
myStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
e.Styles.Add(myStyle);
}
protected void RadGrid1_ExcelExportCellFormatting(object source, Telerik.Web.UI.ExcelExportCellFormattingEventArgs e)
{
e.Cell.Style["BorderColor"] = "black";
if (e.FormattedColumn.UniqueName == "EacReportDate")
{
e.Cell.Style["mso-number-format"] = @"d\-mmm\-yyyy";
}
if (e.FormattedColumn.UniqueName == "WarrantyEndDate")
{
e.Cell.Style["mso-number-format"] = @"d\-mmm\-yyyy";
}
if (e.FormattedColumn.UniqueName == "WarrantyStartDate")
{
e.Cell.Style["mso-number-format"] = @"d\-mmm\-yyyy";
}
}
but only run protected void RadGrid1_ExcelMLExportStylesCreated, Why????
ExcelExportCellFormatting event fires only when using the HTML Excel format - this is why it won't fire in your scenario.
Word/Excel export (HTML-based)
For ExcelML you could use ExcelMLExportStylesCreated and ExcelMLRowCreated.
ExcelML export
Regards,
Daniel
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Could you please let me know which Excel export format is used in your scenario (HTML, ExcelML, Biff, Xlsx)? This will help me provide straight to the point example.
Regards,
Daniel
Telerik
See What's Next in App Development. Register for TelerikNEXT.