Пример #1
0
 private void btnExcel_Click(object sender, EventArgs e)
 {
     try
     {
         saveFileDialog.Title            = "Save Grid to Excel";
         saveFileDialog.InitialDirectory = saveToExcelDirectory;
         saveFileDialog.Filter           = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
         saveFileDialog.FilterIndex      = 0;
         saveFileDialog.RestoreDirectory = true;
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             saveToExcelDirectory = System.IO.Path.GetDirectoryName(saveFileDialog.FileName);
             DevExpress.XtraPrinting.XlsExportOptions xlOptions =
                 new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value, true);
             //      new DevExpress.XtraPrinting.XlsExportOptions(true, true);
             gridViewXmitResult.ExportToXls(saveFileDialog.FileName, xlOptions);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("An error occurred while exporting the grid data to an MS Excel file." + Environment.NewLine +
                             "Error CNF-329 in " + FORM_NAME + ".btnExcel_Click(): " + ex.Message,
                             FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
        public void CreateFile(string path, FileType type)
        {
            try
            {
                switch (type)
                {
                case FileType.PDF:
                    this.urunGridControl.ExportToPdf(path);
                    break;

                case FileType.Excel:
                    DevExpress.XtraPrinting.XlsExportOptions opt = new DevExpress.XtraPrinting.XlsExportOptions();
                    opt.SheetName = "DATA";
                    this.urunGridControl.ExportToXls(path, opt);
                    break;

                case FileType.ExcelX:
                    this.urunGridControl.ExportToXlsx(path);
                    break;

                case FileType.Word:
                    this.urunGridControl.ExportToRtf(path);
                    break;
                }
            }
            catch (Exception ex)
            {
                Commons.Status(Commons.GetErrorCode("FUN", 2) + ex.Message);
            }
        }
Пример #3
0
 void firmaDisaAktarButton_Click(object sender, EventArgs e)
 {
     try
     {
         using (SaveFileDialog file = new SaveFileDialog())
         {
             file.Title = L.AktarilacakExcelDosyasi;
             Firma f = (this.firmaStokLookUpEdit.GetSelectedDataRow() as Firma);
             if (f != null)
             {
                 file.FileName = f.Adi + " - " + L.AlisFiyati + " - " + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
             }
             else
             {
                 file.FileName = L.AlisFiyati + " - " + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
             }
             file.Filter = "Excel (2003)|*.xls";
             switch (file.ShowDialog())
             {
             case System.Windows.Forms.DialogResult.OK:
             case System.Windows.Forms.DialogResult.Yes:
                 DevExpress.XtraPrinting.XlsExportOptions opt = new DevExpress.XtraPrinting.XlsExportOptions();
                 opt.SheetName = "DATA";
                 this.stokGridView.ExportToXls(file.FileName, opt);
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Commons.Status(Commons.GetErrorCode("FST", 12) + ex.Message);
     }
 }
Пример #4
0
        private void btn_Export_Click(object sender, EventArgs e)
        {
            SaveFileDialog mTempSaveDialog = new SaveFileDialog();

            mTempSaveDialog.Filter           = "Excel files (*xls)|*.xls| Excel files (*xlsx)|*.xlsx";
            mTempSaveDialog.RestoreDirectory = true;
            if (DialogResult.OK == mTempSaveDialog.ShowDialog() && null != mTempSaveDialog.FileName.Trim())
            {
                string mTempSavePath = mTempSaveDialog.FileName;
                if (mTempSavePath.Contains("xlsx"))    // 导出07及以上版本的文件
                {
                    DevExpress.XtraPrinting.XlsxExportOptions options = new DevExpress.XtraPrinting.XlsxExportOptions(DevExpress.XtraPrinting.TextExportMode.Value);
                    options.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Text;
                    options.ExportMode     = DevExpress.XtraPrinting.XlsxExportMode.SingleFile;
                    this.gridView_History.ExportToXlsx(mTempSaveDialog.FileName);
                }
                else if (mTempSavePath.Contains("xls"))  // 导出03版本的文件
                {
                    DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value);
                    options.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Text;
                    options.ExportMode     = DevExpress.XtraPrinting.XlsExportMode.SingleFile;
                    this.gridView_History.ExportToXls(mTempSaveDialog.FileName, options);
                }
            }
        }
Пример #5
0
        private void btnDcExcel_Click(object sender, EventArgs e)
        {
            SaveFileDialog sDialog = new SaveFileDialog();

            if (CommonInfo.CLng(this.cmbDeptID.EditValue) == -1)
            {
                sDialog.FileName = "编号:" + sID + "交通事故详情" + ".xls";
            }

            if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 1)
            {
                sDialog.FileName = "编号:" + sID + "交通事故痕迹检验详情" + ".xls";
            }
            if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 2)
            {
                sDialog.FileName = "编号:" + sID + "交通事故酒精检验详情" + ".xls";
            }
            if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 3)
            {
                sDialog.FileName = "编号:" + sID + "交通事故尸体检验详情" + ".xls";
            }

            if (sDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                grd.ExportToXls(sDialog.FileName, options);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #6
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            DataTable dt = gridControl1.DataSource as DataTable;

            if (dt != null && dt.Rows.Count > 0)
            {
                ;
            }
            else
            {
                XtraMessageBox.Show("请先点击分析按钮查询!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dtpStart.Focus();
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title  = "导出Excel";
            saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                //gridControl1.ExportToXls(saveFileDialog.FileName, options);
                gridControl1.ExportToExcelOld(saveFileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #7
0
        /// <summary>
        /// /导出EXCel 宜昌中心医院需求
        /// add by ywk  2012年9月3日 14:13:56
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ExprtExcel_Click(object sender, EventArgs e)
        {
            try
            {
                //gridControlList.ExportToXls(
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Title  = "导出Excel";
                saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
                DialogResult dialogResult = saveFileDialog.ShowDialog(this);
                if (dialogResult == DialogResult.OK)
                {
                    DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                    //gridViewCardList.ExportToXls(saveFileDialog.FileName);
                    //gridControlList.ExportToXls(saveFileDialog.FileName, true);
                    options.SheetName     = "会诊清单";
                    options.ShowGridLines = true;
                    string caption = gridViewList.ViewCaption;
                    gridViewList.ViewCaption = options.SheetName;
                    gridControlList.ExportToXls(saveFileDialog.FileName, options);
                    gridViewList.ViewCaption = caption;

                    m_App.CustomMessageBox.MessageShow("导出成功");
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show(1, ex);
            }
        }
Пример #8
0
 private void btnExportExcel_Click(object sender, EventArgs e)
 {
     if (this.stable.Rows.Count < 1)
     {
         MessageBox.Show("空数据,不转出EXCEL文件!");
     }
     else
     {
         this.saveFileDialog1.DefaultExt      = "xls";
         this.saveFileDialog1.FileName        = "Result.xls";
         this.saveFileDialog1.Filter          = "Excel文件|*.xls";
         this.saveFileDialog1.OverwritePrompt = false;
         this.saveFileDialog1.Title           = "保存";
         DialogResult dialogResult = this.saveFileDialog1.ShowDialog();
         if (dialogResult == DialogResult.OK)
         {
             string fileName = this.saveFileDialog1.FileName;
             if (!File.Exists(fileName))
             {
                 DevExpress.XtraPrinting.XlsExportOptions options =
                     new DevExpress.XtraPrinting.XlsExportOptions();
                 gridControl1.ExportToXls(fileName);
                 DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK,
                                                            MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("该文件已存在,返回!");
             }
         }
     }
 }
Пример #9
0
 /// <summary>
 /// 导出EXCEL。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnXlsExport_Click(object sender, EventArgs e)
 {
     btnQuery_Click(sender, e);
     DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
     options.ExportHyperlinks = false;
     this.exporter.WriteXlsToResponse("QualityProductData", true, options);
 }
Пример #10
0
        private void DevButtonImportExcel1_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Title  = "导出Excel";
                saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
                DialogResult dialogResult = saveFileDialog.ShowDialog(this);
                if (dialogResult == DialogResult.OK)
                {
                    DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                    options.SheetName     = "统计信息";
                    options.ShowGridLines = true;

                    string caption = gridControl1.MainView.ViewCaption;
                    gridControl1.MainView.ViewCaption = options.SheetName;
                    gridControl1.ExportToXls(saveFileDialog.FileName, options);
                    MessageBox.Show("导出成功");
                    gridControl1.MainView.ViewCaption = caption;
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show(1, ex);
            }
        }
Пример #11
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Title  = "导出Excel";
            fileDialog.Filter = "Excel文件t(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                if (tab1.SelectedIndex == 0)
                {
                    mainGrid1.ExportToXls(fileDialog.FileName);
                    DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (tab1.SelectedIndex == 1)
                {
                    mainGrid2.ExportToXls(fileDialog.FileName);
                    DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (tab1.SelectedIndex == 2)
                {
                    mainGrid3.ExportToXls(fileDialog.FileName);
                    DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #12
0
        private void frmExcelAktar_Load(object sender, EventArgs e)
        {
            try
            {
                sfdKaydet.Filter = "Excel Files |*.xls";

                if (sfdKaydet.ShowDialog() == DialogResult.OK)
                {
                    DevExpress.XtraPrinting.XlsExportOptions a = new DevExpress.XtraPrinting.XlsExportOptions();
                    a.ExportMode                = DevExpress.XtraPrinting.XlsExportMode.SingleFile;
                    a.ShowGridLines             = true;
                    a.TextExportMode            = DevExpress.XtraPrinting.TextExportMode.Value;
                    a.ExportHyperlinks          = true;
                    a.Suppress256ColumnsWarning = true;
                    a.Suppress65536RowsWarning  = true;

                    _GelenGrid.ExportToXls(sfdKaydet.FileName, a);
                    if (sfdKaydet.FileName != ".xls")
                    {
                        if (XtraMessageBox.Show("Kaydetme Başarılı.\nKaydedilen Dosya Açılsın mı?", "Servis Takip", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            System.Diagnostics.Process.Start(sfdKaydet.FileName);
                        }
                    }
                }
                this.Close();
            }
            catch (Exception hata)
            {
                XtraMessageBox.Show(hata.Message);
            }
        }
Пример #13
0
 //导出Excel
 private void barBtnExport_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         var dtExport = (DataTable)this.gcDataInfo.DataSource;
         if (dtExport == null || dtExport.Rows.Count < 1)
         {
             MessageBox.Show("当前没有数据可以操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         var dialogResult = saveFileDialog.ShowDialog(this);
         if (dialogResult == DialogResult.OK)
         {
             var options = new DevExpress.XtraPrinting.XlsExportOptions()
             {
                 TextExportMode = DevExpress.XtraPrinting.TextExportMode.Value, ExportMode = DevExpress.XtraPrinting.XlsExportMode.SingleFile
             };
             this.gcDataInfo.ExportToXls(saveFileDialog.FileName, options);
             if (MessageBox.Show("操作成功,是否打开文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
             {
                 System.Diagnostics.Process.Start(saveFileDialog.FileName);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("导出失败:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #14
0
 void urunDisaAktarButton_Click(object sender, EventArgs e)
 {
     try
     {
         using (SaveFileDialog file = new SaveFileDialog())
         {
             file.Title = L.AktarilacakExcelDosyasi;
             Kategori k = this.kategoriAktarimLookUpEdit.GetSelectedDataRow() as Kategori;
             if (k != null)
             {
                 file.FileName = k.Adi.Replace("/", "").Replace("\\", "") + " - " + L.AlisFiyati + " - " + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
             }
             else
             {
                 file.FileName = "ALL PRODUCTS " + L.AlisFiyati + " - " + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
             }
             file.Filter = "Excel (2003)|*.xls";
             switch (file.ShowDialog())
             {
             case System.Windows.Forms.DialogResult.OK:
             case System.Windows.Forms.DialogResult.Yes:
                 DevExpress.XtraPrinting.XlsExportOptions opt = new DevExpress.XtraPrinting.XlsExportOptions();
                 opt.SheetName = "DATA";
                 GridChange("EXCEL");
                 this.urunGridView.ExportToXls(file.FileName, opt);
                 GridChange("");
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Commons.Status(Commons.GetErrorCode("FUN", 9) + ex.Message);
     }
 }
Пример #15
0
 /// <summary>
 /// DevExpress控件通用导出Excel,支持多个控件同时导出在同一个Sheet表或者分不同工作薄
 /// eg:ExportToXlsx("test",true,"控件",gridControl1,gridControl2);
 /// 将gridControl1和gridControl2的数据一同导出到同一个文件不同的工作薄
 /// eg:ExportToXlsx("test",false,"",gridControl1,gridControl2);
 /// 将gridControl1和gridControl2的数据一同导出到同一个文件同一个的工作薄
 /// <param name="title">文件</param>
 /// <param name="isPageForEachLink">多个打印控件是否分多个工作薄显示</param>
 /// <param name="sheetName">工作薄名称</param>
 /// <param name="printables">控件集 eg:GridControl,PivotGridControl,TreeList,ChartControl...</param>
 public static void ExportToExcel(string FileName, bool isPageForEachLink, string sheetName, params DevExpress.XtraPrinting.IPrintable[] printables)
 {
     if (string.IsNullOrEmpty(FileName))
     {
         return;
     }
     using (DevExpress.XtraPrintingLinks.CompositeLink link = new DevExpress.XtraPrintingLinks.CompositeLink(new DevExpress.XtraPrinting.PrintingSystem()))
     {
         foreach (var item in printables)
         {
             var plink = new DevExpress.XtraPrinting.PrintableComponentLink()
             {
                 Component = item
             };
             link.Links.Add(plink);
         }
         if (isPageForEachLink)
         {
             link.CreatePageForEachLink();
         }
         if (string.IsNullOrEmpty(sheetName))
         {
             sheetName = "Sheet";
         }
         //默认工作薄名称
         try
         {
             if (FileName.LastIndexOf(".xlsx") >= FileName.Length - 5)
             {
                 DevExpress.XtraPrinting.XlsxExportOptions options = new DevExpress.XtraPrinting.XlsxExportOptions()
                 {
                     SheetName = sheetName
                 };
                 if (isPageForEachLink)
                 {
                     options.ExportMode = DevExpress.XtraPrinting.XlsxExportMode.SingleFilePageByPage;
                 }
                 link.ExportToXlsx(FileName, options);
             }
             else
             {
                 DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions()
                 {
                     SheetName = sheetName
                 };
                 if (isPageForEachLink)
                 {
                     options.ExportMode = DevExpress.XtraPrinting.XlsExportMode.SingleFile;
                 }
                 link.ExportToXls(FileName, options);
             }
         }
         catch (Exception ex)
         {
             DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message);
         }
     }
 }
Пример #16
0
        /// <summary>
        /// 导出文件,多种格式选择
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="reportName"></param>
        /// <param name="fullFileName"></param>
        public static void ExportGridToFile(DevExpress.XtraGrid.Views.Base.BaseView gridView, string reportName, string fullFileName = null)
        {
            string fileName = string.Empty;

            if (string.IsNullOrEmpty(fullFileName))
            {
                System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();
                dlg.DefaultExt   = ".xls";
                dlg.FileName     = reportName + "-" + DateTime.Now.ToString("yyyyMMddhhmmss");
                dlg.AddExtension = true;
                dlg.Filter       = "Excel2000-2003(*.xls)|*.xls|Excel2007以上(*.xlsx)|*.xlsx|PDF文件(*.pdf)|*.pdf|网页文件(*.html)|*.html|RTF文件(*.rtf)|*.rtf|文本文件(*.txt)|*.txt";
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    fileName = dlg.FileName;
                }
                else
                {
                    return;
                }
            }
            if (fileName == string.Empty)
            {
                return;
            }
            string extFileName = System.IO.Path.GetExtension(fileName).ToUpper();

            DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();

            switch (extFileName)
            {
            case ".XLSX":
                gridView.ExportToXlsx(fileName);
                break;

            case ".PDF":
                gridView.ExportToPdf(fileName);
                break;

            case ".HTML":
                gridView.ExportToHtml(fileName);
                break;

            case ".RTF":
                gridView.ExportToRtf(fileName);
                break;

            case ".TXT":
                gridView.ExportToText(fileName);
                break;

            default:
                gridView.ExportToXls(fileName);
                break;
            }
            OpenFile(fileName);
        }
Пример #17
0
        private void btnDcExcel_Click(object sender, EventArgs e)
        {
            SaveFileDialog sDialog = new SaveFileDialog();

            sDialog.FileName = "交通事故案情报表" + CommonInfo.CDate(this.dateEdit1.EditValue).ToString("yyyy-MM-dd") + "至" + CommonInfo.CDate(this.dateEdit2.EditValue).ToString("yyyy-MM-dd") + ".xls";
            if (sDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                grd.ExportToXls(sDialog.FileName, options);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #18
0
 public void ExportToXls()
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.Title = "导出Excel";
     saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
     DialogResult dialogResult = saveFileDialog.ShowDialog(this);
     if (dialogResult == DialogResult.OK)
     {
         DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
         gridControl1.ExportToXls(saveFileDialog.FileName, options);
         DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #19
0
        private void btn_Export_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Title  = DateTime.Now.ToString("yyyy-MM-dd");
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gridView1.ExportToXls(fileDialog.FileName);
                //DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        //导出表
        private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title  = "导出Excel";
            saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                //MainGridControl.ExportToXls(saveFileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示");
            }
        }
Пример #21
0
        private void btn导出_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Title  = "导出Excel";
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gridControl请购计划列表.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #22
0
        //导出查询结果  excel
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Title  = "历史数据统计";
            fileDialog.Filter = "Excel文件(#.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gcVehicleInfo.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #23
0
        private void btExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //TODO: (WXC) 导出Excel文件
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title  = "导出Excel";
            saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gcConsumerGrid.ExportToExcelOld(saveFileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #24
0
        private void export_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title    = "导出Excel";
            saveFileDialog.Filter   = "Excel文件(*.xls)|*.xls";
            saveFileDialog.FileName = name[TimeSelect.SelectedIndex];
            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gridControl1.ExportToXls(saveFileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #25
0
 private void 导出报表ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (gridView4.RowCount > 0)
     {
         SaveFileDialog fileDialog = new SaveFileDialog();
         fileDialog.Title  = "导出Excel";
         fileDialog.Filter = "Excel文件(*.xls)|*.xls";
         DialogResult dialogResult = fileDialog.ShowDialog(this);
         if (dialogResult == DialogResult.OK)
         {
             DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
             gridControl4.ExportToXls(fileDialog.FileName);
             DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Пример #26
0
        /// <summary>
        /// 病历评分列表增加导出功能
        /// add by ywk 2012年6月12日 14:32:28
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title  = "导出";
            saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gridControl1.ExportToXls(saveFileDialog.FileName, true);

                m_app.CustomMessageBox.MessageShow("导出成功!");
            }
        }
        public override void Export()
        {
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Title    = "导出Excel";
            fileDialog.Filter   = "Excel文件(*.xls)|*.xls";
            fileDialog.FileName = "资产退库信息";
            DialogResult dialogResult = fileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gcData.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #28
0
        /// <summary>
        /// 将数据导出Excel
        /// </summary>
        private void ExportDataGridViewToExcel(GridView dataGridView)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Title  = "导出Excel";
            fileDialog.Filter = "Excel文件t(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                mainGrid.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                StartProcess(fileDialog.FileName);
            }
        }
Пример #29
0
        private void Export(string level)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title    = "导出Excel";
            saveFileDialog.Filter   = "Excel文件(*.xls)|*.xls";
            saveFileDialog.FileName = level + "统计信息";
            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                topClass.ExportToXls(saveFileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #30
0
        private void 导出ExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title  = "导出Excel";
            saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = saveFileDialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gridControl1.ExportToXls(saveFileDialog.FileName, options);
                //gridControl_liangti.ExportToExcelOld(saveFileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #31
0
        private void frmExceleAktar_Load(object sender, EventArgs e)
        {
            try
              {
            sfdKaydet.Filter = "Excel Dosyası |*.xls";

            if (sfdKaydet.ShowDialog() == DialogResult.OK)
            {
              DevExpress.XtraPrinting.XlsExportOptions a = new DevExpress.XtraPrinting.XlsExportOptions();
              //excel içinde tek sayfaya mı yazsın?
              a.ExportMode = DevExpress.XtraPrinting.XlsExportMode.SingleFile;
              //grid teki çizikler, excel de gösterilsin mi?
              a.ShowGridLines = true;
              //grid deki hangi bilgiler excel e gönderilsin. value-> gizli olan bilgiler de gitsin.
              a.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Value;
              //grid deki http linkleri excel e aktarılsın mı?
              a.ExportHyperlinks = true;
              //excel in satır ve kolon satır sayısı hataları oluşursa, sana haber vereyim mi ?
              a.Suppress256ColumnsWarning = true;
              a.Suppress65536RowsWarning = true;

              //grid görünümünü seçilen excel dosyasına, belirtilen özelliklerle birlikte kaydet.
              _gelenGrid.ExportToXls(sfdKaydet.FileName, a);

              if (sfdKaydet.FileName != ".xls")
            if (XtraMessageBox.Show("Kaydetme işlemi başarılı.\nDosya Açılsın mı?", "Bilişim ERP", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes)
              System.Diagnostics.Process.Start(sfdKaydet.FileName);
            }
            this.Close();
              }
              catch (Exception hata)
              {

            throw new Exception(hata.Message);
              }
        }
Пример #32
0
 private void export_Click(object sender, EventArgs e)
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.Title = "导出Excel";
     saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
     saveFileDialog.FileName = name[TimeSelect.SelectedIndex];
     DialogResult dialogResult = saveFileDialog.ShowDialog(this);
     if (dialogResult == DialogResult.OK)
     {
         DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
         gridControl1.ExportToXls(saveFileDialog.FileName);
         DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #33
0
 private void saveToExcel(GridView AGridView)
 {
     try
     {
         saveFileDialog.Title = "Save Grid to Excel";
         saveFileDialog.InitialDirectory = saveToExcelDirectory;
         saveFileDialog.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
         saveFileDialog.FilterIndex = 0;
         saveFileDialog.RestoreDirectory = true;
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             saveToExcelDirectory = System.IO.Path.GetDirectoryName(saveFileDialog.FileName);
             DevExpress.XtraPrinting.XlsExportOptions xlOptions =
             new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value, true);
             AGridView.ExportToXls(saveFileDialog.FileName, xlOptions);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("An error occurred while saving the " + AGridView.Name + " grid to MS Excel format." + Environment.NewLine +
                "Error CNF-040 in " + FORM_NAME + ".saveToExcel(): " + ex.Message,
              MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #34
0
        private void bbLoadSummaryIntoExcel_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                string fileName = Path.Combine(appDocumentsDir, "~SummaryData.xls");

                DevExpress.XtraPrinting.XlsExportOptions xlOptions =
                   new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value, true);

                gridViewSummary.ExportToXls(@fileName, xlOptions);

                Process process = new Process();
                process.StartInfo.FileName = @fileName;
                process.StartInfo.UseShellExecute = true;
                process.Start();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while exporting the Summary grid to MS Excel format." + Environment.NewLine +
                       "Error CNF-039 in " + FORM_NAME + ".bbLoadSummaryIntoExcel_ItemClick(): " + ex.Message,
                     MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #35
0
 private void btnExcel_Click(object sender, EventArgs e)
 {
     try
     {
         saveFileDialog.Title = "Save Grid to Excel";
         saveFileDialog.InitialDirectory = saveToExcelDirectory;
         saveFileDialog.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
         saveFileDialog.FilterIndex = 0;
         saveFileDialog.RestoreDirectory = true;
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             saveToExcelDirectory = System.IO.Path.GetDirectoryName(saveFileDialog.FileName);
             DevExpress.XtraPrinting.XlsExportOptions xlOptions =
                 new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value, true);
             //      new DevExpress.XtraPrinting.XlsExportOptions(true, true);
             gridViewXmitResult.ExportToXls(saveFileDialog.FileName, xlOptions);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("An error occurred while exporting the grid data to an MS Excel file." + Environment.NewLine +
                "Error CNF-329 in " + FORM_NAME + ".btnExcel_Click(): " + ex.Message,
              FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #36
0
        private static void OnExportToExcelClick(object sender, EventArgs e)
        {
            DXMenuItem item = sender as DXMenuItem;
            RowInfo info = item.Tag as RowInfo;
            var exportType = info.ExportType;
            SaveFileDialog dialog1 = new SaveFileDialog();
            if (exportType == ViewExportType.Excel2003) {
                dialog1.Filter = "Excel Workbook (*.xls)|*.xls";
            } else if (exportType == ViewExportType.Excel2007) {
                dialog1.Filter = "Excel Workbook (*.xslx)|*.xlsx";
            } else if (exportType == ViewExportType.CSV) {
                dialog1.Filter = "CSV (Comma Delimited) (*.csv)|*.csv";
            }

            dialog1.Title = "Save As";
            dialog1.CheckPathExists = true;
            dialog1.CheckFileExists = false;
            if (dialog1.ShowDialog() == DialogResult.OK) {
                if (dialog1.FileName != "") {
                    if (dialog1.FilterIndex == 1) {
                        info.View.OptionsPrint.AutoWidth = false;
                        info.View.BestFitColumns();

                        FileStream fs = (FileStream)dialog1.OpenFile();
                        if (exportType == ViewExportType.CSV) {
                            DevExpress.XtraPrinting.CsvExportOptions opts = new DevExpress.XtraPrinting.CsvExportOptions();
                            info.View.Export(DevExpress.XtraPrinting.ExportTarget.Csv, fs, opts);
                        } else if (exportType == ViewExportType.Excel2007) {
                            DevExpress.XtraPrinting.XlsxExportOptions opts = new DevExpress.XtraPrinting.XlsxExportOptions();
                            opts.ExportMode = DevExpress.XtraPrinting.XlsxExportMode.SingleFile;
                            opts.SheetName = "Sheet1";
                            info.View.GridControl.ExportToXlsx(fs, opts);
                        } else if (exportType == ViewExportType.Excel2003) {
                            DevExpress.XtraPrinting.XlsExportOptions opts = new DevExpress.XtraPrinting.XlsExportOptions();
                            opts.ExportMode = DevExpress.XtraPrinting.XlsExportMode.SingleFile;
                            opts.SheetName = "Sheet1";
                            info.View.GridControl.ExportToXls(fs, opts);
                        }
                        fs.Close();
                    }

                }
            }
        }
Пример #37
0
 private void Export(string level)
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.Title = "导出Excel";
     saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
     saveFileDialog.FileName = level + "统计信息";
     DialogResult dialogResult = saveFileDialog.ShowDialog(this);
     if (dialogResult == DialogResult.OK)
     {
         DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
         topClass.ExportToXls(saveFileDialog.FileName);
         DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #38
0
 private void MyExportExcute(object obj)
 {            
     SaveFileDialog fileDialog = new SaveFileDialog();
     fileDialog.Title = "导出Excel";
     fileDialog.Filter = "Excel文件(*.xls)|*.xls";
     DialogResult dialogResult = fileDialog.ShowDialog(this);
     if (dialogResult == DialogResult.OK)
     {
         DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
         grdMain.ExportToXls(fileDialog.FileName);
         DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }            
 }