SIGN UP MEMBER LOGIN:    
ARTICLE

How to download/Read Excel file from SharePoint Library using Excel Services

Posted by Vivek Srivastava Articles | SharePoint December 03, 2010
In this article I will explain how can we download and read excel file using excel services in a simple way.
Reader Level:
Download Files:
 

In this article I will explain how can we download and read excel file using excel services in a simple way. 

Step 1 
  • Open document library where you have uploaded excel files in SharePoint.
  • Copy path of document library and add the path into trusted location to enable excel services.
Steps to add Path in Trusted File Location:-
  1. Open Shared Services from central administration.
  2. Go to Excel Service section and click on Trusted File Location.

    1.gif

  3. A new window will be open, Click on Add Trusted File Location.

    2.gif

  4. A new window will be open to add the path into trusted file location, paste the url in address field.

    3.gif

  5. Click on OK button. Now document library added in trusted file location.

    4.gif
Step 2
  • Open Visual Studio >> File >> New >>Project   choose console application from C# Project Window.

    5.gif

  • Right click on ExcelServiceTest solution and select Add Web Reference.

    6.gif

  • In add web reference window specify excel web service url  i.e http:// <sharepoint site url>/_vti_bin/excelservice.asmx.

    7.gif

  • Give the web reference name as XLService and click on Add Reference button. Now Excel Service web reference is added in the ExcelServiceTest solution as shown below.

    8.gif

  • Add namespace of the XLService  reference in Program.cs file

    using ExcelServiceTest.XLService;
Function for Reading Excel File:-

9.gif
  
ReadExcelFile contains following arguments-
  1. strFileURL- Give the url of the excel i.e.

    http://<sharepointsiteurl>/<documentlibrary>/excelfilename.xlsx     
  2. strSheetName- Give the name of sheet which you want to read i.e. Sheet1.
  3. strRange- Give the range of sheet i.e. A1:D4.    
Function for download excel file:- 

10.gif
  
DownloadXLFile contains following arguments-
  1. strPath- Give the url of the excel i.e.

    http://<sharepointsiteurl>/<documentlibrary>/excelfilename.xlsx     
  2. strDest- Give the local file path to download i.e. c:\TestExcel.xlsx.
Note: - This solution will work only with Office 2007 onwards.  

Please download complete code for Reading/downloading Excel File from the SharePoint Doc Library.

Enjoy it.

Login to add your contents and source code to this article
share this article :
post comment
 

Really good artical

Posted by Saurabh Jha Nov 10, 2011
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Gauge for SharePoint
Become a Sponsor