.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

Problem with referencing Excel version

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :Windows Application

Apologies if this is in the wrong place and needs to be moved.

I've built a small application which takes in Excel data, manipulates it and creates a workbook with charts. The PC I first built it on has Excel 2003, 2007 and 2010 installed and I referenced the Microsoft.Office.Interop.Excel (version 11.0) dll. When I transferred to a client's PC which had only Excel 2003, I got a compile error and had to redo the reference to Excel. When I transferred again to another of the client's PCs which had only Excel 2007 installed, it again threw a compile error and I had to reference the version 12.0 Excel object library. Naturally, going back, this version didn't work on the PC with only Excel 2003 installed.

Is there a way round this, other than to build separate versions of the application for each version of Excel? Thanks in advance for any help.

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




Excel-like experience - gridview focus problem



I'm creating a page where people can order several items from a list without having to press "edit" and "save" in between like you normally would in a gridview. The user writes down the quantity, and finally presses a "submit" button that saves the order.

I want the user to have a windows form (or excel) like eperience, so once the user puts in the quantity and moves on to the next item, either by TAB or by clicking on the TextBox, i make some calculations without the user beeing bothered with a full refresh or having to press a buton to execute the event, so I place the controls inside an UpdatePanel and use TextBox.TextChanged. The event runs code that calculates the sum for the row (price * quantity) and shows that in a column called "Sum", and updates a label in a fixed position with the new order total ("Total").

Any ideas on how to achieve this?

Right now I use a GridView with a templatefield for the Quantity and set the TextBox.TextChanged event to fire to make the calculations. The problem is that the focus then changes.

By using SmartNavigation or the ScriptManager.SetFocus I manage to retain focus on the TextBox that executed the Postback, but the user might have moved on to a textbox far down the gridview (thus causing the postback by leaving the previo

reading excel file problem



i have 200 rows in my excel file. im using OleDbConnection to read the excel file.

The problem is that it will read all the blank rows from row 200 onwards. Is there a configuration im missing ? or is there a way to import all rows that has data? Here's some of my code.

string excelConnectionString =
               "Provider=Microsoft.Jet.OLEDB.4.0;" +
                "Data Source=" + filePath + ";" +
                "Extended Properties=Excel 8.0";

OleDbConnection excelConnection =
                    new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=NO'");

OleDbCommand cmd = new OleDbCommand("Select * from [list$]",excelConnection);

Problem with Excel


Hi All,

I am trying to create hyperlink in Excel using below code, But it is giving me error:

Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))


 Dim oXL As Excel.Application
Dim oWB As Excel._Workbook
Dim oSheet As Excel._Worksheet

oXL = New Excel.Application()
oWB = DirectCast(oXL.Workbooks.Add(True), Excel._Workbook)
oSheet = DirectCast(oWB.ActiveSheet, Excel._Worksheet)

oSheet.Hyperlinks.Add(oSheet.Cells("A3"), "http://www.MySite.com", Nothing, "My Site Info", "clickhere")

It is giving the error on the above line when trying to create hyperlink.

Can you please tell me where I am doing wrong.




Excel problem

I m operning excel file using Applicaion object of Excel,InteropNow i am closing it but it doesn't release from memoryIt's process is runnig like Excel.exeHow can i release it.

How to solve the problem " FAILED TO LOAD udRBIctrls.ocx" Your version may be outdated??

I am getting the error message "Failed to load control 'udspinbutton'from udRBIctrls.ocx.Your version of udRBIctrls.ocxmay be outdated.Make sure you are using version of the control was that was provided with version". I have windows server 2008 64-bit o/s. I have installed my application on it. But in the application when i click few of the tabs of my applicaiton the above error message is being shown. I have searched the internet for the file , but didnt find it on the internet. Please help me to solve the problem.   

Excel Connection Manager Problem

I am building a package that has 2 tasks that need to use the same excel connection manager. I use a execute sql task to dynamically build a table from the headers of the excel sheet  ,then I use an excel source component to load the data from the sheet. However when I try to edit the excel source and switch the data access mode to a variable and select the variable(for the path), when I try to close the editor I get this message 'S:\myfolder'.  It is already opened exclusively by another user, or you need permission to view its data. I need this package to access the same folder each time because the files will be placed in that folder. This package also has a branch for loading a text file into sql server. It access the same folder but uses a flatfile connection manager It looks like permissions on the folder are correct

Problem with ASP.NET Ajax, Framework version 4.0 and the SeaMonkey browser...

I have a site that I'm upgrading to the 4.0 framework and I've come across an issue with asp.net ajax and the SeaMonkey browser. It seems like the script manager is not registering the scripts on the page in seamonkey (but it works fine in IE, Firefox, Chrome, Opera, and Safari). Now, if I change the user agent string in SeaMonkey to use the user agent string from any of those other browsers, it works fine. So I guess my question is does ASP.NET Ajax check the browser's user agent to determine what scripts to register and, if so, is it possible that SeaMonkey is not included in the list in the 4.0 framework (I should add that it's working fine in the 3.5 framework so it seems to me like this is a difference between the two framework versions).

Problem opening excel

