Example #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            string         strFile_jisuancanshu = "";
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = "D:\\开题\\shuju";
            //ofd.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx|所有文件|*.*";
            ofd.ValidateNames   = true;
            ofd.CheckPathExists = true;
            ofd.CheckFileExists = true;

            //strFileA_xishu = "D:\\开题\\shuju\\20120712_20m+\\1000\\2012-07-12-10_56_36.txt  ";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show("请选择数据文件");
                // return;
            }

            strFile_jisuancanshu = ofd.FileName;
            ps5000example.ExcelHelp excelhelp = new ExcelHelp();
            //MessageBox.Show("您当前选择数据为" + strFileName8.ToString());
            Jisuancanshu        = excelhelp.LoadDataFromExcel(strFile_jisuancanshu);
            JisuancanshuFor_1_3 = excelhelp.LoadDataFromExcel_sheel2(strFile_jisuancanshu);

            if (Jisuancanshu != null && JisuancanshuFor_1_3 != null)
            {
                MessageBox.Show("读取数据成功");
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string         strFileName8 = "";
            OpenFileDialog ofd          = new OpenFileDialog();

            ofd.InitialDirectory = "D:\\开题\\shuju";
            //ofd.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx|所有文件|*.*";
            ofd.ValidateNames   = true;
            ofd.CheckPathExists = true;
            ofd.CheckFileExists = true;

            //strFileName8 = "D:\\开题\\shuju\\20120712_20m+\\1000\\2012-07-12-10_56_36.txt  ";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show("请选择数据文件");
                // return;
            }

            strFileName8 = ofd.FileName;
            ps5000example.ExcelHelp excelhelp = new ExcelHelp();
            //MessageBox.Show("您当前选择数据为" + strFileName8.ToString());
            dt_for_cal = excelhelp.LoadDataFromExcel(strFileName8);
            if (dt_for_cal != null)
            {
                if (dataGridView1.DataSource != null)
                {
                    DataTable dt = (DataTable)dataGridView1.DataSource;
                    dt.Rows.Clear();
                    dataGridView1.DataSource = dt;
                }
                else
                {
                    dataGridView1.Rows.Clear();
                }
                data_fresh();
            }
            else
            {
                MessageBox.Show("读取数据失败");
            }
        }
Example #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            string         strFileA_xishu = "";
            OpenFileDialog ofd            = new OpenFileDialog();

            ofd.InitialDirectory = "D:\\开题\\shuju";
            //ofd.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx|所有文件|*.*";
            ofd.ValidateNames   = true;
            ofd.CheckPathExists = true;
            ofd.CheckFileExists = true;

            //strFileA_xishu = "D:\\开题\\shuju\\20120712_20m+\\1000\\2012-07-12-10_56_36.txt  ";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show("请选择数据文件");
                // return;
            }

            strFileA_xishu = ofd.FileName;
            ps5000example.ExcelHelp excelhelp = new ExcelHelp();
            //MessageBox.Show("您当前选择数据为" + strFileName8.ToString());
            A_xishu = excelhelp.LoadDataFromExcel(strFileA_xishu);
            try
            {
                dataGridView1.ColumnCount = 4;
                dataGridView1.Columns[3].HeaderCell.Value = "A加权系数";

                for (int i = 0; i < 31; i++)
                {
                    this.dataGridView1.Rows[i].Cells[3].Value = A_xishu.Rows[i][1].ToString();
                }
                this.dataGridView1.Columns[0].FillWeight = 60;
                this.dataGridView1.Columns[1].FillWeight = 60;
                MessageBox.Show("读取数据成功");
            }catch
            {
                MessageBox.Show("读取数据失败");
            }
        }