ExportExcel

本文链接:http://user.qzone.qq.com/108633744/blog/1219742370

public static void ExportExcel(DataGridView dgv, Form frm, string title)
        {
            //Excel导出
            if (dgv.RowCount == 0)
            {
                MessageBox.Show("没有数据要导出", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            Excel.ApplicationClass appExcel;
            Excel.Range selectRange;
            
            try
            {
                appExcel = new Excel.ApplicationClass();
                appExcel.Workbooks.Add(true);
                appExcel.Visible = true;
            }
            catch
            {
posted @ 2008-09-14 09:53  九边gis  阅读(548)  评论(0编辑  收藏  举报