如何在不使用Office互操作库的情况下以编程方式检测Office文档(Word,Excel)中是否存在任何宏? [英] How to programmatically detect if there is any Macro in office document (Word, Excel) without using office interop libraries?

查看:162
本文介绍了如何在不使用Office互操作库的情况下以编程方式检测Office文档(Word,Excel)中是否存在任何宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

寻找您的专业知识,以查看 

Looking for your expertise to see 

如何  以编程方式  检测Office文档(Word,Excel)中是否有任何宏而不使用office互操作库?

How to Programmatically detect if there is any Macro in office document (Word, Excel) without using office interop libraries?

我们有文件上传功能,如果用户上传包含宏的文件,我们需要拒绝它。

We have file upload feature where if the user uploads a file which contains macros in it we need to reject it.

请提供有关如何进行此操作的建议在不使用互操作库和打开文件的情况下实现。

Please provide suggestions on how this can be achieved without using interop libraries and opening the files.

谢谢

Suresh A

推荐答案

如果它是.docx,xl​​sx等,它将不会有宏。 (您可能需要充分打开该文件以确保它不是某人重命名为.docx扩展名的.doc。)

Well if it is a .docx, xlsx, etc it won't have macros. (you might need to open the file sufficiently to make sure it isn't a .doc that someone renamed to have a .docx extension).

如果是.doc(或类似)前台2007格式),事情变得更加艰难。  我们的电子邮件系统只是假设.doc文件有宏并隔离这些文件。

If it is a .doc (or similar pre office 2007 format), things are tougher.  Our email system just assumes that .doc files have macros and quarantines those files.

如果要查看.doc,您可能需要某种第三方库来打开该文件并告诉您是否有宏,因为您可能不想自己编写.doc / .xls解析器。

If you want to examine .doc you will probably want a 3rd party library of some sort to open up the file and tell you if you have macros, since you probably don't want to write a .doc/.xls parser yourself.


这篇关于如何在不使用Office互操作库的情况下以编程方式检测Office文档(Word,Excel)中是否存在任何宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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