vba 关于如何部署和共享 VSTO 解决方案的最佳内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2081040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
best content on how to deploy and share a VSTO solution
提问by leora
with the push to leverage visual studio and dotnet with office based solutions, especially excel, where is the best article or information on how having office sheet with additional binaries and assemblies is sharable.
随着基于 Office 的解决方案(尤其是 excel)利用 Visual Studio 和 dotnet 的推动,关于如何共享带有附加二进制文件和程序集的 Office 工作表的最佳文章或信息在哪里。
- Do this external code get packaged with the spreadsheet
- what if people start emailing the spreadsheet around. Is there any overhead of this additional assemblies. Is there risk of the binaries getting detached from the spreadsheet
- 是否将此外部代码与电子表格打包在一起
- 如果人们开始通过电子邮件发送电子表格会怎样。这个额外的程序集是否有任何开销。是否存在二进制文件与电子表格分离的风险
It seems like microsoft has been pushing VSTO for over 5 years nowbut you read lots of mixed reviews and issues. Are we at the point where companies that do large VBA excel solutions can fully migrate over to dotnet without any real worries?
微软似乎已经推动 VSTO 超过 5 年了,但你读到了很多褒贬不一的评论和问题。我们是否处于执行大型 VBA excel 解决方案的公司可以完全迁移到 dotnet 而无需任何真正担心的地步?
回答by Gabriel McAdams
First of all, I want to answer your question on whether or not VSTO is ready for larger implementations. The answer is YES! Especially if the alternative is VBA. You have the entire .Net framework available, you can use web services, ADO.Net (better still, with the enterprise library). You can still write code that looks a lot like VBA, but is much more powerful. You can get more information by reading Walkthrough: Creating Your First Document-Level Customization for Excel. This pagewill give you an idea of what VSTO features are available to you.
首先,我想回答您关于 VSTO 是否已准备好进行更大规模实施的问题。答案是肯定的!特别是如果替代方案是 VBA。您拥有完整的 .Net 框架可用,您可以使用 Web 服务 ADO.Net(使用企业库更好)。您仍然可以编写看起来很像 VBA 但功能更强大的代码。您可以通过阅读演练:为 Excel 创建您的第一个文档级自定义来获取更多信息。 此页面将让您了解哪些 VSTO 功能可供您使用。
Now, to answer your question on deployment.
现在,回答您关于部署的问题。
It depends on whether you are making an Add-In or a document level customization. If its an Add-In, then you must install it on each client, and any passing around of documents will not effect that (Add-Ins are at the application level, and not at the individual document level).
这取决于您是在制作插件还是文档级自定义。如果它是一个加载项,那么您必须在每个客户端上安装它,并且任何文件的传递都不会影响它(加载项在应用程序级别,而不是在单个文档级别)。
I assume that you are talking about a document level customization, so I will center my answer around that.
我假设您正在谈论文档级别的自定义,因此我将围绕此进行回答。
When you create a document level customization, the assemblies are not loaded into the excel file (as they are with VBA). Instead, a document property is added telling the application that this document contains a manifest file (and tells it of the manifest file's location). The manifest file contains links to the assembly that makes up your customization.
创建文档级自定义时,程序集不会加载到 Excel 文件中(就像使用 VBA 时一样)。相反,添加了一个文档属性,告诉应用程序该文档包含一个清单文件(并告诉它清单文件的位置)。清单文件包含指向组成您的自定义的程序集的链接。
As with any .Net application, there are sometimes other (referenced) assemblies that also need to be deployed. Not always are these assemblies in the GAC, so they would have to be located in the same folder as your executing assembly (in this case, your customization assembly). You don't necessarily have to place your assemblies in the same location as your excel file, though.
与任何 .Net 应用程序一样,有时也需要部署其他(引用)程序集。这些程序集并不总是位于 GAC 中,因此它们必须与您的执行程序集(在本例中为您的自定义程序集)位于同一文件夹中。不过,您不必将程序集放置在与 excel 文件相同的位置。
There are a few ways you can deploy the customization.
有几种方法可以部署自定义。
- You can store all of the assemblies and the excel file in a folder and run the application that way (if the excel file is passed around, the users must pass around the entire folder).
- You can run an setup program that installs the assemblies to a specific folder on the users computer, and specifies the manifest at that location (if the excel file is passed around, the users must also pass around the setup program).
- You can install the assemblies in a network locationand specify in the document properties, that the manifest and the assemblies are all at that network location (if the excel file is passed around, nothing needs to be passed along with it - but there are security settings that need to be made. Read this pagefor more information).
- 您可以将所有程序集和 excel 文件存储在一个文件夹中并以这种方式运行应用程序(如果传递 excel 文件,则用户必须传递整个文件夹)。
- 您可以运行安装程序,将程序集安装到用户计算机上的特定文件夹,并在该位置指定清单(如果传递 excel 文件,用户也必须传递安装程序)。
- 您可以将程序集安装在网络位置并在文档属性中指定清单和程序集都位于该网络位置(如果传递 excel 文件,则不需要随同传递任何内容 - 但有安全性需要进行的设置。阅读此页面了解更多信息)。
Any way that you decide to do this, here is the pageyou need to read in order to understand the document properties that enable the customization.
无论您决定以何种方式执行此操作,这里都是您需要阅读的页面,以了解启用自定义的文档属性。
You need to make sure all of your users have the prerequisites installed. The easiest way to do this is to give them all a setup program. If you create a setup project for your customization, you can setup the bootstrapper to automatically install the prerequisites. You can also do this if you use ClickOnceto install the customization. This pagewill give you all the information you need to know regarding deployment.
您需要确保所有用户都安装了先决条件。最简单的方法是给他们一个安装程序。如果为自定义创建安装项目,则可以设置引导程序以自动安装先决条件。如果您使用ClickOnce安装自定义,也可以执行此操作。 此页面将为您提供有关部署所需的所有信息。
Here are some other helpful links you will need to see:
以下是您需要查看的其他一些有用链接:
- Application Manifests for Office Solutions (2007 System)
- Deployment Manifests for Office Solutions (2007 System)
- Application and Deployment Manifests in Office Solutions
I hope this helps. Once you read all of this information, I think you'll agree that VSTO is a much better choice than VBA. You just have to plan your deployment carefully.
我希望这有帮助。一旦您阅读了所有这些信息,我想您会同意 VSTO 是比 VBA 更好的选择。您只需要仔细规划您的部署。
回答by Chris Ridenour
I created a Excel add-on and deployed it to a server. Then I passed around two links, the setup.exe file and the link to the actual Workbook. The workbook file never changed - it's purpose was to open and load the add-on which was now in the user's Add/Remove Programs. The add-on itself would check for updates on startup.
我创建了一个 Excel 插件并将其部署到服务器。然后我传递了两个链接,setup.exe 文件和指向实际工作簿的链接。工作簿文件从未改变 - 它的目的是打开和加载现在在用户的添加/删除程序中的加载项。附加组件本身会在启动时检查更新。
So if they start emailing the workbook around, great! I believe in theory, the workbook would download the add-on if it was missing, but I don't have a fresh computer around to test that. If it doesn't, it's just a simply exe to install (which will update on launch anyhow, so outdated isn't an issue).
因此,如果他们开始通过电子邮件发送工作簿,那就太好了!我相信理论上,如果缺少附加组件,工作簿会下载它,但我没有新的计算机来测试它。如果没有,它只是一个简单的 exe 安装(无论如何都会在启动时更新,所以过时不是问题)。
回答by dong
For document-level deployment, I recommend the following three links:
对于文档级部署,我推荐以下三个链接:
https://msdn.microsoft.com/en-us/library/ms268758(v=vs.90).aspx
How do you assign the Assembly Location of an Excel VSTO Installation?
Unlike application-level solution, document-level has 2 special properties: _AssemblyLocation and_AssemblyName, which indicate the *.vsto position. To set these properties by install path, a custom action project should be created to record the target path when installing, and packaged together with setup.exe. Then you could put your excel file anywhere (on local machine) and open it in the correct way.
与应用程序级解决方案不同,文档级有 2 个特殊属性:_AssemblyLocation 和_AssemblyName,它们指示 *.vsto 位置。要通过安装路径设置这些属性,需要创建一个自定义动作项目,记录安装时的目标路径,并与setup.exe一起打包。然后你可以把你的 excel 文件放在任何地方(在本地机器上)并以正确的方式打开它。