导出EXCEL

 #region 导出EXCEL
        /// <summary>
        /// 导出EXCEL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnF1_Click(object sender, EventArgs e)
        {
            if (this.gvRM_ALARM_INFO.RowCount > 0)
            {
              
                using (SaveFileDialog fd = new SaveFileDialog())
                {
                    fd.Title = "导出Excel文件";
                    fd.RestoreDirectory = true;
                    fd.Filter = "Excel文件|*.xls";
                    fd.FilterIndex = 1;
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        gvRM_ALARM_INFO.ExportToXls(fd.FileName);
                        MessageBox.Show("文件导出成功!", "导出提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("当前没有可以导出的记录!", "导出Excel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            this.operate_flag = "F1";
        }
        #endregion

 

posted @ 2014-03-28 15:37  SharkLock  阅读(207)  评论(0编辑  收藏  举报