I am using OLEDb to load table from a local .xls
file in C# .Net
.
The table is loaded and showed correctly when I view the webpage "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.
Is there a reason why the excel file can be loaded when debugging but cannot load when published?
Here is the code in C# that load the Excel:
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. But I have another link on the webpage that would open this excel when clicked. 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.
Please help!
Thank you!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.