.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

OPENROWSET on Excel 2007 file

Posted By:      Posted Date: September 26, 2010    Points: 0   Category :Sql Server


I am seriously loosing hair over this one! I have successfully used OPENROWSET to query data in an Excel 2003 file (*.xls) in SQL Server, however I am now looking to replicate this functionality with an Excel 2007 (*.xlsx) file.


I have tried the usual google searches but nothing concrete seems to come up, can anyone give me any pointers?


My Excel 2003 file sql is as follows: (works great)


SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\test.xls',

View Complete Post

More Related Resource Links

While Importing Excel 2007 file to Datatable - headerrow problem


Hi there,


I am trying to simply extract an excel data from an uploaded file an put it into a datatable. In this case the excel file has 3 rows but when I fill the datatable I only see row count of 2.

I tried changing HDR:NO; to HDR:YES and vice versa, but no luck. 

What am I doing wrong? (Note: the excel file cannot have a  headerrow)


string connstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + pFilePath + ";Extended Properties=\"Excel 12.0;IMEX=1;HDR:NO;\"";
            OleDbConnection conn = new OleDbConnection(connstr);
            DataTable dtTables = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
            string strTablename = dtTables.Rows[0]["TABLE_NAME"].ToString();
            string strSQL = "SELECT * FROM [" + strTablename + "]";

            OleDbCommand cmd = new OleDbCommand(strSQL, conn);

            DataTable dt = new DataTable();
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            //At this point row count=2 which doesn't make sense




import multiple Excel 2007 files using openrowset

hello, I Have a folder that includes multiple excle files (ver 2007), i am trying  to loop through each file using vbscript to import its data to sql 2000 using openrowset but i am getting this error in the openrowset line "[Microsoft][ODBC sql server driver] [sql server] [OLE/DB provider returned message: the microsoft office access DB engine cannot open or write to the file '', it is already open exclusively by another user or you need permission to view or write its data] code 80040E14 source microsoft OLEDB provider for ODBC drivers Any help please    

Import Excel-File (OPENROWSET) on x64 SQL Server


Hi, recently I encountered the following problem:

I tried to execute a stored procedure on the newly installed SQL 2005 Server (now on x64 Win Server 2003) which imports an Excel-File into a DB table.

We use OPENROWSET to access the Excel data. But I recognized this is dependent on Jet OLE DB which seems is not available for x64 windows.


Is there another way to import excel data using a stored procedure.


thank you in advance, rene

Unable to open an Excel File in Sharepoint MOSS 2007


I am unable to open an excel file in Sharepoint (MOSS 2007). All other documents work fine. As far as I know there was no change on the Server at all.

Excel found unreadable content in 'stuff.xls'. Do you want to recover the contents of this workgroup? If you trust the source of this workbook , click Yes

When I click YES >> It says "Excel recovered your formulas and cell values, but some data may have been lost." And then a link to an xml file , which reads :

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <summary>Errors were detected in file 'http://server_name/Project_name/Shared Documents/abc - def/Phase 5/Track/stuff.xls'</summary>
- <additionalInfo>
  <info>Excel recovered your formulas and cell values, but some data may have been lost.</info>

Now this has resulted in huge loss of data and I can see New numbers in the cells which is very strange!

Is there a way I can get it back ? I do not have a

Excel 2007 - embed an XML file




I tried to find an answer to this question without any success: is it possible to embed an XML file in a xlsx file?

My final objective would be to use this embedded XML file as a data source to generate a table.


Thank you!


not open excel 2010 file template in moss 2007 document library


I have installed microsoft sharepoint portal server 2007.

In which I specify in one document library excel template. I upload template of excel 2010

if OFFICE 2007 is installed in my system or in other persons . then it will open a template in excel document . but I update office and now office 2010 installed in my system. now when i click a new button and open a excel document . it is not opening and open only a text file with garbage. and show a dialog box with message.


"The document could not be created.

The required application may not be installed properly, or the template for this document library cannot be opened."

How can I open a template in office 2010 with MOSS 2007 document library.

Kindly tell me the solution as soon as possible.



Basim Alvi

Need to read an excel 2007 file from C# on 64 bit windows 7 ultimate machine



