保存 VSTO 工作簿的非 VSTO 副本

发布于 2024-08-03 02:40:30 字数 309 浏览 2 评论 0原文

我正在尝试将 ListObject 从 .NET 3.5 Excel 2007 VSTO 工作簿保存到新工作表(完成),并将该新工作表保存到新工作簿(完成),而该工作簿不需要 VSTO 自定义文件(!!!!!) 。

有人有这样的运气吗?我取得成功的唯一方法就是另存为 CSV 文件,但在本例中这并不完全可接受。我不想只是为了复制回 XLS 文件而保存到 CSV。

worksheet.SaveAs(saveDialog.FileName, Excel.XlFileFormat.xlOpenXMLWorkbook)

I am trying to save a ListObject from a .NET 3.5 Excel 2007 VSTO Workbook to a new sheet (done) and save that new sheet to a new workbook (done) without that workbook requiring the VSTO customization file (!!!!!).

Has anyone had any luck with this? The only way I've had any success is just saving as a CSV file but that's not exactly acceptable in this case. I'd rather not save to a CSV just to copy back to a XLS file.

worksheet.SaveAs(saveDialog.FileName, Excel.XlFileFormat.xlOpenXMLWorkbook)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

厌倦 2024-08-10 02:40:30

如果我理解正确的话,您不希望新的工作簿文件依赖或加载任何 VSTO 自定义?

尝试使用此 MSDN 链接从工作簿中删除 VSTO 自定义程序集。

If I understand correctly, you do not want the new workbook file to depend or load any VSTO customization?

Try this MSDN link to remove VSTO customization assemblies from workbooks.

断肠人 2024-08-10 02:40:30

好吧,这最终对我不起作用,这就是原因。答案仍然是正确的,但我想为未来的用户澄清一下。

我有一个 ListObject,想使用 VSTO 保存在外部工作簿中。创建新的工作表并使用“另存为”会将当前工作簿重命名为该工作簿,因此我必须关闭整个工作簿才能删除自定义项。

我从一开始就应该做的是:

创建工作表并在所述工作表上填充 ListObject。然后使用不带参数的 .Copy() 创建新工作簿。那么我如何找到工作簿呢?我只是将工作表命名为 Now.Ticks.ToString(),并查找 ActiveSheet.Name 为 Now.Ticks.ToString() 的任何打开的工作簿。对于此应用程序,不需要比这更深入。我保存了该工作簿,然后关闭了它。由于工作簿是使用 Copy 创建的,因此没有任何自定义内容并且问题已解决。

Ok this didn't end up working for me and here's why. The answer is still correct but I want to clarify for future users.

I have a ListObject I wanted to save in an external workbook using VSTO. Creating a new Worksheet and using SaveAs would rename the current Workbook to that and therefore I would have to close the entire workbook to remove the Customization.

What I should have done from the beginning is this:

Create the Worksheet and populate the ListObject on said Worksheet. Then use .Copy() with no parameters to create a new workbook. How do i find the workbook then though? I simply named the Worksheet Now.Ticks.ToString() and looked for any open workbook with the ActiveSheet.Name as Now.Ticks.ToString(). For this application, it doesn't need to be more in depth then that. I the saved THAT workbook and then closed it. Since the workbook was created with Copy it had no customizations on it and problem solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文