0

Below is my Code to show Excel

    objExcel = new Microsoft.Excel.Interop.Application();
object objOpt = System.Reflection.Missing.Value;
            objExcel.Visible = true;
    objExcel.Workbooks.Open(fi.FullName,
                    objOpt, objOpt, objOpt, objOpt, objOpt, objOpt, objOpt,
                    objOpt, objOpt, objOpt, objOpt, objOpt, objOpt, objOpt);

Now the problem is if i have xls file made with excel 2003 it will work if the file is made with excel 2007,2010 then it won't open.Gives the error File is not in recognizable form Same code runs fine in win7.

Anychanges i need to do in reading excel file of both 2003 and 2007.

Note:Both files created in excel 2003 and 2007 has extension .xls

1 Answer 1

1

If you make an Excel file programmatically and name it with the .xls extension from Excel 2007 or 2010, you may be making an Open XML (.xlsx) file unknowingly, as this is the default save format for those versions of Excel. Essentially, if you are hard coding the file name, you may be saving an .xlsx file with the .xls extension, which would explain why you can't open the files. Try renaming the files generated from Excel 2007 to the .xlsx extension and see if you can open them.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.