Exemplo n.º 1
0
        private void btn_export_Click(object sender, EventArgs e)
        {
            string path      = "";
            bool   overWrite = true;

            if (dataGridView1.Rows.Count == 0)
            {
                return;
            }

            comn = new Common.Common();

            saveFileDialog1.Filter = "Excel File|*.xls";
            saveFileDialog1.Title  = "数据导出";
            //this.saveFileDialog1.FileName = txtKhmc.Text.Trim() + "印刷清单";
            if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                path = saveFileDialog1.FileName;
                DataGridViewExport.ExportToExcel(dataGridView1, path, "s", overWrite);
            }

            DialogResult result = MessageBox.Show("是否打开Excel文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            if (DataGridViewExport.IsExistsExcel())
            {
                DataGridViewExport.OpenExcel(path);
            }
        }
Exemplo n.º 2
0
        private void bt_print_Click(object sender, EventArgs e)
        {
            //RdlcPrintNew rdlcprint = new RdlcPrintNew();
            //rdlcprint.Run(reportView.LocalReport, "单据打印", false, "A4");

            //DataGridViewExport.DataGridviewShowToExcel(dgv_tjxm,false);

            string path      = "";
            bool   overWrite = true;

            if (dgv_tjxm.Rows.Count == 0)
            {
                return;
            }

            Common.Common comn = new Common.Common();

            saveFileDialog1.Filter = "Excel File|*.xls";
            saveFileDialog1.Title  = "数据导出";

            if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                path = saveFileDialog1.FileName;
                DataGridViewExport.ExportToExcel(dgv_tjxm, path, "s", overWrite);
            }

            DialogResult result = MessageBox.Show("是否打开Excel文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            if (DataGridViewExport.IsExistsExcel())
            {
                DataGridViewExport.OpenExcel(path);
            }
        }