C# – Transform a excel file in xml file in c#

c

I'm trying to open a "xls" file in c# and save as an xml,like if i did from excel.
I don't need to read the file,just to convert in xml with the same format if i did it with Microsoft Excel.
If anyone have any leads,thanks.

Best Answer

This is how i did it,if it interest anyone.

Microsoft.Office.Interop.Excel.Application _excelApp = new Microsoft.Office.Interop.Excel.Application();
                    Workbook workBook = _excelApp.Workbooks.Open(@"d:\test.xls",
                    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                    Type.Missing, Type.Missing);

                    workBook.SaveAs(@"d:\test.xml", 
                        Microsoft.Office.Interop.Excel.XlFileFormat.xlXMLSpreadsheet, 
                        null, 
                        null,
                        true,
                        true,
                        XlSaveAsAccessMode.xlNoChange,
Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges,
                        true,
                        null,
                        null,
                        false);
                    workBook.Close(null,null,null);