Search code examples
c#exceloledbjet

System.Data.OleDb.OleDbException: Invalid internet address. How do you connect to excel files located on a webserver using OleDb


I'm trying to create an OleDb connection to an Excel file that is located on a SharePoint server. The example code I'm playing with at the moment throws an OleDb exception "Invalid internet address":

public static void ConnectToRemoteExcelFile()
    {
        string connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;\";", "http://horde.servername.co.uk/Docs/Documents/Sales.xlsx");

        using (OleDbConnection connection = new OleDbConnection(connectionString))
        {
            connection.Open();
        }

    }

Anyone know how to connect to an excel spread sheet on a web server?

Update

Microsoft support have come back to me and agree that is not possible to connect to Excel files located on a web server. Both Jet .40 and the news ACE (Access Connectivity Engine) do not support this mode of operation. They cite reference to the KB Article "The Import/Link Data on an FTP or HTTP Server Help topic is not correct in Access 2000, Access 2002, Access 2003 and Access 2007"


Solution

  • As far as I know that is not possible, you would have to download the file first, then access it. The reason being is that the file could not be modified given its location.