i am in need to read an excel 2007 file from C# on 64 bit windows 7 ultimate machine. Please help me out to find an optimum solution to it. I have got an option to change the project settings to 'x86' from 'Any CPU', however i dont want to do this since these are NUnit assemblies and would be running on 64 bit windows 7 server only.

i hope i clearly mentioned my problem, if more information is needed please feel free to ask.


Sankalp Singhal

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

Convert excel file into xml


Hai, I have two columns with id,name in the excel sheet.I want to convert into xml file in the below format

<?xml version="1.0" encoding="utf-8"?>

<guide xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Boat id="1"> <name> Copper Kettle </name> </Boat> <Boat id="2"> <name> Copper Penny </name> </Boat> <Boat id="3"> <name> Copperhead </name> </Boat> <Boat id="4"> <name> Coppertone </name> </Boat> <Boat id="5"> <name> Copy Boy </name> </Boat> </guide>

suggest me with sample code in ASP.NET. Thanks


Read Excel file from Web Application (C#)



I have a web app where user uploads a file.

File is saved in server locally and I want to read some data from it.

Currently my development  server has office 2003.

So do I need office 2007 in order to be able to  read an excel from office 2007 ?

What are other requirements  ?

I tried a test, using

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wrkBook; // = new Microsoft.Office.Interop.Excel.Workbook();

wrkBook = excelApp.Workbooks.Open(@"C:\www\excel_files\b.xls", ....);

But When trying to open the file I get the error:

Exception from HRESULT: 0x800A03EC

So I'm wondering what I'm missing.


Returning datas from two excel file



I used the below code to return the datas from one excel file. My question is if i suppose need to get the records from morethan one excel file using joins, how it is possible.

   string connString = ConfigurationManager.ConnectionStrings["xls"].ConnectionString;
        // Create the connection object 
        OleDbConnection oledbConn = new OleDbConnection(connString);
         // Open connection
            // Create OleDbCommand object and select data from worksheet Sheet1
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
            // Create new OleDbDataAdapter 
            OleDbDataAdapter oleda = new OleDbDataAdapter();
            oleda.SelectCommand = cmd;
            // Create a DataSet which will hold the data extracted from the worksheet.
            DataSet ds = new DataSet();
            // Fill the DataSet from the data extracted from the worksheet.
            oleda.Fill(ds, "Employees");




Excel 2007




I want to develop an application which supports Server Side Excel Automation using a template(xltx). I am able to acheive most of the automation except(using excelpackage.dll - OfficeOpenXml), i am stuck up identifying the checkbox controls in my excel work sheet.

Any help on this is really appreciated.


My sample code.




display data in excel 2007


 I am using .net  version 1.1  and  excel 2003 to display data.I need to display data in 2007 .Can  anyone suggest the reference to be added ,connection string change and what should be imported.  

Importing Excel 2007 spreadsheet into WSS 3.0 -- Error Message



I'm trying to import (Custom Lists >> Import Spreadsheet) into WSS 3.0 and I'm getting the following message: 

Refers to the _layouts

You are not authorized to view this page.  You might not have permissions to view this direcotyr or page using the credentials you supplied. [More stuff here.]

Http ERror 403 - Forbidden

Is this just a permissions problem or is there some other underlying issue?  Should you be able to upload an Excel spreadsheet (with links) into a Custom List?


Thanks! Patti N.

In sharepoint excel working fine in office 2007 but not in office 2010


Hi All,

we receive error  while trying to create excel sheet using the template we have uploaded on the SharePoint 2007.


This occurs on a machine that has Office 2010 installed. Earlier the machine had Office 2007 and everything was working fine.


Can you let me know why is problem is coming and how to resolve this.



Sanjeev Tiwari


Excel file getting error


when i am trying to save a excel document in library it getting error like "The file cannot be saved because some properties are missing or invalid"

If anyone know the solution for this pls tell me.



Excel file not showing in search results

We have a strange issue. I have one Excel document (or at least one that I am aware of) that will not show up in search results for content within the document. I can find the document by title just fine, but when I search for words within the document I do not see it. The document was originally a 2003 Excel document and was recently converted to 2007. Other than that there isn't really anything unusual about it (some formatting stuff, but mainly just background colors and whatnot, nothing fancy). The crawl log shows the document was crawled without error. Anyone know anything else I can check on?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend