.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

How do I read an Excel Named Table?

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :

First I am using Excel 2007 and a .xlsm file. I am able to read in data from Excel that is on a Sheet or in a Range, but how do I read from a named table. 

My sampe file as data in B10:G20 and that area is a table named Table1.  Since the location and size changed between my actual files, Table1 will not always be in that location.

Here is the SQL command I am currently using

SELECT * FROM OPENROWSET ('Microsoft.ACE.OLEDB.12.0','Excel 12.0; Database=C:\Test.xlsm', 'SELECT * FROM [table1$]') 

I have also set this file up as a Linked Server and have gotten the same result.  And I have tried Table1 with and without out square brackets, and with and without the dollar sign.  I'm sure I'm missing something small.


Thanks for any help you can give!.

View Complete Post

More Related Resource Links

How to read Excel table?


If I  use Microsoft.Jet.OLEDB.4.0 to retreive for example named range or sheet from Excel and use it as data source for some server control on the ASP page, everything works fine. But when I try to get table from Excel like this: "select * from [Table1]", debugger complains that database engine could not find object Table1. So how should I reference Table1 in Excel file so that the database engine could find it?

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

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.


How to read value of CheckBox in EXCEL sheet


I am using OLEDBConnection (@"Provider=Microsoft.ACE.OLEDB.12.0;") to connect to the EXCEL file and read contents. When I read the contents, I get all the contents from the excel sheet but i dont get contents for checkboxes placed inside.

My Excel sheet contains set of checkboxes and I need to know If they are checked or not.These checkboxes are controls which are added from Developer tab in EXCEL.

I dont want to use Excel Assemblies for reading contents as it is not recommended. And also i am using OLEDBconnection and want to stick to this .

Awaiting replies from you guys. Thanks in Advance.

some of the cell value cant read from Excel

Hi all, Im reading some data from the excel file, using below code objBusy = new BusinessLogic();                string strFileName = FileUpload1.PostedFile.FileName;                string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strFileName + ";" + "Extended Properties=Excel 8.0;";                OleDbConnection objConn = new OleDbConnection(connectionString);                objConn.Open();                String strConString = "SELECT * FROM [Product1$]";                //where date = CDate('" + DateTime.Today.ToShortDateString() + "')";                OleDbCommand objCmdSelect = new OleDbCommand(strConString, objConn);                // Create new OleDbDataAdapter that is used to bui

Read Excel sheet by Sheet Name using office interop

Hi,I am using office interop to read Excel sheet.I want to read the contents of the sheet  using the name of the sheet.For example I want to read the contents of the sheet- "ABC" (if ABC exists).Thanks

Excel 2007 Pivot table OLAP- SSAS 2008 Error

Hi, I do have a strange issue with Excel 2007 pivot table report; the data source is SSAS 2008 cube. When refresh the excel 2007 report data using the 'Refresh All' or 'Refresh' button available under the Data menu, the below error is thrown. "The expression contains a function that cannot operate on a set with more than 4,294,967,296 tuples." After some analysis, the report works well on the below workaround, 1. Remove all the calculated measures from report (3 measures in this scenario) 2. Remove one row label (dimension attribute) from report But the measures, attributes are valid one from cube and it is required fields in the report. So, understand that removing few items is not at all a solution. The below workaround also works. 1. Check the 'Defer Layout Update' option from the Pivot Table Field List window. 2. Click on the Update button After that Unchecked the 'Defer Layout Update' option and apply the filter, etc in the report. The report works very well. But every time, we need to use the above work around after open the excel report. I have NO clue on this issue. Please help to resolve this issue. Thanks, Jey

read data from excel

hi all,i had 2 columns in the excel file one is SNo and another Descriptionlooks like belowSno                         Description1                              1/2 Feet2                               1/5 Feet3                              204                               30i read the data from this file using below codestring strFileName = FileUpload1.PostedFile.FileName;            string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strFileName + ";" + "Extended Properties=Excel 8.0;";            OleDbC

Excel 2003 pivot table - parent showing grand total than the sum of its children

All, In Excel 2003, I have a product hierarchy, for simplistic sake lets say it goes A > B > C > model nbr.  I have filtered on model nbr 1.  I have the product hierarchy in my pivot table and unit cnt as the measure. Starting at level A in the hierarchy I am showing a total unit of 12000, if I drill down to B it still shows 12000, if I drill down to C it shows 100 and if I drill down to model nbr it shows me model nbr 1 with a unit cnt of 100. So my question is why are my parents not filtering the model nbr, it is taking the total for ALL records that have level A as their parent regardless of the model nbr? This does NOT happen in Excel 2007 or when I browse my cube in SSAS.

