如果 Excel 文件源自其他服务器,则阻止使用本地安装的 VSTO
我有一个 Excel 文件,它使用 VSTO 来检索和更新数据。它被部署到各种环境(开发、暂存、生产……)。
我想确保从暂存下载工作表的用户不会将数据发送到生产,因为该工作表使用来自生产的(本地安装的)VSTO。
有办法防止这种情况吗?
I have an Excel file which uses VSTO to retrieve and update data. This is deployed to various environments (Development, Staging, Production,...).
I want to make sure that a user who downloads a sheet from Staging isn't sending data to Production, because the sheet is using the (locally installed) VSTO which came from Production.
Is there a way to prevent this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
生产/登台/测试的整个概念是一个定义,软件不会神奇地理解,所以处理这个问题的唯一方法是将您使用的任何逻辑编码到您的 vsto 加载项中。
我们处理此问题的方法是,加载项将检查每个工作表中是否有名为:MYADDIN_ISTEST 的自定义属性。如果找到此属性,则加载项将连接到测试数据库(针对该工作表),如果没有找到,它将连接到生产数据库。您可以根据对您的环境有意义的方式想到此主题的各种变体,但我们这样做的原因是重命名或移动文件(带有测试数据)可以由任何人轻松完成,无需他/她意识到后果。进入文档的自定义属性并删除该测试属性只是您特意要做的事情。
The whole concept of prod/staging/test is a definition thing that software won't magically understand so really the only way to deal with this is to code whatever logic you use into your vsto add-in.
The way we deal with this is that the add-in will check each sheet for a custom property named like: MYADDIN_ISTEST. If this property is found then the add-in will connect to the test database (for that sheet) and if not it will connect to the production database. You can think of all sort of variations to this theme depending on what makes sense for your environment but the reason for us to do it this way is that renaming or moving a file (with testdata) can be easily done by anyone without him/her realising the consequences. Going into the document's custom properties and removing that test property is something you will only do on purpose.