.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

Reading data from Excel 2007

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
I am attempting to read data from an uploaded spreadsheet using ACE.OLEDB. The code, which is running fine on dev and test machines for XL2003/2007 reports "External table is not in the expected format" error on connecting on the production server for XL2007 only. The code is Dim connectionString As String = "provider=Microsoft.Ace.OLEDB.12.0;" _ & "Data Source='" & ImportData.FullName & "';Extended Properties=Excel 12.0;" LogWebActivity.LogThis("Entering POPSUKD, ConStr=" & connectionString, LogWebActivity.LogDetailLevel.DetailAndData) Dim con As New System.Data.OleDb.OleDbConnection(connectionString) LogWebActivity.LogThis("Dimmed con", LogWebActivity.LogDetailLevel.Debugging) Try Dim cmdSelect As New System.Data.OleDb.OleDbCommand("SELECT * FROM [" & WorksheetName & "$]", con) Dim adapter As New System.Data.OleDb.OleDbDataAdapter(cmdSelect) Dim dS As New Data.DataSet LogWebActivity.LogThis(cmdSelect.CommandText, LogWebActivity.LogDetailLevel.Debugging) con.Open() LogWebActivity.LogThis("Opened Connection", LogWebActivity.LogDetailLevel.Debugging) adapter.Fill(dS, WorksheetName) LogWebActivity.LogThis("Filled DataAdapter", LogWebActivity.LogDetailLevel.Debugging) _SKUS = dS.Tables(W

View Complete Post

More Related Resource Links

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.  

Video: Connecting PivotTables in Excel 2007 to Data Stored in SharePoint Lists

Learn how to use the Open XML SDK 2.0 to create Excel 2007 PivotTables that are connected to data stored in SharePoint lists.

Importing Excel 2007 data into SQL 2005 database

I have a SQL 2005 cluster installation without SSIS and without management studio (I didn't install it). Now we need to import data from an excel 2007 file into a specific table in a database. I have tried doing this from a remote management studio, BI development studio and DTSwizard but I can't seem to make it work. The error message from BIDS is that "the data source is on a remote computer..." Does any of you have a step by step  guide that works from a remote location. BR Rasmus    

SSIS - reading blank rows from Excel 2007 which are actually deleted

Folks, We are facing a strange issue with SSIS and thought I would share the same with you and see if there are any solutions. We are developing a solution where users upload their data in the form of Excel 2007 spreadsheets to a web application interface and then, the file is loaded into an Oracle RDBMS using SSIS 2008 (SSIS called using SSIS Object Model from .NET). Now, there are specific templates provided to the users for their input files and they are using the same. However, it is being observed that when the user deletes certain rows from Excel manually and tries to load it, the file load fails. The reason for the same   is seen when the package is run in debug mode – the excel source is reading a few rows (we are assuming the recently deleted rows) as NULL values in all the columns. Now, some searching revealed at http://www.tech-recipes.com/rx/2189/excel_2007_eliminate_blank_rows/ that the following manual set of operations are resolving the problem – 1. Go to the Ribbon, and select the Home tab. 2. In the Editing section, click the small arrow next to Find & Select . 3. Select Go To Special . 4. Select the Blanks radio button and click OK. 5. All blank columns/rows will be highlighted. 6. Delete However, this requires a user intervention and obviously, the users are not really loving it J . I just wanted to check that if there are any po

Reading Excel data to SQL database



Using C# to develop an application.

I need to upload data ( which is in excel) to a sql table.

This is the code I have.

public ReadExcel(string strFileName,string strRegion)
        string strFilePath = string.Concat("c:/BulkUpload/", strFileName);
        myDataSet = new DataSet("Excel_DataSet1");
        string myConnectionString;
        OleDbConnection myConnection;
        OleDbDataAdapter myAdapter;
        myConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source='" + strFilePath + "';Extended Properties=Excel 8.0;";
        myConnection = new OleDbConnection(myConnectionString);

        myAdapter = new OleDbDataAdapter("select * from [sheet1$]", myConnection);

        DataTable dt = myDataSet.Tables[0];
        int count = 0;
        foreach (DataRow r in dt.Rows)
            if (count != 0)
                DBConnect db = new DBConnect();
                db.AddData("INSERT INTO " + strRegion + "(Country,ProjectOwner,State,County,ProjectName,Quarter,Manager,Comments) VALUES ('" + r[1].ToString() + "','"

SSIS 2005 - Export Data into an Excel 2007 Table


Hello !

I have an excel file (xlsx) containing a table :

Excel Table

Once I launched my ssis task (successfully) to insert data in it, it is actually append after the table :

Excel Table after the SSIS task

So I am looking for a way to insert into the table and expand it with the data. I hope someone could help me.

Thank you !

Initialization of the data source failed in Excel 2007 from As 2008R2


Environment: Win server 2003 , Office2007, SQL Server2003, PowerPivot for Excel

All the user do have access to connect the cube. am the admin user and i get the same error message.

"Initialization of the data source failed. Check the database or contact your database administrator. Make sure the external database is avaliable, and then try to operation again.

I have tried deleteing the data source and creating a new one.

Can any one help with this there are other fourms on this but i can't see a answer for it.


Reading data from document library excel workbook



I am having Sharepoint 2010 Enterprise RTM Trial on windows Server 2008 SP2. 

I have Document Library in my site. I want to display the contents of excel workbook placed in that library in a webpart (webpart like List webpart not Excel Web access webpart). If workbook is updated then the webpart should also update....

Can it be done through workflows ? or any other webpart that provide me the desired behaviour ?


CLASS Not Registered - Excel 2007 Data Source (Not 64 Bit machine)


First off, I am not running on a 64 bit machine.

I keep getting the following error when I try to run a task that has an ODBC connection to an xlsx file on a SQL Server 2005 server using SQL Server Agent.

Executed as user: ACCT02\ssc_emr_ra. ... 9.00.4035.00 for 32-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Started:  7:29:39 AM  Error: 2010-10-28 07:29:42.63     Code: 0xC0202009     Source: RFC_Data_Load Connection manager "Excel ODBC Connection"     Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040154.  An OLE DB record is available.  Source: "Microsoft OLE DB Service Components"  Hresult: 0x80040154  Description: "Class not registered".  End Error  Error: 2010-10-28 07:29:42.63     Code: 0xC020801C     Source: Data Flow Task OLE DB Source [3052]     Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel ODBC Connection" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method c



Recent install of add in  Excel data mining on excel 2007 when I press the classification matrix button for example it gives me the error : A connection to analysis service is required to perform the classification matrix task. Click the no connection button on the data mining tool bar to create a new connection.

I click new connection then new,, I type in my name , and then test connection then another error Test connection Failed Aconnection cannot be made ensure that the server is running : No such host is known.

Can someone please help me with this so i may use the data mining feature on my spread sheets thanks in advance :]

SSAS 2008 data refresh problem in Excel 2007



My problem sounds like that:

I have some cube created with SSAS 2008 and I'm using Excel 2007 as browser to view cube data.

I made pivot table with nessesary data, everything works fine till I save excel file and sent it to my client.

When client uses some filter, some row measures disapear. Dimension data are shown, measures are blank cells, but calculations from those measures is filled.

e.g. I see difference of sales between years in percent, but I can't see measures, which were used to count that difference, because in excel I see blank cells.

Any ideas?

Data Mining add in for Excel 2007 video tutorials



Does any one knows where can i get Data Mining add in for Excel 2007 video tutorials? (Classify, Estimate,Cluster, Associate, Etc.)

All i can find are videos tutorials for Data Mining table analysis tool.




Excel 2007 Data Mining Add-in disappear



I install add-in and run fine for a while, then all of sudden I could not see Table Analyze tool and data mining tab at my ribbon. I re-run server configuration and re-connect to DMAddinDB (remote server, but I am the administrator), but data mining add-in and table analyzer still not showing at my ribbon.


Then I uninstall DMAddin, re-install it, go through configuration again, but still the tabs are not showing up.


Any idea you can help me get my add in back?

Reading and Writing Data to/from Excel File


I need to read and write data from excel sheet. Firstly for example I need to use the concept of accessing workgroup, sheet and then cells whatever I want.

For example I need to use cell A1+B1 and put the result in C1

alternatively I can use the same function above and put data in some other sheet of same excel file.

Please reply the answer either using C#.NET or asp.net using C#.NET

Reading excel data in SSIS Script task


I am reading an excel file using OleDbDataReader.

I can read all cells from the sheet. But when I read a string value its returning me a NULL value. If I replace that cell with a Integer value I can get it.

Basically I am doing a validation on the cells to see if there are any non-numeric values. For certain cells which has string value I can get it as string and I can do the validation but for certain others I cant. Its returning as NULL. Any help would be really helpful.




display data into GridView from excel sheet

I have to display data from excel sheet into my gridview and also I need to figure out a way to store data into excel files from my web page. I am using C# 3.5, VS 2008.

Creating an Excel Spreadsheet and Adding Data to It Programmatically

The Interoperability services make it veryeasy to work with COM Capable Applications such as Word and Excel. Thisarticle reveals using Excel from a managed application. Excel is thespreadsheet component of Microsoft Office 2000. The majority of Excelprogrammatic functionality is exposed through Automation via the typelibrary Excel9.olb. The intention of this article is to express that amanaged application can interrelate with Excel as a COM server.
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