Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            if (chkSelectNoneStudent.Checked)
            {
                saveFileDialog1.FileName = string.Format("匯出查詢未選課學生({0})", cboIdentity.SelectedItem.ToString());
            }
            else
            {
                saveFileDialog1.FileName = string.Format("匯出查詢已選課學生({0})", cboIdentity.SelectedItem.ToString());
            }

            saveFileDialog1.Filter = "Excel (*.xls)|*.xls";
            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DataGridViewExport export = new DataGridViewExport(dgvData);

            export.Save(saveFileDialog1.FileName);

            if (new CompleteForm().ShowDialog() == DialogResult.Yes)
            {
                System.Diagnostics.Process.Start(saveFileDialog1.FileName);
            }
        }
Ejemplo n.º 3
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);
            }
        }