Example #1
0
        private void 导入CSVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (DialogExcelDataLoad.ShowDialog() == DialogResult.OK)
            {
                ConstantMethod.SaveDirectoryByFileDialog(DialogExcelDataLoad);

                string localFilePath = DialogExcelDataLoad.FileName;

                string FileExt = Path.GetExtension(localFilePath).ToLower();

                if (FileExt.Equals(Constant.CSVFileEX))
                {
                    UserDt = null;

                    UserDt = csvop.OpenCSV0(DialogExcelDataLoad.FileName);


                    if (UserDt != null && UserDt.Columns.Count > 3)
                    {
                        dgv.DataSource = UserDt;
                        showColName();
                    }
                    else
                    {
                        MessageBox.Show("加载文件错误!");
                    }
                }
                else
                {
                    MessageBox.Show("文件格式错误!");
                }
            }
        }