private void CreateExcelTree() { List <ExcelDataHelper> Excels = new List <ExcelDataHelper>(); foreach (TreeNode rnode in treeView1.Nodes[0].Nodes) { string fname = rnode.Tag as string; TreeNode node = treeView1.Nodes[0].Nodes[Path.GetFileName(fname)]; ExcelDataHelper edh = new ExcelDataHelper(fname); Excels.Add(edh); string[] sheetnames = edh.GetSheetNames(); foreach (string sheet in sheetnames) { TreeNode cnode = new TreeNode(); cnode.Text = sheet; cnode.Name = sheet; node.Nodes.Add(cnode); GZDataTable gzdt = GZDataTable.ImportFromExcel(fname, sheet); string[] cols = gzdt.GetColumnsName(); foreach (string col in cols) { cnode.Nodes.Add(col); } } } }
public void ImportFromExcel(string[] filepaths, string[] RejectNames) { YearTables = new Dictionary <string, GZDataTable>(); foreach (string file in filepaths) { GZDataTable gzdt = GZDataTable.ImportFromExcel(file); gzdt.DeleteBlankOrZeroColumns(RejectNames); YearTables.Add(gzdt.DateStr, gzdt); } }
private void button2_Click(object sender, EventArgs e) { foreach (var item in GetCheckedFiles()) { GZDataTable gzdt = GZDataTable.ImportFromExcel(item.ToString()); gzdt.DeleteBlankOrZeroColumns(RejectNames); this.dataGridView1.AutoGenerateColumns = true; this.dataGridView1.DataSource = gzdt; this.dataGridView1.AutoResizeRows(); toolStripStatusLabel1.Text = gzdt.Rows.Count.ToString(); gzdt.ExportToExcel(); } }