VS2010中,呼叫SaveFileDialog 工具並結合DEV控制元件之GridControl匯出到Excel

阿霂發表於2015-01-04


private void btnToXls_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();
                gridControl1.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("儲存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }     

相關文章