Link to home
Start Free TrialLog in
Avatar of kravindra
kravindra

asked on

How to copy the XLSX file to XLS file using C#

I want copy the data from XLSX file to XLS file in c#
Avatar of kris_per
kris_per


You can pen the xlsx file programmatically using excel interop and save it as xls file.

Excel.Application oXls = new Microsoft.Office.Interop.Excel.ApplicationClass();
                    
object oMissing = System.Reflection.Missing.Value;

                   
                   Excel.Workbook oSpr = oXls.Workbooks.Open("ExcelData.xlsx", oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
                   object fileFormat = Excel.XlFileFormat.xlXMLSpreadsheet;
                
                   
                    oSpr.SaveAs("ExcelData.xls", ref fileFormat, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
                    oSpr.Close();
                    oXls.Quit();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kris_per
kris_per

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial