RadGrid 导出到 Excel
我有一个 radgrid,可以根据用户输入动态生成列。 填充网格后,用户可以选择导出到 Excel 或 Word。 但是,当用户想要保留页面格式时,不会导出任何数据。 但如果用户随后选择忽略分页,则一切正常。
因此,如果 radgrid 属性“AutoGenerateColumns”设置为 false,并且“IgnorePaging”也设置为 false,则似乎不会导出数据。
其他人也有这个问题还是我忽略了什么?
以下是配置和调用导出的方法:
private void ConfigureReport(string strExportType)
{
switch (strExportType.ToLower())
{
case "excel":
RadGrid1.ExportSettings.FileName = "RadGridExportToExcel";
break;
case "word":
RadGrid1.ExportSettings.FileName = "RadGridExportToWord";
break;
}
RadGrid1.ExportSettings.IgnorePaging = this.cbxPaging.Checked;
RadGrid1.ExportSettings.ExportOnlyData = this.cbxFormat.Checked;
}
private void btnExcel_Click(object sender, EventArgs e)
{
if (this.UserProcess.SearchResults != null &&
this.UserProcess.SearchResults.Count > 0)
{
ConfigureReport("excel");
RadGrid1.MasterTableView.ExportToExcel();
}
else
{
this.lblError.Text = AAILocalization.GetLocaleText("Error:NoResultExport");
}
}
提前感谢您的帮助:) 帕特
为了勇敢起见,我排除了创建列的方法。
I have a radgrid that generates columns dynamically based on user input. Once the grid is populated, the user has the option to export to excel or word. However when the user want's to retain the page formatting, no data is getting exported. But if the user then selects to ignore paging, everything works fine.
So it seems that if the radgrid property "AutoGenerateColumns" is set to false, and "IgnorePaging" is also false, data isn't getting exported.
Anyone else have this problem or am I over looking something?
Here are the methods that configure and call the export:
private void ConfigureReport(string strExportType)
{
switch (strExportType.ToLower())
{
case "excel":
RadGrid1.ExportSettings.FileName = "RadGridExportToExcel";
break;
case "word":
RadGrid1.ExportSettings.FileName = "RadGridExportToWord";
break;
}
RadGrid1.ExportSettings.IgnorePaging = this.cbxPaging.Checked;
RadGrid1.ExportSettings.ExportOnlyData = this.cbxFormat.Checked;
}
private void btnExcel_Click(object sender, EventArgs e)
{
if (this.UserProcess.SearchResults != null &&
this.UserProcess.SearchResults.Count > 0)
{
ConfigureReport("excel");
RadGrid1.MasterTableView.ExportToExcel();
}
else
{
this.lblError.Text = AAILocalization.GetLocaleText("Error:NoResultExport");
}
}
Thanks in advance for the help:)
Pat
P.S. i've excluded the method that creates the columns for bravity's sake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里没有足够的信息来提供确切的原因/解决方案,但是一个建议(实际上更多的是一种解决方法)是在用户导出时始终设置
IgnorePaging
。 这是一些示例代码:There isn't enough information here to provide an exact cause/solution, however one suggestion (really more of a workaround) is to always set
IgnorePaging
when the user is exporting. Here is some sample code: