[英]OLEDB Cannot load data from excel after publishing
I am using OLEDb to load table from a local .xls
file in C# .Net
. 我正在使用OLEDb从
C# .Net
的本地.xls
文件加载表。
The table is loaded and showed correctly when I view the webpage "View in Browser"
. 当我查看
"View in Browser"
查看”网页时,该表已加载并正确显示。 But when I publish, the table is not shown on the webpage (URL that I publish to) but other parts of the webpage are shown correctly. 但是,当我发布时,该表未显示在网页上(我发布到的URL),但网页的其他部分却正确显示。
Is there a reason why the excel file can be loaded when debugging but cannot load when published? 为何在调试时可以加载excel文件,而在发布时却不能加载?
Here is the code in C# that load the Excel: 这是加载Excel的C#代码:
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=//Dfs.local/I/Test Copy.xls;Extended Properties='Excel 8.0;HDR=False;IMEX=1'";
OleDbConnection OleConn = new OleDbConnection(strConn);
OleConn.Open();
String sql1 = "SELECT * FROM [Sheet1$]";
OleDbDataAdapter OleDaExcel1 = new OleDbDataAdapter(sql1, OleConn);
My first idea was that the excel spreadsheet could not be access by webpage. 我的第一个想法是无法通过网页访问excel电子表格。 But I have another link on the webpage that would open this excel when clicked.
但是我在网页上有另一个链接,当单击该链接时,它将打开此excel。 And it's working on the webpage after publishing.
发布后在网页上运行。 Here is the code for the link:
这是链接的代码:
<script language="JavaScript" type="text/javascript">
Out = '<a href="file://Dfs.local/I/Test Copy.xls">Report<\/a>';
document.writeln(Out);
</script>
I tried many different ways of publishing but could still not load the excel table when opening from URL. 我尝试了多种发布方式,但是从URL打开时仍然无法加载excel表。
Please help! 请帮忙!
Thank you! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.