主办MS O​​ffice文档的自定义应用程序更好的选择?自定义、应用程序、文档、MS

2023-09-04 02:46:29 作者:诗呓

我目前托管在.NET(2.0)格式的IE浏览器控件,并用它来加载Office文件,如Excel和Word正是如此:

I am currently hosting an IE Browser control in a .NET (2.0) Form and using it to load Office files such as Excel and Word thusly:

_ieCtrl.Navigate("C:\\test.xls", False);

托管和装载工作得很好,除了每当我浏览到一个文件,我psented有询问我是否要保存或打开文件对话框$ P $。 (这是标准的IE文件下载行为。)我一直想打开它当然,我不希望该对话框显示。

The hosting and loading works well except whenever I navigate to a file I am presented with a dialog that asks whether I want to save or open the file. (This is standard IE file-download behavior.) I always want to open it of course and I do not want the dialog to show.

另一个问题是,当我关闭承载IE控件和Office文档的文档不会关闭,并保留在磁盘上打开的窗户。这意味着,后续尝试通过我的应用程序打开同一文件或本机应用程序的Office将失败,因为共享冲突的。

Another issue is that when I close the window that hosts the IE control and the Office doc the document does not close and remains open on disk. This means that subsequent attempts to open the same file via my app or the native office app will fail because of the sharing violation.

有一个计划避免这种对话和清理资源之后的方法吗?我问了一个纲领性的答案,因为网络研究才取得的要修改OS级别的设置解决方案。

Is there a programmatic way of avoiding this dialog and cleaning up resources afterward? I am asking for a programmatic answer because web research has only yielded solutions that entail modifying OS-level settings.

赏金注:

我愿意接受任何解决这个问题,让我:

I am open to any solution to this issue that will allow me to:

在主机的Excel US $ p $我的应用程序中padsheet 在工作,而透明的(避免类似上面所描述的可用性问题) 避免不得不作出任何操作系统特定的变化,可能会影响其他应用程序(特别是icluding IE) 是额外的零费用(无许可的第三方库讨好)code项目和其他开放源代码资源确定 在不惹周围的DSO成帧器ActiveX控件,除非一个稳定版本开发/发现

推荐答案

是你的意图,为用户能够在一个Excel十岁上下的方式Excel文件的工作(即列,行,公式等),可能挽救回来?如果是这样的话,我看不出你如何能解决好这个问题,而不依赖于COM互操作的Excel对象模型或通过集成第三方库的Excel工作表的工作。我知道你说没有支付解决方案,但也有一些功能丰富的第三方控件在那里只是为了与Excel文件中的应用程序的工作。

Is your intention for the user to be able to work with the Excel file in an Excel-ish way (i.e. columns, rows, formulas, etc.), possibly saving it back? If this is the case, I can't see how you can solve this problem well without relying on COM Interop with the Excel object model or by integrating third-party libraries to work with the Excel sheet. I know you said no paid solutions, but there are some feature-rich 3rd-party controls out there just for working with Excel files within applications.

我注意到在您的评论到 SLaks 的最终产品是各种各样的仪表板。如果你的目的是设计AA定制的仪表板应用程序时,你有没有考虑解析Excel文件(S)中提取数据,然后presenting它在你的应用程序中的逻辑方式。这样,就不再需要直接显示和使用Excel的文件的工作,同时还允许您使用的数据的那个文件里面工作。如果您想获得该文件以外的数据,这里有两种方法很多:

I noticed in your comment to SLaks that the final product is a "dashboard of sorts". If your intention is to design a a custom dashboard application, have you considered parsing the Excel file(s) to extract the data and then presenting it in a logical manner within your application. This removes the need to directly display and work with the Excel file while still allowing you to work with the data inside that file. If you are trying to get the data outside of the file, here are two approaches among many:

您可以考虑使用Excel对象模型和COM互操作读取数据从Excel文件到您的应用程序。当然,这包括正在安装Excel的依赖,但它是一个可能性。 本文有一些伟大的$ C $下开始接触阅读这样的Excel文件。 在一个更好的办法可能是使用不具有Excel的依赖被安装在本地系统上的库。 这个答案建议使用的 Excel数据读取器库,可在codePLEX。 You might consider using the Excel object model and COM interop to read the data from the Excel file into your application. Granted, this includes a dependency on Excel being installed, but it is a possibility. This article has some great code for getting started with reading Excel files in this way. A better way might be to use a library that doesn't have a dependency on Excel being installed on the local system. This answer suggests using the Excel Data Reader library, available on CodePlex.

我知道这个答案侧步你原来的答案主办的[A]自定义应用程序的MS Office文档,但如果你真正感兴趣的是什么的数据的那些Excel的内部文件,希望这个答案将证明是有益的。

I know this answer side-steps your original answer of "hosting MS Office documents in [a] custom app," but in case what you're really interested in is the data inside those Excel files, hopefully this answer will prove helpful.

 
精彩推荐
图片推荐