hello everyone, i m having a serious problem, and i have been searching for days and i couldn't find a solution, my application deployed on IIS 7.5 is working very good except when trying to open excel file, i am getting an error telling me that the path is wrong or page is already used or the workbook you are trying to save already exists. to open excel m using: Dim xlApp = new Excel.application Dim xlWorkbook = new Excel.workbook Dim xlWorksheet = new Excel.worksheet   xlapp = new Excel.application xlworkbook = xlapp.workbooks.open(xxx) and here is the line of error !!!!     it seems to be a problem with the security privileges of the users, i have been told to find the excel application in Component services - COM+ and change it's security, but the problem is that i can't find the excel application in COM+ so i have tried this: Component services - mycomputer - properties - COM security - Edit default(for acces, launch and activiation permissions) and grant it for Network Service, USers and IIS_IUsers and still that did not work out.   any solution?  

Which version of Excel to install for a calculated measure?

I have a 64bit server running SSAS 2010 and I keep getting an ExcelMDX error when processing my cube. We do use an Excel function called FINV() in a calculated measure. I installed Excel 2007 on the SSAS 2010 server but this did not help (I also tried Excel 2010). I can start Excel on the server so I know it is installed. Does it matter whether I install Excel 32bit or 64bit on the server? How do I verify that Excel is installed correctly for SSAS 2010? Errors and Warnings from Response  MdxScript(Sales and Returns) (94, 8) The '[Excel].[FINV]' function does not exist.Kerry

Problem Installing .Net Framework Version 4.0

I am trying to install .net 4 on my Vista business machine SP2. It however continually fails with "class not registered" error. No matter what i try and do i cannot get it to install. Has anyone come across this error before, was there a resolution? I need this to be able to install VS2010 on my machine.   Thankyou

data type problem in import data from excel file


Dear All,

I am importing the data from excel file using following code.

connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(strFolderFileName) & ";Extended Properties=HTML Import;"
                conn = New OleDbConnection(connstr)
                Dim strSQL As String = "SELECT * FROM [" & strWorkSheetName & "]"

                Dim cmd As New OleDbCommand(strSQL, conn)

                Dim da As New OleDbDataAdapter(cmd)

Now the problem is if a coulmn vlaue start with a number value like "15" then the other string value like "W15" in that column is ignored in the datatable.

eg. The excel column value     Column1


Restore problem with version '' on sharepoint foundation pls help !!!


Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. Tht Foundation and cannot be restored to a server running the current version. Tht Foundation and

Restore problem with version '' on sharepoint foundation pls help !!!

Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. Tht Foundation and cannot be restored to a server running the current version. Tht Foundation and cannot be restored to a server running the current version.
The backup file should be restored to a server with version '' or later

Am getting the above error while trying to restore the backup of a sitecollection developed on development server to another development server .
Kindly let me know where am doing wrong using Sharepoint managementShell with foll. cmdlet,
(Restore-SPSite -Identity URL -Path C:\....\.bak -force)
Thanks in advance !!!!

Problem with ajaxtoolkit version 4


Dear friends ,

  I was working on an asp.net 3.5 website and used ajaxtoolkit in it and when I use it in my page it was registered as below

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

and it was working well even After I upgraded my wevbsite to .net version 4

but when I started a new website from scratch in vs2010 using .net4 when I use ajax toolkit in this new site it is registered as folowing

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

and when I run the page I get the error

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

I don't Know what is the reason for this

I noticed another thing

in my old website I was using thckbox script by using the files

common.js, jquery-1.3.2.js,jquery.thickbox.js

and puting them in a Javascript folder ad then registering them in Script manager as following

<asp:ScriptManager ID="ScriptManager1" runat="server">
            <asp:ScriptReference Path="~/Javascrip

Problem with Linked servers from sql 2005 to Excel file


I am probably doing something stupid BUT I am creating a linked server to an excel file, I have done this on sql2005sp2x64 using the ace ole 12 provder, and replicated on another machine running sql2005sp2x32 using the jet4 provider and I am having the same problem on both.  I have turned allow inprocess option on on both providers.  I as an administrator on the machine where the database and datafile are residing have no problem accessing the linked server and the file underneath however any enduser that is not in the local administrators group gets the error   Cannot initialize the data source object of OLE DB provier "Either provider I have tried" for linked server    SQL Server Error 7303.  I have checked file permissions, and they are open to the world, I have tried both use existing authentication and use no authentication when accessing the linked server.  and I have tried endless different combinations of providers and provider strings.  I have went as far as having the enduser create a linked server to an excel file on his local machine (which he is admin on and I am not)   and he can access the file .. and I can not.  so I am just assuming there is some sort of security setting somewhere .. that I am just missing.



Excel problem


Hi all,

             I am trying to fetching the data from Book1.xlsx file. The program is not working and throws an exception.Please check the code and tell me where I am doing the mistake?


protected void Page_Load(object sender, EventArgs e)
        string con = ConfigurationManager.ConnectionStrings["xlsx"].ConnectionString;

        using (OleDbConnection myConnection = new OleDbConnection(con))
                OleDbCommand myCommand = new OleDbCommand("SELECT * FROM [Cities$]", myConnection);
                 OleDbDataReader reader = myCommand.ExecuteReader();

                    GridView1.DataSource = reader;
            catch (Exception ex)
                Response.Write("An error: " + ex.Message);

The exception is:

An error: The Microsoft Office Access database engine cannot open or write to the file ''. It is alre

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