Example #1
0
        void ButtonExcelReadClick(object sender, EventArgs e)
        {
            if (!CheckExcelRowColValid())
            {
                MessageBox.Show("please input excel row(1,2,3...) and col(A,B,C...)");
                return;
            }

            string cell     = this.textBoxExcelCol.Text + this.textBoxExcelRow.Text;
            string filename = Path.GetFileName(this.textBoxExcelPath.Text);

            ExcelUIA excel = new ExcelUIA(filename);
            string   value = "not found";
            bool     ret   = excel.GetValue(cell, ref value);

            this.textBoxExcelValue.Text = value;

            if (ret)
            {
                MessageBox.Show(cell + "读取成功: " + value);
            }

            excel.Close();
            excel = null;
        }
Example #2
0
        void ButtonExcelWriteClick(object sender, EventArgs e)
        {
            if (!CheckExcelRowColValid())
            {
                MessageBox.Show("please input excel row(1,2,3...) and col(A,B,C...)");
                return;
            }

            string cell     = this.textBoxExcelCol.Text + this.textBoxExcelRow.Text;
            string filename = Path.GetFileName(this.textBoxExcelPath.Text);

            ExcelUIA excel = new ExcelUIA(filename);

            if (excel.SetValue(cell, this.textBoxExcelValue.Text))
            {
                MessageBox.Show(cell + "设置成功");
            }

            excel.Close();
            excel = null;
        }