locked
C# Excel file wasnt found RRS feed

  • Question

  • User1527544554 posted

    i got a problem the files xlsx cannot be found look at the code the bold part is where it says this error (XlPlatform)

                Excel.Application xlApp;
                Microsoft.Office.Interop.Excel.Application xl = new Microsoft.Office.Interop.Excel.Application();
    
                Excel.Workbook xlWorkBook;
                Excel.Worksheet xlWorkSheet;
                object misValue = System.Reflection.Missing.Value;
    
                xlApp = new Excel.Application();
                xlWorkBook = xlApp.Workbooks.Open(Ubtn.Text, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
    

    The Error:
     

    'Update.xlsx' could not be found. Check the spelling of the file name, and verify that the file location is correct.
    
    If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.

    and the name of the file isnt Update.xlsx its File.xlsx 

    Wednesday, November 23, 2011 12:31 PM

All replies

  • User1292382518 posted

    What is the value of Ubtn.Text? Is it a textbox? It appears that the value of Update.xlsx is coming from that text box.

    Wednesday, November 23, 2011 1:31 PM
  • User1527544554 posted

    yes it is a textbox and even if i write there just the name it says Update.xlsx

    Wednesday, November 23, 2011 1:48 PM
  • User1527544554 posted

    never mind u were right thanks :D

    Wednesday, November 23, 2011 1:50 PM
  • User1292382518 posted

    We are Glad.

    Hope you have found what you were looking for.

    Saturday, November 26, 2011 3:05 AM
  • User-578657687 posted

    Hi,

    'Update.xlsx' could not be found. Check the spelling of the file name, and verify that the file location is correct.

    Ubtn.Text seems is the file path(Update.xlsx), but it could not be found, so please confirm the file path of Update.xlsx.

    The code snippet below also show how to open an excel file:

        Microsoft.Office.Interop.Excel.Application myExcelApp = new Microsoft.Office.Interop.Excel.Application();
            myExcelApp.Workbooks.Open(filePath, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
    
    Tuesday, November 29, 2011 10:23 PM
  • User1527544554 posted

    hey im getting this error:

    The Microsoft Access database engine could not find the object 'Main table'. Make sure the object exists and that you spell its name and the path name correctly. If 'Main table' is not a local object, check your network connection or contact the server administrator. 

    this is my code:

     string conn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Tzahi\Desktop\Xlsx Files\Clal data base 20110930 - Copy.xls;Extended Properties=Excel 12.0";
    
    using (OleDbConnection oledbConn = new OleDbConnection(conn))
    
    { oledbConn.Open();
    
    OleDbCommand cmd = new OleDbCommand(@"INSERT INTO [Main table] (B5, C5, D5) VALUES(1,'Fake Record','Fake Record')", oledbConn); cmd.ExecuteNonQuery();
    
    }
    Monday, December 5, 2011 12:18 PM
  • User-1910946339 posted

    My guess is that 'Main table' does not exist.  Thank you, thank you, no need to send money.

    Seriously, why have you added this new question on top the end of a previous question?  What do you think your question has to do with c# (this is a c# forum)?  I am encouraging you to think because with a little thought you may ask your questions of the right people and get a better answer.

    Monday, December 5, 2011 4:53 PM
  • User1527544554 posted

    My guess is that 'Main table' does not exist.  Thank you, thank you, no need to send money.

    Seriously, why have you added this new question on top the end of a previous question?  What do you think your question has to do with c# (this is a c# forum)?  I am encouraging you to think because with a little thought you may ask your questions of the right people and get a better answer.

    well it is in C# :D
    and there is no other forum to write it in..
    ohh and Main Table Does Exists 

    Monday, December 5, 2011 11:55 PM
  • User-1910946339 posted

    ohh and Main Table Does Exists 

    Your computer does not agree with you.

    there is no other forum to write it in..
    http://lmgtfy.com/?q=access+excel+forum

     

    Tuesday, December 6, 2011 12:31 AM