.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 opening excel

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
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?  

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

Problem opening dotnet 1.1 projet on 2008 web server


 We recently upgraded to a 2008 development web server and I installed all the stuff to get dot net 1.1 app working on the server.  I can host them and they work.  My problem is that when I try to open one in VS 2003 I get the following error.  I set up the web server the same as my previous one, and I think a long time  ago I got this error when we set up current one but do not remember how to resolve it.  So I moved my project files from the old server to the new server and then I get these errors. 


The web Server reported the following error when attempting to create or open the Web Project located at the following url: Http://localhost:/MobTracker. 'Http/1.1 500 server error

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.

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 about opening Office documents in SPS2003

Hi, I have a problem about opening Office documents in SPS2003. The situation is as follows: I use the same NB in building A and building B. In building A everything is fine but in building B when I open Office documents(word, excel..) in my SPS2003 portal something happened. If documents don't need authorization these documents are opened quickly but documents that need authorization when I typed id and password documents are opened very slowly(about 5-10 minutes). So what is the reasom about this problem. Any suggestion? Thanks.

Problem with opening Office documents

How's your SP Environment, Are you happy with it? Here's my Biggest bone!#1 Issue   Annoying Prompt's when trying to Open Office Documents when accessing the sites through AD? All those who read this please state weather or not you encounter this problem, or have.This problem Usually occurs when your trying to access a SP Protected and Anonymous Site through windows Auth (AD) outside of your office LAN. when your at your home PC.Now I just would like to open a Discussion to see who faces this issue, and who doesn't and see what the common factors are in each. Thank you in advance!

having problem opening up pages correctly from web part

Hi all, I have a SL4 application that I'm trying to deploy as a webpart in Sharepoint 2010. To give you a background -- the SL project name is MyStuffApp. And there's a designated test page project called MyStuffApp.Web. Now, MyStuffApp has 2 different xaml pages, page1.xaml and page2.xaml. I've added two aspx pages on MyStuffApp.Web called page1.aspx and page2.aspx to respectively host the two xaml.  When I run the application, page1.aspx opens up. It has a hyperlinkbutton on it, which when clicked, opens up pag2.aspx. I've properly managed this on App.xaml.cs as well.  Now my problem is -- when I deploy the project as a web part, I can see page1.aspx. But when I click on that hyperlinkbutton, it doesn't display the content of page2.aspx, and I instead get the standard IE error "cannot display the webpage".  Can someone help me troubleshoot the issue? I'm very new to web parts, so I'm trying to learn things step-by-step.    Thanks.  

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


Problem on opening child window on third time



I have a button that having an attributes as follow:

btnAddColumn.Attributes.Add("onClick", "selectDetailColumn('Type1',1); return false");

It will open a child window with the following assignment.

<script language="javascript" type="text/javascript">

        function selectDetailColumn(area, testType) {
            scLeft = (window.screen.availWidth - 600) / 2;
            scTop = (window.screen.availheight - 700) / 2;
            window.open('Details.aspx?, 'PopUp', 'width=600,height=700,top=' + scTop + ',left=' + scLeft + ',toolbars=no,scrollbars=no,status=no,resizable=no');

On this details.aspx, I have button to close the form as below:

<asp:Button ID="btnClose" runat="server" Width="80" Text="Close" OnClientClick="window.close();" />

What I did is when I open the child window, I will click on the Close button. I will repeat this process again. And on the third time I open the child window again, it wont open it, but instead the page "stays loading...".

Seems like the IIS is not responding.

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.



Error opening an excel file

I'm getting this error while trying to open an excel file from my application. I tried this http://blog.crowe.co.nz/archive/2006/03/02/589.aspx but it didn't help. Excel itself opens normally, but it does not from my application. here is a screenshot of my code:
        case "xls":
          System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("ru-RU");
          Microsoft.Office.Interop.Excel.WorkbookClass wb = new Microsoft.Office.Interop.Excel.WorkbookClass();
          wb.Application.Visible = true;
          wb.Application.Workbooks.Open(fileName.ToString(), updateLinks, readOnly,
            missing, missing, missing, missing, missing,
            missing, missing, missing, missing, missing,
            missing, missing);
I didn't find a solution in another threads. Please help me... this option is cruicial in my application. Thank you!


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

Error when opening Excel document from sharepoint


Hi, I am using Sharepoint 2010 and Excel 2010 x64.

I created a document library where I host a simple excel file for testing. When I click on it , it opens in the web browser just fine.

When I chose to open it with Excel , I get this error : The document could not be opened for editing. A microsoft Sharepoint Foundation compatible application could not be found to edit the document.

I already tried as well to do a check out before opening it and it still doesn't work.

Any ideas ?

PS : same thing happens with Visio 2010.


Has anybody experienced problems opening 'protected Excel 2007 worksheets in SPS 2003?


I have added the doc icons and MIME types to my SPS2003 farm and now it works properly with Office2007 documents, with the exception of 'protected' Excel files.  In those cases where the Excel file contains a 'protected' worksheet, the user can open the doc, unprotect the worksheet and make their edits.  When they 'protect' the worksheet again and try to save the file, they get an alert that the destination file is 'read-only' and they must save it with a different name.

This only happens for 'protected' Excel 2007 docs residing on an SPS2003 site.  Protected Excel 2003 documents work fine, as do unprotected documents.  Any help y'all can be is greatly appreciated.  I only have two users who are using the protected worksheets, but they are the most vocal of my users.

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