C#中用dataList绑定exel的数据的方法:
1、displayasp代码
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload"
OnClick="btnUpload_Click" />
<br />
<asp:Label ID="Label1" runat="server" Text="Has Header " />
<asp:RadioButtonList ID="rbHDR" runat="server">
<asp:ListItem Text = "Yes" Value = "Yes" Selected = "True" >
</asp:ListItem>
<asp:ListItem Text = "No" Value = "No"></asp:ListItem>
</asp:RadioButtonList>
<asp:GridView ID="GridView1" runat="server"
OnPageIndexChanging = "PageIndexChanging" AllowPaging = "true">
</asp:GridView>
2、绑定excel的配置文件webConfigxml:
<connectionStrings>
<add name ="Excel03ConString"
connectionString="Provider=MicrosoftJetOLEDB40;Data Source={0};
Extended Properties='Excel 80;HDR={1}'"/>
<add name ="Excel07ConString"
connectionString="Provider=MicrosoftACEOLEDB120;Data Source={0};
Extended Properties='Excel 80;HDR={1}'"/>
</connectionStrings>
3、后端c#代码:
protected void btnUpload_Click(object sender, EventArgs e)
{
if (FileUpload1HasFile)
{
string FileName = PathGetFileName(FileUpload1PostedFileFileName);
string Extension = PathGetExtension(FileUpload1PostedFileFileName);
string FolderPath = ConfigurationManagerAppSettings["FolderPath"];
string FilePath = ServerMapPath(FolderPath + FileName);
FileUpload1SaveAs(FilePath);
Import_To_Grid(FilePath, Extension, rbHDRSelectedItemText);
}
}
以上就是关于C#中如何用DataList绑定excel的数据全部的内容,包括:C#中如何用DataList绑定excel的数据、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)