使用c#将Excel导入到asp.net中的数据表 [英] Import Excel to Datatable in asp.net using c#
问题描述
您好。有没有其他方法可以将Excel文件数据导入数据表并使用c#在asp.net 2.0中的Gridview中加载它?
我尝试使用
OleDbConnection oconn = new OleDbConnection( @ Provider = Microsoft.ACE.OLEDB.12.0; Data Source = + path + ;扩展属性= Excel 12.0);
它可以在我的本地机器上运行,但是当我在网络(服务器)中部署它时,它给出了错误
'microsoft.ace.oledb.12.0'提供程序未在本地计算机上注册。
我知道我应该安装一些东西来删除错误并使Web应用程序正常工作,但是我们不允许在服务器中安装一些东西,因为它可能会影响与其他应用程序集成的内容它。
任何帮助请...
尝试以下链接
OLEDB提供程序未在本地计算机上注册 [ ^ ]
是,我想你需要添加对你的服务器的引用。以下是可能对您有用的有用链接:
将excel数据导入sql server数据库表并在gridview中显示 [ ^ ]
http://stackoverflow.com/questions/21673283/import-excel-data-to-sql- server-database-table-and-display-in-gridview [ ^ ]
所以,我认为Epplus.dll是将excel数据导入数据表的最佳方式。
http://www.aspneto.com/import-csv-excel-data-into-sql-server-using-bulk-insert-asp-net.html 一> [ ^ ]
感谢您的所有建议!我用过这个。但是,它只接受2003年格式的Excel
OleDbConnection oconn = new OleDbConnection( @ Provider = Microsoft.ACE.OLEDB.12.0; Data Source = + path + ;扩展属性='Excel 12.0; HDR = YES; IMEX = 1';);
Hi. Is there any other way to import an Excel file data to a datatable and load it in Gridview in asp.net 2.0 using c#?
I tried using
OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+path+";Extended Properties=Excel 12.0");
and it works in my local machine, but when i deployed it in network(server), it gives an error of
the 'microsoft.ace.oledb.12.0' provider is not registered on the local machine.
I know that i should install something to remove the error and make the web application work, but we are not allowed to install something in the server as it may affect other application integrated with it.
Any help please...
Try below link
OLEDB Provider is Not Registered on the Local Machine[^]
Yes, I guess you need to add the reference to your server. Here is the useful links that may helps you:
import excel data to sql server database table and display in gridview[^]
http://stackoverflow.com/questions/21673283/import-excel-data-to-sql-server-database-table-and-display-in-gridview[^]
So, I think Epplus.dll is the best way to import excel data to datatable.
http://www.aspneto.com/import-csv-excel-data-into-sql-server-using-bulk-insert-asp-net.html[^]
Thank you for all your suggestions! I used this. However, it just accepts Excel in 2003 format
OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1';");
这篇关于使用c#将Excel导入到asp.net中的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!