使用excel 2013的c#编程语言另存为 [英] c# programming language using excel 2013 save as

查看:59
本文介绍了使用excel 2013的c#编程语言另存为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何保存为.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