none
Excel File created using Microsoft.Office.Interop.Excel 12.0.0 does not open in Excel 2007 RRS feed

  • Question

  • Hi Guys,

     

    I am creating a excel file using the 12.0 version of the Microsoft.Office.Interop.Excel dll. After I edit it using office 2007 and save it it becomes unreadable. Also if I rename the file in to .zip then the package is corrupt.

    Is this a known issue?? Also is there any work around to it?? Any help will be utmost appreciated.

     

    Thanks and Regards

    Kunal Ghogale

    Friday, December 3, 2010 11:30 AM

Answers

  • Hi Kunal,

             >>I have 2010 installed on the system that creates the files on the fly

             >> I have an application that creates these excels on the fly using PIA 12.0

             It seems that you installed Office 2007 and Office 2010 on the same computer or have you installed them on the same computer. If so, the issue may due to that. Microsoft does not recommend install different version on the same computer, it will encounter unpredictable issues. The solution is to clean your machine with only one PIA left, such as just keep Office2007 and PIA12.0.

            Make sure whether you dispose related resources when you create the Excel file.

            If above suggestions do not help you, would you mind share us with you code and tell us your project type and development environment.

            I hope these can help you and feel free to follow up.

    Best Regards,

    Bruce Song

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Bruce Song Wednesday, December 8, 2010 7:54 AM
    • Marked as answer by Bruce Song Tuesday, December 14, 2010 9:46 AM
    Wednesday, December 8, 2010 7:54 AM

All replies

  •  Hi Kunal,

                Welcome to MSDN forum and I am glad to help with you.

    I am creating a excel file using the 12.0 version of the Microsoft.Office.Interop.Excel dll.After I edit it using office 2007 and save it it becomes unreadable. Also if I rename the file in to .zip then the package is corrupt

    Do you mean that you create an Excel file and edit it via PIA12.0, but after saving, you can’t open it? While on my computer, I can successfully open the created Excel file. Could you mind providing the code for me to analyze in details? And below is my code:

    static void Main(string[] args)
    
        {
    
          Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
    
     
    
          if (xlApp == null)
    
          {
    
            Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct.");
    
            return;
    
          }
    
          xlApp.Visible = true;
    
     
    
          Workbook wb = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
    
          Worksheet ws = (Worksheet)wb.Worksheets[1];
    
     
    
          if (ws == null)
    
          {
    
            Console.WriteLine("Worksheet could not be created. Check that your office installation and project references are correct.");
    
          }
    
     
    
          // Select the Excel cells, in the range c1 to c7 in the worksheet.
    
          Range aRange = ws.get_Range("C1", "C7");
    
     
    
          if (aRange == null)
    
          {
    
            Console.WriteLine("Could not get a range. Check to be sure you have the correct versions of the office DLLs.");
    
          }
    
     
    
          // Fill the cells in the C1 to C7 range of the worksheet with the number 6.
    
          Object[] argsValue = new Object[1];
    
          argsValue[0] = 6;
    
          aRange.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, aRange, argsValue);
    
     
    
          // Change the cells in the C1 to C7 range of the worksheet to the number 8.
    
          aRange.Value2 = 8;
    
     
    
          wb.SaveCopyAs(@"D:\aa.xlsx");
    
          
    
        }
    
     
    
    
    

    If I haven’t misunderstood your scenario, the issue may due to the PIA12.0, so please reinstall it, you can download form this website: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=59daebaa-bed4-4282-a28c-b864d8bfa513&displaylang=en

    I hope it can help you and feel free to follow up.             

    Best Regards,

    Bruce Song

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, December 6, 2010 6:16 AM
  • Hi Bruce,

    Thanks for the reply but i think you have misunderstood. I have an application that creates these excels on the fly using PIA 12.0 but when I open the excels using office 2007 something goes wrong with them. It allows me to save using 2007 but on trying to read the file again it says file is corrupted.

    Any know issues with the PIA like that?? I have 2010 installed on the system that creates the files on the fly . Will that make a difference?

    Monday, December 6, 2010 6:51 AM
  • Hi Kunal,

             >>I have 2010 installed on the system that creates the files on the fly

             >> I have an application that creates these excels on the fly using PIA 12.0

             It seems that you installed Office 2007 and Office 2010 on the same computer or have you installed them on the same computer. If so, the issue may due to that. Microsoft does not recommend install different version on the same computer, it will encounter unpredictable issues. The solution is to clean your machine with only one PIA left, such as just keep Office2007 and PIA12.0.

            Make sure whether you dispose related resources when you create the Excel file.

            If above suggestions do not help you, would you mind share us with you code and tell us your project type and development environment.

            I hope these can help you and feel free to follow up.

    Best Regards,

    Bruce Song

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Bruce Song Wednesday, December 8, 2010 7:54 AM
    • Marked as answer by Bruce Song Tuesday, December 14, 2010 9:46 AM
    Wednesday, December 8, 2010 7:54 AM