我尝试过这段代码,但它不起作用:
private void Load_Button_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "Excel Workbook|*.xls", ValidateNames = true })
{
if (ofd.ShowDialog() == DialogResult.OK)
{
System.IO.FileStream fs = File.Open(ofd.FileName, System.IO.FileMode.Open, FileAccess.Read);
ExcelDataReader.IExcelDataReader reader = ExcelDataReader.ExcelReaderFactory.CreateBinaryReader(fs);
reader.IsFirstRowAsColumnNames = true;
result = reader.AsDataSet();
cboSheet.Items.Clear();
foreach (DataTable dt in result.Tables)
cboSheet.Items.Add(dt.TableName);
reader.Close();
}
}
}
我似乎无法运行此代码,因为IsFirstRowAsColumnNames
和AsDataSet
有红色下划线。
答案 0 :(得分:2)
来自instructions for the library:
安装
<Style TargetType="{x:Type local:ClickableBorder}"> <Setter Property="BorderBrush" Value="Black"/> <Setter Property="Background" Value="LightGray"/> <Style.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsMouseOver" Value="True"/> <Condition Property="IsEnabled" Value="True"/> </MultiTrigger.Conditions> <MultiTrigger.EnterActions> <BeginStoryboard> <Storyboard> <ColorAnimation Duration="0:0:0.200" To="White" Storyboard.TargetProperty="BorderBrush.Color"/> <ColorAnimation Duration="0:0:0.200" To="DarkGray" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"/> </Storyboard> </BeginStoryboard> </MultiTrigger.EnterActions> <MultiTrigger.ExitActions> <BeginStoryboard> <Storyboard FillBehavior="Stop"> <ColorAnimation Duration="0:0:0.200" To="Black" Storyboard.TargetProperty="BorderBrush.Color"/> <ColorAnimation Duration="0:0:0.200" To="LightGray" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"/> </Storyboard> </BeginStoryboard> </MultiTrigger.ExitActions> </MultiTrigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="local:FrameworkElementExt.IsPressed" Value="True"/> <Condition Property="IsEnabled" Value="True"/> </MultiTrigger.Conditions> <MultiTrigger.EnterActions> <BeginStoryboard> <Storyboard> <ColorAnimation Duration="0:0:0.200" To="DarkRed" Storyboard.TargetProperty="BorderBrush.Color"/> <ColorAnimation Duration="0:0:0.200" To="Red" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"/> </Storyboard> </BeginStoryboard> </MultiTrigger.EnterActions> <MultiTrigger.ExitActions> <BeginStoryboard> <Storyboard FillBehavior="Stop"> <ColorAnimation Duration="0:0:0.200" To="Black" Storyboard.TargetProperty="BorderBrush.Color"/> <ColorAnimation Duration="0:0:0.200" To="LightGray" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"/> </Storyboard> </BeginStoryboard> </MultiTrigger.ExitActions> </MultiTrigger> </Style.Triggers> </Style>
扩展程序包以使用ExcelDataReader.DataSet
方法填充AsDataSet()
。
所以你需要additional library。
System.Data.DataSet
属性根本不存在,也许它是已删除的遗留项。相反,您似乎需要将配置传递给IsFirstRowAsColumnNames
方法,例如:
AsDataSet