问题描述
我正在寻找一种方式来基本上将Excel文件扩展名为.xls的Excel文件夹转换成.xlsm。我意识到你可以自己进入excel表并手动执行,但是有没有办法用代码呢?具体使用任何类型的库?
I'm looking for a way to essentially take a folder of excel files that are the old 2003 file extension .xls and convert them into .xlsm. I realize you can go into the excel sheet yourself and manually do it, but is there anyway to do it with code? Specifically using any sort of library?
推荐答案
这不是我的代码,但是之前我已经使用了ClosedXML,它是真棒。我发现这个常见问题是否支持Excel 2003,它看起来应该适合你...
This is not my code, but I have used ClosedXML before and it is awesome. I found this on the FAQ asking if it supports Excel 2003 which looks like it should work for you...
为了澄清,这使用Office Interop库不是closedXML,但是我提到它会导致您需要进行任何其他修改。
To clarify, this uses the Office Interop library not closedXML, but I mentioned it incase you had any additional modifications you needed.
public void Convert(String filesFolder)
{
files = Directory.GetFiles(filesFolder);
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Open(file);
wb.SaveAs(Filename: file + "x", FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
wb.Close();
app.Quit();
}
这里是链接:
希望它有帮助:D
这篇关于将Excel 2003文件以编程方式转换为2007+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!