/// <summary> /// 导出Excel过程 /// </summary> /// <param name="grdList">数据表格</param> public static void ExportExcel(DevExpress.XtraGrid.Views.Grid.GridView grdList) { string fileName = ShowSaveFileDialog("Microsoft Excel Document", "Microsoft Excel|*.xls"); if (fileName != "") { grdList.ExportToXls(fileName); //DevExpress.XtraGrid.Export.GridViewExportLink gvlink; //using (DevExpress.XtraExport.ExportXlsProvider provider = new DevExpress.XtraExport.ExportXlsProvider(fileName)) //{ // gvlink = (DevExpress.XtraGrid.Export.GridViewExportLink)grdList.CreateExportLink(provider); // gvlink.ExportAll = true; // gvlink.ExpandAll = true; // gvlink.ExportDetails = true; // gvlink.ExportTo(true); Framework.Abstract.ExcelMsg.ExcelMsgInfo.Show("EXCEL文件导出", "表格数据已成功导出!", fileName); //Framework.Abstract.frmExcelMsg frm = new Framework.Abstract.frmExcelMsg(); //frm.ShowDialog(); //"Export listgrid data to excel file successful!" ,"File name:" // DevExpress.XtraEditors.XtraMessageBox.Show("表格数据已成功导出!" + "\r\n文件名:" + fileName, "", MessageBoxButtons.OK, MessageBoxIcon.Information); //OpenFile(fileName); //} } }
/// <summary> /// 导出Excel /// </summary> /// <param name="grdList">数据表格</param> public static void ExportExcelList(DevExpress.XtraGrid.Views.Grid.GridView grdList) { string fileName = ShowSaveFileDialog("Microsoft Excel Document", "Microsoft Excel|*.xls"); if (fileName != "") { grdList.ExportToXls(fileName); DevExpress.XtraEditors.XtraMessageBox.Show("表格数据已成功导出!" + "\r\n文件名:" + fileName, "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// hàm này cho phép xuất excel và lưu dữ liệu trong Release /// </summary> /// <param name="v_grv"> tên của gridview</param> /// <param name="name"> tên file mà bạn muốn xuất ra</param> public static void xuat_excel(DevExpress.XtraGrid.Views.Grid.GridView v_grv, string name) { name =name+ ".xls"; v_grv.SaveLayoutToXml("tempLayout.xml"); foreach (DevExpress.XtraGrid.Columns.GridColumn col in v_grv.Columns) { col.Visible = true; } v_grv.ExportToXls(name); v_grv.RestoreLayoutFromXml("tempLayout.xml"); }