Esempio n. 1
0
        private void btnChoseExcel_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();
            DialogResult   result   = openFile.ShowDialog();

            if (result == DialogResult.OK)
            {
                string path = openFile.FileName;
                this.stuList = objImportData.GetStudentByExcel(path);

                this.dgvStudentList.DataSource = this.stuList;
            }
        }
Esempio n. 2
0
        private void 导入员工ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            DialogResult   result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string path   = dialog.FileName;
                var    sfList = ImportDataFromExcel.GetStudentByExcel(path);

                if (sfList.Count > 0)
                {
                    ImportDataFromExcel.Import(sfList);

                    MessageBox.Show("导入成功!");
                }
            }
        }
Esempio n. 3
0
        //从excel导入数据
        private void BtnChoseExcel_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile     = new OpenFileDialog();
            DialogResult   dialogResult = openFile.ShowDialog();
            string         filePath     = string.Empty;

            if (dialogResult == DialogResult.OK)
            {
                filePath = openFile.FileName;//获取Excel路径
            }
            try
            {
                this.studentList = fromExcel.GetStudentByExcel(filePath);
                this.dgvStudentList.DataSource = null;
                this.dgvStudentList.DataSource = studentList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示信息");
            }
        }