Esempio n. 1
0
        private void ExportRegister_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            GridListEditor listEditor = ((DevExpress.ExpressApp.ListView)View).Editor as GridListEditor;
            Type           TypeObject = View.ObjectTypeInfo.Type;
            string         strObj     = "";

            foreach (BaseObject obj in View.SelectedObjects)
            {
                strObj = (strObj == "" ? string.Format("Oid='{0}'", obj.Oid) : string.Format("{0} or Oid='{1}'", strObj, obj.Oid));
            }
            if (strObj != "")
            {
                if (listEditor != null)
                {
                    GridView gv = (listEditor.Grid as GridControl).MainView as GridView;
                    using (SaveFileDialog sfd = new SaveFileDialog())
                    {
                        sfd.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*";
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            XlsExportOptions xlsExportOptions = new DevExpress.XtraPrinting.XlsExportOptions();
                            xlsExportOptions.SheetName      = View.Caption.Replace(" ", "");
                            xlsExportOptions.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Value;
                            xlsExportOptions.ShowGridLines  = true;
                            gv.GridControl.DataSource       = new XPCollection(View.ObjectSpace.Session, TypeObject,
                                                                               CriteriaOperator.Parse(strObj));

                            gv.ExportToXls(sfd.FileName, xlsExportOptions);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 导出Excel  2013-3-6 by tj
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_export_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 = gridControlMedicalRecord.MainView.ViewCaption;
                    gridControlMedicalRecord.MainView.ViewCaption = options.SheetName;
                    gridControlMedicalRecord.ExportToXls(saveFileDialog.FileName, options);
                    MessageBox.Show("导出成功");
                    gridControlMedicalRecord.MainView.ViewCaption = caption;
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show(1, ex);
            }
        }
        private void ExportRegister_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            GridListEditor listEditor = ((DevExpress.ExpressApp.ListView)View).Editor as GridListEditor;
            Type TypeObject = View.ObjectTypeInfo.Type;
            string strObj="";
            foreach (BaseObject obj in View.SelectedObjects)
            {
                strObj = (strObj =="" ? string.Format("Oid='{0}'", obj.Oid) : string.Format("{0} or Oid='{1}'", strObj, obj.Oid));
            }
            if (strObj != "")
            {
                if (listEditor != null)
                {
                    GridView gv = (listEditor.Grid as GridControl).MainView as GridView;
                    using (SaveFileDialog sfd = new SaveFileDialog())
                    {
                        sfd.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*";
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            XlsExportOptions xlsExportOptions = new DevExpress.XtraPrinting.XlsExportOptions();
                            xlsExportOptions.SheetName = View.Caption.Replace(" ", "");
                            xlsExportOptions.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Value;
                            xlsExportOptions.ShowGridLines = true;
                            gv.GridControl.DataSource = new XPCollection(View.ObjectSpace.Session, TypeObject,
                              CriteriaOperator.Parse(strObj));

                            gv.ExportToXls(sfd.FileName, xlsExportOptions);
                        }
                    }

                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 导出Excel的操作
        /// </summary>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (!HasFunction("User/Set/UserExport"))
            {
                MessageDxUtil.ShowError(Const.NoAuthMsg);
                return;
            }

            string file = FileDialogHelper.SaveExcel(string.Format("{0}.xls", moduleName));

            if (!string.IsNullOrEmpty(file))
            {
                try
                {
                    DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value);
                    options.TextExportMode = TextExportMode.Text;//设置导出模式为文本
                    winGridViewPager1.gridView1.OptionsPrint.AutoWidth = false;
                    winGridViewPager1.gridView1.ExportToXls(file, options);

                    if (MessageDxUtil.ShowYesNoAndTips("导出成功,是否打开文件?") == System.Windows.Forms.DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start(file);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmUser));
                    MessageDxUtil.ShowError(ex.Message);
                }
            }
        }
        //EXCEL'E AKTARMA
        private void btnExcel_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = isim + " alıcısına ait fatura (" + DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year + ")";
            saveFileDialog1.Filter   = "XLS Dosyaları (*.xls)|*.xls";

            saveFileDialog1.InitialDirectory = "c:";

            //eğer saveFileDiaolog1 açıldığında Evet’e tıklanırsa

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions _Options = new DevExpress.XtraPrinting.XlsExportOptions();

                _Options.SheetName = isim + " alıcısına ait fatura (" + DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year + ")";

                gridFaturaDetay.ExportToXls(saveFileDialog1.FileName, _Options);

                if (MessageBox.Show("Aktarılan dosyayı şimdi görmek ister misiniz?", "Excel dosyası", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    //Kaydedilen Excel Dosyasını açar.

                    System.Diagnostics.Process.Start(saveFileDialog1.FileName);
                }
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 数据导出到Excel
 /// </summary>
 /// <param name="paramGridView">要操作的GridView控件</param>
 /// <param name="paramFilePath">导出文件路径</param>
 private static void ExportToExcel(DevExpress.XtraGrid.Views.Grid.GridView paramGridView, string paramFilePath)
 {
     DevExpress.XtraPrinting.XlsExportOptions myXlsExportOptions = new DevExpress.XtraPrinting.XlsExportOptions();
     myXlsExportOptions.ExportHyperlinks = true;
     myXlsExportOptions.SheetName        = "餐饮管理系统";
     myXlsExportOptions.ShowGridLines    = true;
     myXlsExportOptions.TextExportMode   = DevExpress.XtraPrinting.TextExportMode.Value;
     paramGridView.ExportToXls(paramFilePath, myXlsExportOptions);
 }
Esempio n. 7
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();
                mainGrid.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 8
0
        public void ExportToExcel(BaseView exportView, string sName)
        {
            //string fileName = this.ShowSaveFileDialog(sName);
            string fileName = "c:/" + sName + ".xls";

            if (!string.IsNullOrEmpty(fileName))
            {
                DevExpress.XtraPrinting.XlsExportOptions xlsExportOptions = new DevExpress.XtraPrinting.XlsExportOptions();
                //xlsExportOptions.TextExportMode = TextExportMode.Text;
                xlsExportOptions.TextExportMode = TextExportMode.Value;
                System.Windows.Forms.Cursor currentCursor = System.Windows.Forms.Cursor.Current;
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                exportView.ExportToXls(fileName, xlsExportOptions);
                System.Windows.Forms.Cursor.Current = currentCursor;
            }
        }
Esempio n. 9
0
        private void ExportDetail()
        {
            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();
                detailGrid.ExportToXls(fileDialog.FileName);

                if (System.IO.File.Exists(fileDialog.FileName))
                {
                    System.Diagnostics.Process.Start(fileDialog.FileName); //保存v
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            try
            {
                Log.Info(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---START");

                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter   = "电子表格文件 (*.xls)|*.xls";
                saveFileDialog.FileName = "导出文件.xls";
                var dialogResult = saveFileDialog.ShowDialog();
                if (dialogResult == DialogResult.Cancel)
                {
                    return;
                }
                string fileName = saveFileDialog.FileName;
                if (!string.IsNullOrEmpty(fileName))
                {
                    try
                    {
                        DevExpress.XtraPrinting.XlsExportOptions __options = new DevExpress.XtraPrinting.XlsExportOptions();
                        __options.TextExportMode           = TextExportMode.Value;
                        __options.ExportMode               = DevExpress.XtraPrinting.XlsExportMode.SingleFile;
                        __options.ShowGridLines            = true;
                        gvList.OptionsPrint.UsePrintStyles = true;
                        gcList.ExportToXls(fileName, __options);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("文件正在使用!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(this.GetType() + "->" + ApplicationCommon.GetMethodName() + "---FAILED", ex);
                throw ex;
            }
        }
Esempio n. 11
0
 public void Excel()
 {
     try
     {
         nPrint = true;
         SaveFix();
         SaveFileDialog fileDialog = new SaveFileDialog();
         fileDialog.Title    = "导出Excel";
         fileDialog.Filter   = "Excel文件(*.xlsx)|*.xlsx";
         fileDialog.FileName = this.Text;
         DialogResult dialogResult = fileDialog.ShowDialog(this);
         if (dialogResult == DialogResult.OK)
         {
             DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
             this.gridControl1.ExportToXlsx(fileDialog.FileName);
             DevExpress.XtraEditors.XtraMessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         nPrint = false;;
     }
     finally
     {
         ClearFix();
     }
 }
        private void ExportRegister_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            ASPxGridListEditor listEditor = ((ListView)View).Editor as ASPxGridListEditor;
            Type TypeObject = View.ObjectTypeInfo.Type;
            string strObj="";
            int countobj = 0;

            if (View.ObjectTypeInfo.Type == typeof(ReportData))
            {
                foreach (ReportData obj in View.SelectedObjects)
                {
                    strObj = (strObj == "" ? string.Format("ReportName='{0}'", obj.ReportName) : string.Format("{0} or ReportName='{1}'", strObj, obj.ReportName));
                    countobj++;
                }
            }
            else
            {
                foreach (BaseObject obj in View.SelectedObjects)
                {
                    strObj = (strObj == "" ? string.Format("Oid='{0}'", obj.Oid) : string.Format("{0} or Oid='{1}'", strObj, obj.Oid));
                    countobj++;
                }
            }
            if (countobj > 2000)
                throw new UserFriendlyException(string.Format("Không thể export dữ liệu nhiều hơn 2000 dòng. Bạn đã chọn {0} dòng!!", countobj));
            if (strObj != "")
            {
                if (listEditor != null)
                {
                    ASPxGridView gv = listEditor.Grid;
                    using (ASPxGridViewExporter gridViewExporter = new ASPxGridViewExporter())
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            //gridViewExporter.WriteXlsToResponse();
                            gridViewExporter.GridViewID = gv.ID;
                            gridViewExporter.Page = gv.Page;
                            gv.Parent.Controls.Add(gridViewExporter);
                            gv.BeginUpdate();
                            gv.DataSource = new XPCollection(View.ObjectSpace.Session, TypeObject,
                                CriteriaOperator.Parse(strObj));
                            gv.DataBind();
                            gv.EndUpdate();
                            gridViewExporter.DataBind();

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

                            xlsExportOptions.SheetName = View.Caption.Replace(" ", "");

                            xlsExportOptions.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Value;
                            xlsExportOptions.ShowGridLines = true;

                            gridViewExporter.WriteXls(stream, xlsExportOptions);
                            byte[] buffer = stream.GetBuffer();
                            string contentType = "application/ms-excel";
                            string contentDisposition = "attachment; filename=Export_Result.xls";
                            HttpContext.Current.Response.Clear();
                            HttpContext.Current.Response.Buffer = false;
                            HttpContext.Current.Response.AppendHeader("Content-Type", contentType);
                            HttpContext.Current.Response.AppendHeader("Content-Transfer-Encoding", "binary");
                            HttpContext.Current.Response.AppendHeader("Content-Disposition", contentDisposition);
                            HttpContext.Current.Response.BinaryWrite(buffer);
                            HttpContext.Current.Response.End();
                        }
                    }

                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// DevExpress控件通用导出Excel,支持多个控件同时导出在同一个Sheet表或者分不同工作薄
        /// eg:ExportToXlsx("test",true,"控件",gridControl1,gridControl2);
        /// 将gridControl1和gridControl2的数据一同导出到同一个文件不同的工作薄
        /// eg:ExportToXlsx("test",false,"",gridControl1,gridControl2);
        /// 将gridControl1和gridControl2的数据一同导出到同一个文件同一个的工作薄
        /// <param name="FileName">Excel路径</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)
        {
            // SaveFileDialog saveFileDialog = new SaveFileDialog()
            // {
            //     FileName = title,
            //     Title = "导出Excel",
            //     Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls"
            // };
            // DialogResult dialogResult = saveFileDialog.ShowDialog();
            // if (dialogResult == DialogResult.Cancel)
            //     return;
            // string FileName = saveFileDialog.FileName;

            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) //15.1 的Xls不支持这个功能,15.2未知
            {
                link.CreatePageForEachLink();
            }
            //默认工作薄名称
            if (string.IsNullOrEmpty(sheetName))
            {
                sheetName = "Sheet";
            }
            try
            {
                int count = 1;
                //在重复名称后加(序号)
                while (System.IO.File.Exists(FileName))
                {
                    if (FileName.Contains(")."))
                    {
                        int start = FileName.LastIndexOf("(");
                        int end   = FileName.LastIndexOf(").") - FileName.LastIndexOf("(") + 2;
                        FileName = FileName.Replace(FileName.Substring(start, end), string.Format("({0}).", count));
                    }
                    else
                    {
                        FileName = FileName.Replace(".", string.Format("({0}).", count));
                    }

                    count++;
                }

                if (FileName.LastIndexOf(".xlsx") >= FileName.Length - 5)
                {
                    DevExpress.XtraPrinting.XlsxExportOptions options =
                        new DevExpress.XtraPrinting.XlsxExportOptions(TextExportMode.Value, true, false, true)
                    {
                        SheetName = sheetName
                    };
                    if (isPageForEachLink)
                    {
                        options.ExportMode = DevExpress.XtraPrinting.XlsxExportMode.SingleFilePageByPage;
                    }
                    link.ExportToXlsx(FileName, options);
                }
                else
                {
                    DevExpress.XtraPrinting.XlsExportOptions options =
                        new DevExpress.XtraPrinting.XlsExportOptions(TextExportMode.Value, true, false, true)
                    {
                        SheetName = sheetName
                    };
                    if (isPageForEachLink) //15.Xls没有这个属性,15.2未知
                    {
                        options.ExportMode = DevExpress.XtraPrinting.XlsExportMode.SingleFilePageByPage;
                    }
                    link.ExportToXls(FileName, options);
                }

                if (DevExpress.XtraEditors.XtraMessageBox.Show("保存成功,是否打开文件?", "提示", MessageBoxButtons.YesNo,
                                                               MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(FileName); //打开指定路径下的文件
                }
            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message);
            }
        }
Esempio n. 14
0
            public void Export(ViewExportType 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) {
                            gridView1.OptionsPrint.AutoWidth = false;
                            gridView1.BestFitColumns();

                            FileStream fs = (FileStream)dialog1.OpenFile();
                            if (exportType == ViewExportType.CSV) {
                                DevExpress.XtraPrinting.CsvExportOptions opts = new DevExpress.XtraPrinting.CsvExportOptions();
                                gridView1.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";
                                gridControl1.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";
                                gridControl1.ExportToXls(fs, opts);
                            }
                            fs.Close();
                        }
                    }
                }
            }
Esempio n. 15
0
        /// <summary>
        /// 匯出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void ToExcelButton_Click(object sender, EventArgs e)
        {
            base.ToExcelButton_Click(sender, e);
            if (tabControl1.SelectedIndex == 0)
            {
                if (gridView1.RowCount <= 0)
                {
                    MessageBox.Show("無內容,請重新查詢", "取消儲存");
                    return;
                }
            }
            else
            {
                if (gridView3.RowCount <= 0)
                {
                    MessageBox.Show("無內容,請重新查詢", "取消儲存");
                    return;
                }
            }
            SaveFileDialog OFD = new SaveFileDialog();

            OFD.InitialDirectory = "D:\\";
            OFD.RestoreDirectory = true;
            OFD.Title            = "儲存檔案";
            OFD.DefaultExt       = "xls";
            OFD.Filter           = "Microsoft Office Excel 活頁簿 (*.xls)|*.xls";

            GridControl[] grids;

            if (tabControl1.SelectedIndex == 0)
            {
                //合併兩個gridcontrol到同一個報表
                grids = new GridControl[] { gridControl1 };
            }
            else
            {
                grids = new GridControl[] { gridControl3 };
            }

            OFD.FileName = FileName_OutPutExcel;
            DialogResult chooseOutPut = OFD.ShowDialog();

            if (chooseOutPut == DialogResult.Cancel)
            {
                return;
            }

            //gridview排版
            gridView1.OptionsView.ColumnAutoWidth = false;
            gridView1.OptionsPrint.AutoWidth      = false;
            gridView1.BestFitColumns();
            gridView2.OptionsView.ColumnAutoWidth = false;
            gridView2.OptionsPrint.AutoWidth      = false;
            gridView2.BestFitColumns();
            gridView3.OptionsView.ColumnAutoWidth = false;
            gridView3.OptionsPrint.AutoWidth      = false;
            gridView3.BestFitColumns();
            gridView1.AppearancePrint.Row.Font            = new Font("Arial Unicode MS", 12);
            gridView1.AppearancePrint.Row.Options.UseFont = true;
            gridView2.AppearancePrint.Row.Font            = new Font("Arial Unicode MS", 12);
            gridView2.AppearancePrint.Row.Options.UseFont = true;
            gridView3.AppearancePrint.Row.Font            = new Font("Arial Unicode MS", 12);
            gridView3.AppearancePrint.Row.Options.UseFont = true;

            PrintingSystem ps            = new PrintingSystem();
            CompositeLink  compositeLink = new CompositeLink();

            compositeLink.PrintingSystem = ps;

            foreach (GridControl gc in grids)
            {
                PrintableComponentLink link = new PrintableComponentLink();
                link.Component = gc;

                compositeLink.Links.Add(link);
            }
            compositeLink.CreateDocument();

            //準備輸出
            DevExpress.XtraPrinting.XlsExportOptions XEO = new DevExpress.XtraPrinting.XlsExportOptions();
            XEO.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Text;
            XEO.ExportMode     = XlsExportMode.SingleFile;
            XEO.SheetName      = FileName_OutPutExcel;

            DevExpress.XtraPrinting.PdfExportOptions PEO = new PdfExportOptions();
            //PEO.PasswordSecurityOptions.OpenPassword = "******";

            #region 檢查檔案是否能寫入
            bool IsFileLocked = false;
            if (File.Exists(OFD.FileName))
            {
                FileInfo   filepath = new FileInfo(OFD.FileName);
                FileStream steam    = null;
                try
                {
                    steam = filepath.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
                }
                catch (IOException e1)
                {
                    IsFileLocked = true;
                }
                finally
                {
                    if (steam != null)
                    {
                        steam.Close();
                    }
                }
            }
            #endregion
            if (IsFileLocked)
            {
                MessageBox.Show("檔案被鎖定,請檢查是否有其他程式正在開啟", "匯出失敗");
                return;
            }
            compositeLink.ExportToXls(OFD.FileName, XEO);
            //gridView1.ExportToXls(OFD.FileName, XEO);
            MessageBox.Show("檔案匯出至 " + OFD.FileName + " 完畢", "匯出成功");

            //gridview排版
            gridView1.OptionsView.ColumnAutoWidth = true;
            gridView1.OptionsPrint.AutoWidth      = true;
            gridView1.BestFitColumns();
            gridView2.OptionsView.ColumnAutoWidth = true;
            gridView2.OptionsPrint.AutoWidth      = true;
            gridView2.BestFitColumns();
            gridView3.OptionsView.ColumnAutoWidth = true;
            gridView3.OptionsPrint.AutoWidth      = true;
            gridView3.BestFitColumns();
        }