我正在开发一个控制台应用程序,它将 xlsx 文件转换为 xls 文件。我不想将它从 xlsx 重命名为 xls,因为它将在 excel 2007 中打开,但它会在 excel 2003 中显示为损坏的文件。寻找一种加载文档的方法,然后将其保存为 xls 格式.
我当前的代码只是将 xlsx 重命名为 xls
string fileName = @"C:\Users\L-3\Desktop\my.xlsx";
string svfileName = @"C:\Users\L-3\Desktop\ssc\my1.xls";
object oMissing = Type.Missing;
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Open(fileName, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
wb.SaveAs(svfileName, XlFileFormat.xlOpenXMLTemplate, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
app.Quit();