使用excel 2013的c#编程语言另存为 [英] c# programming language using excel 2013 save as
问题描述
如何保存为.xlsm格式的文件
您好,
您需要指定文件格式(第二个参数)到
SaveAs 方法。
例如,在Excel 2007中-2016,如果ActiveWorkbook不是xlsm文件,则会失败
ActiveWorkbook.SaveAs" d:\test.xlsm" 跨度>
的此代码将始终有效
ActiveWorkbook.SaveAs" d:\test.xlsm" ;, FILEFORMAT:= 52  跨度>
" 52 = xlOpenXMLWorkbookMacroEnabled = XLSM(在2007-2016年宏的)跨度>
作为用于C#,下面的代码就像我的机器上安装了Excel 2013的魅力一样:
Application.ActiveWorkbook.SaveAs(@" H:\ wb.xslm" ,Excel.XlFileFormat.xlOpenXMLWorkbookMacroEnabled,
Type.Missing,Type.Missing,Type.Missing,Type.Missing,Excel.XlSaveAsAccessMode.xlNoChange,Type.Missing,
Type.Missing,Type.Missing,类型.Missing,Type.Missing
);
跨度>
How do I save as a .xlsm formatted file
Hello,
You need to specify the file format (the second argument) to the SaveAs method.
For example, in Excel 2007-2016, this will fail if the ActiveWorkbook is not an xlsm file
ActiveWorkbook.SaveAs "D:\test.xlsm"
This code will always work
ActiveWorkbook.SaveAs "D:\test.xlsm", fileformat:=52
' 52 = xlOpenXMLWorkbookMacroEnabled = xlsm (with macro's in 2007-2016)
As for C#, the following code works like a charm on my machine with Excel 2013 installed:
Application.ActiveWorkbook.SaveAs(@"H:\wb.xslm", Excel.XlFileFormat.xlOpenXMLWorkbookMacroEnabled, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing );
这篇关于使用excel 2013的c#编程语言另存为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!