C# 如何使用c在工作簿中打开相应的excel工作表#
我的代码打开excel的第一页。我的目标是打开组合框中选定的工作表。是否有人可以帮助我找到解决方案: 我的代码: 按图纸名称C# 如何使用c在工作簿中打开相应的excel工作表#,c#,excel,C#,Excel,我的代码打开excel的第一页。我的目标是打开组合框中选定的工作表。是否有人可以帮助我找到解决方案: 我的代码: 按图纸名称 Microsoft.Office.Interop.Excel.Worksheet wsh = (Worksheet)excelsheet["SheetName"]; 按索引(从1开始-第一页) 只需在组合框中使用其中一个值。 如果要用可用的工作表填充组合框,可以浏览工作表 foreach (Worksheet Sh in excelsheet) { Combob
Microsoft.Office.Interop.Excel.Worksheet wsh = (Worksheet)excelsheet["SheetName"];
按索引(从1开始-第一页)
只需在组合框中使用其中一个值。
如果要用可用的工作表填充组合框,可以浏览工作表
foreach (Worksheet Sh in excelsheet)
{
Combobox.Items.Add(Sh.Name);
}
然后,组合框的选定值将已经是一个工作表名称,您可以通过以下方式获得:
Microsoft.Office.Interop.Excel.Worksheet wsh = (Worksheet)excelsheet[Combobox.SelectedValue]; //I'm not sure if combobox value is got like this, but the excel part is ok.
foreach (Worksheet Sh in excelsheet)
{
Combobox.Items.Add(Sh.Name);
}
Microsoft.Office.Interop.Excel.Worksheet wsh = (Worksheet)excelsheet[Combobox.SelectedValue]; //I'm not sure if combobox value is got like this, but the excel part is ok.