private void toolStripButton2_Click(object sender, EventArgs e) { //显示excel数据 livinvoice.Items.Clear(); DataTable dta = dsExcelFile.GetRecord("select * from [" + cbbSheets.Text + "] ").Tables[0]; dta.Columns[0].ColumnName = "invo"; dta.Columns[16].ColumnName = "custname"; dta.Columns[32].ColumnName = "count"; dta.Columns[34].ColumnName = "tax"; DataView dv = dta.DefaultView; DataTable dt = dv.ToTable(true, new string[] { "invo", "custname", "count", "tax" }); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][0].ToString().Trim() != "") { ListViewItem li = new ListViewItem(); li.Text = dt.Rows[i][0].ToString(); li.SubItems.Add(dt.Rows[i][1].ToString()); li.SubItems.Add(dt.Rows[i][2].ToString()); li.SubItems.Add(dt.Rows[i][3].ToString()); livinvoice.Items.Add(li); } } }
private void toolStripButton1_Click(object sender, EventArgs e) { //显示excel数据 int count = 0; livVoucher.Items.Clear(); //张大维 //若用户没有选择Excel表,提示用户并退出当前代码块 if (cbbSheets.DataSource == null) { MessageBox.Show("请正确选择需要导入的会计凭证!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //张大维 //读取Excel表内容到内存中并形成DataTable DataTable dt = dsExcelFile.GetRecord("select * from [" + cbbSheets.Text + "] ").Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { ListViewItem li = new ListViewItem(); li.Text = dt.Rows[i][0].ToString(); li.SubItems.Add(((DateTime)dt.Rows[i][1]).ToString("yyyy-MM-dd")); li.SubItems.Add(((DateTime)dt.Rows[i][2]).ToString("yyyy-MM-dd")); li.SubItems.Add(dt.Rows[i][3].ToString()); livVoucher.Items.Add(li); count++; } label3.Text = "共:" + count.ToString(); }
private void toolStripButton2_Click(object sender, EventArgs e) { //显示excel数据 int count = 0; livinvoice.Items.Clear(); DataTable dt = dsExcelFile.GetRecord("select * from [" + cbbSheets.Text + "] ").Tables[0]; for (int i = 5; i < dt.Rows.Count; i++) { if (dt.Rows[i][1].ToString().Trim() != "" && IsNumberic(dt.Rows[i][1].ToString())) { ListViewItem li = new ListViewItem(); li.Text = dt.Rows[i][1].ToString(); li.SubItems.Add(dt.Rows[i][2].ToString()); li.SubItems.Add(dt.Rows[i][14].ToString()); li.SubItems.Add(dt.Rows[i][16].ToString()); livinvoice.Items.Add(li); count++; } } label3.Text = count.ToString(); }
private void toolStripButton2_Click(object sender, EventArgs e) { //显示excel数据 dvgstaff.DataSource = dsExcelFile.GetRecord("select * from [" + cbbSheets.Text + "] ").Tables[0]; }