예제 #1
0
        public void btnExportExcel_Click(object sender, EventArgs e)
        {
            string         localFilePath = "";
            SaveFileDialog sfd           = new SaveFileDialog();

            sfd.Filter           = "Excel Files(07版本 *.xlsx)|*.xlsx|(03版本 *.xls)|*.xls|所有文件(*.*)|*.*";
            sfd.FilterIndex      = 1;
            sfd.RestoreDirectory = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                localFilePath = sfd.FileName.ToString(); //获得文件路径
            }
            if (localFilePath == "")
            {
                MessageBox.Show("未选择Excel文件");
                return;
            }

            NopiExcel.TableToExcel(dgv, localFilePath);
        }
예제 #2
0
        public void ExpToExcel()
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                string         localFilePath = "";
                SaveFileDialog sfd           = new SaveFileDialog();
                sfd.Filter           = "Excel Files(07版本 *.xlsx)|*.xlsx|(03版本 *.xls)|*.xls|所有文件(*.*)|*.*";
                sfd.FilterIndex      = 1;
                sfd.RestoreDirectory = true;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    localFilePath = sfd.FileName.ToString(); //获得文件路径
                }
                if (localFilePath == "")
                {
                    MessageBox.Show("未选择Excel文件");
                    return;
                }

                NopiExcel.TableToExcel(dgv, localFilePath);
            }
        }