Adding data from Excel spreadsheet to SQL table

This is not a programming question, I simply have a lot of data in two columns in an excel spreadsheet of data that I gathered.  I want to copy and paste this (manually) into a table that I have created in my ASPNETDB in my ASP.NET web application.  I thought it'd be as easy as copy the column, and hit paste in the "table data" view, but it's not (it only pastes one cell).Is there a way for me to manually copy data from excel and paste it in a table in my SQL Server?Thanks in advance! :)

How to change connection string of a pivot table pointing to SSAS 2005 cube using excel 2003?

Hi All,I am not sure if I should have posted this query to Excel 2003 forum. But posting it here as it applies to SSAS 2005 as well.Ok, let me give the background before I tell the actual problem.We have users on ABC domain and the SSAS server is also on ABC domain. Users on this domain can acess the excel pivots by connecting to cube to browse the data. They leave the Userid & password field blank while they setup the connection string and it works fine. Thanks to windows authentication that takes the credentials of user logged in. Let's say I have two users A and B, they login to ABC domain with their own windows ids.  Now when user A creates a excel file having a cube pivot and then sends this file to user B, user B can refresh and modify the same excel file (he can select new measures to pivot, new hierarchies in filters and so on).Now, let's say I have another user, user C. He has excel 2003 installed on his PC and cannot migrate to excel 2007. He is on different domain XYZ but have a valid windows userid on domain ABC. The domain ABC & XYZ can not be setup to have trusted relationship. Now, when user A sends the same excel file to user C. When user C opens the file and try to refresh it or try to modify the pivot by selecting/deselecting any elements, he gets below error prompt:" An error was encountered in the transport layer." and "Errors in the

How to read excel header name and put into SELECT statement?

Hi,        I'm trying to read Excel file header column name. Then I can query data from excel using SELECT statement. For instance. column name is name, department and email.  Then I want this three header name being detected using code and put in select statement. User no need to care about the header name and we can use code to read the header name instead of hardcode header name inside SELECT statement.       Please provide the details. Thanks.

Excel External Table Data can only create new SharePoint List when Exporting from Excel?

I have a SQL Query that I refresh everyday in Excel. I want to be able to export this list over to a SharePoint list right after my refresh in Excel but I can only Export to a SharePoint list only once. If I try to export again to the same list then it will give me the error "The specified list name is already in use on this server. You must rename the list before publishing it to the server." I have web parts that have connections to this list and I do not want to export my Query to a new SharePoint list everyday. Does anyone know a way around this issue?

Excel Drop Table question

Can anyone tell me if the drop table syntax should delete only the data in a worksheet or clear the formatting as well. If not is there a way to clear all the formatting. Thanks

read excel column value

Hi All,             i am uploading excel file data to database.Excel column value is combination of text and time,i need to extract only time.Each column will have different value. One column value is   _immediate 17:00 - 9:00 another column value is EMAIL 09:30 - 18:00,another column value is CKA 09:30 - 18:30 ans so on. i need to extract only time and store it 2 different variables like this. string Intime - 17:00 string OutTime - 9:00   Please send me code to acheive this task.            

Analysis Service Oracle Number inconsistent Data Type for TABLE or Named Query

Dear Gurus, I'd VERY OLD PROBLEM. And I believe it addressed since 2006. When I design DataSource Views from Oracle Data Source. I found it return different oracle number data type for TABLE or NAMED QUERY   Provider Data Type Column Data Type Data Source View Data Type Oracle OLE DB Provider (OraOLEDB.Oracle.1) Table Number System.Int64   View Number System.Decimal   Named Querey Number System.Decimal Microsoft OLE DB Provider for Oracle (MSDAORA.1) Table Number System.Double   View Number System.Double   Named Query   1 System.Int64   Named Query   1.1234 System.Int64 Althought I know I can fix IT via MANUALLY EDIT DATASOURCE VIEW XML SOURCE. But I don't think this is a better solution. Is anybody have ideas ?  Wilson

Dimensions order in excel pivotal table

The list of dimensions in excel pivotal table are in alphabetical order. is it possible to reorder the dimensins?
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