devexpress girdview 转excel求助
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了devexpress girdview 转excel求助相关的知识,希望对你有一定的参考价值。
我现在有3个gridview要转成EXCEL文件保存,用gridView.ExportToXls,怎么能将3个gridview存到1个excel文件的3个sheet页中?谢谢!
只保存键值,不用保存显示的值#region 导出Execl
private void ExportToXls()
string fileName = ShowSaveFileDialog("Microsoft Excel Document", "Microsoft Excel|*.xls");
if (fileName != "")
ExportTo(new ExportXlsProvider(fileName));
OpenFile(fileName);
private string ShowSaveFileDialog(string title, string filter)
SaveFileDialog dlg = new SaveFileDialog();
string name = " 统计表";
int n = name.LastIndexOf(".") + 1;
if (n > 0) name = name.Substring(n, name.Length - n);
dlg.Title = "Export To " + title;
dlg.FileName = name;
dlg.Filter = filter;
if (dlg.ShowDialog() == DialogResult.OK) return dlg.FileName;
return "";
private void ExportTo(IExportProvider provider)
Cursor currentCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
this.FindForm().Refresh();
BaseExportLink link = gridView1.CreateExportLink(provider);
(link as GridViewExportLink).ExpandAll = false;
//link.Progress += new DevExpress.XtraGrid.Export.ProgressEventHandler(Export_Progress);
link.ExportTo(true);
provider.Dispose();
//link.Progress -= new DevExpress.XtraGrid.Export.ProgressEventHandler(Export_Progress);
Cursor.Current = currentCursor;
private void OpenFile(string fileName)
if (XtraMessageBox.Show("你想打开这个文件吗??", "文件导出...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
try
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = fileName;
process.StartInfo.Verb = "Open";
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.Start();
catch
DevExpress.XtraEditors.XtraMessageBox.Show(this, "您的系统上无法找到适合打开导出的数据文件的应用程序。", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
//progressBarControl1.Position = 0;
#endregion 参考技术A 设置了CustomColumnDisplayText事件后,GridView导出的数据到Excl是自定义后的数据 ,如何才能导出原始数据?
protected void ASPxGridView1_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e)
for (int i = 0; i < ASPxGridView1.VisibleRowCount; i++)
if (e.Column.FieldName == "品名")
var v_hash = new Hashtable();
v_hash.Add("p1", e.GetFieldValue("入库单id"));
v_hash.Add("p2", Q_入库日期_1.Date.ToString("yyyy-MM-dd"));
v_hash.Add("p3", Q_入库日期_2.Date.ToString("yyyy-MM-dd"));
v_hash.Add("p4", e.GetFieldValue("数量1"));
v_hash.Add("p5", e.GetFieldValue("金额2"));
string v_str = "<a href='库存台账明细.aspx?%s'>%s<a>";
v_str = Common.FormatEh(v_str,
CommonWebUtil.GetUrlParams(v_hash), e.GetFieldValue("品名"));
e.DisplayText = v_str;
public static void GridExport(string fileName, ASPxGridViewExporter gridExporter)
XlsExportOptions ExportOptions = new XlsExportOptions
ExportMode = XlsExportMode.SingleFile,
SheetName = "Sheet1",
ShowGridLines = true,
TextExportMode = TextExportMode.Text
;
gridExporter.WriteXlsToResponse(fileName, true, ExportOptions);
protected void ASPxMenu1_ItemClick(object source, MenuItemEventArgs e)
switch (e.Item.Text)
case "查询":
LoadData();
return;
case "清空查询":
CommonWebUtil.清空查询(div查询);
return;
case "导出":
LoadData();
CommonWebUtil.GridExport("库存台账", ASPxGridViewExporter1);
return;
: DevExpress 学习:DevExpress 汉化(简单实用快速)
[转]: DevExpress 学习(2):DevExpress 汉化(简单、实用、快速)
devexpress(dxperience) 2011.1.8源代码
以上是关于devexpress girdview 转excel求助的主要内容,如果未能解决你的问题,请参考以下文章
DevExpress14.1版本,GridControl中的GridView自动生成并显示EditForm
请教DevExpress barEditItem 转 TextEdit问题