[英]How to tell if Office Primary Interop Assemblies are installed on a system?
I have a program that currently outputs Excel via SpreadsheetML files. 我有一个程序当前通过SpreadsheetML文件输出Excel。 I build these using streams.
我使用流构建这些。 This is very space inefficient for Excel;
这对于Excel来说空间非常低; the files can be 5 to 6 times as large as other Excel binary formats.
文件的大小是其他Excel二进制格式的5到6倍。
I would like to output a binary excel format such as .xls or .xlsx, but I don't want to have the installation of the program depend on Office. 我想输出.xls或.xlsx等二进制excel格式,但我不想让程序的安装依赖于Office。 Some users might have it installed, some might not.
有些用户可能已经安装了它,有些则没有。 How can I handle this gracefully?
我该如何优雅地处理呢? Is it possible to not have an assembly as a dependency but based on the user enabling binary output still use the assembly?
是否可以不将程序集作为依赖项,而是基于用户启用二进制输出后仍使用该程序集?
Edit: 编辑:
In reviewing some old questions, I realized I should have been asking how to check if the Office PIA are on the system, use them if available, but gracefully handle the case when the yare not and use SpreadsheetML. 在回顾一些旧问题时,我意识到我应该一直在问如何检查Office PIA是否在系统上,如果可用,请使用它们,但是如果是的话,请优雅地处理此问题,并使用SpreadsheetML。
If your base programming platform is Java you can use POI . 如果您的基本编程平台是Java,则可以使用POI 。 If it's .NET you can use NPOI (a port of POI, actively under development).
如果是.NET,则可以使用NPOI (POI端口,正在积极开发中)。
Most of the features are supported by these libraries. 这些库支持大多数功能。 You need not install Office, just include the corresponding libraries in your program.
您无需安装Office,只需在程序中包含相应的库即可。
rAm. 内存。
Do you have a specific requirement for a binary file vs. some other format that Excel will read nicely? 您对二进制文件和Excel能够很好地读取的其他格式有特定要求吗? Will the old trick of outputting an HTML table with .xls extension work for your application?
输出带有.xls扩展名的HTML表的旧技巧对您的应用程序有效吗? Excel will render formatting properly and I think you can even embed formulas in the table cells and they will be rendered in Excel too...
Excel将正确呈现格式, 我想您甚至可以将公式嵌入表格单元格中,它们也将在Excel中呈现...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.