使用 epplus 迭代 c# 中的所有工作表并将它们导入组合框中

iterate all sheets in c# with epplus and importing them in the combobox

我想使用 将特定 excel 的所有 sheet 名称放入组合框的项目中。你能帮我怎么做吗?谢谢

如果我正确理解了你的问题,你想读取 Excel 的所有名称并将 Excel 工作表的名称放入组合框中,以便用户可以选择它,我我对吗?

 var filePath = "C:\temp\excel.xlsx";
 var excel = new ExcelPackage(new FileInfo(filePath));

 foreach (var worksheet in excel.Workbook.Worksheets)
 {
     this.comboBox1.Items.Add(worksheet.Name);
 }

如果您将文件路径替换为您的文件路径 excel 名称并将 comboBox1 更改为您的组合框,我认为这就是您想要的。