简体   繁体   English

如何判断系统上是否安装了Office Primary Interop程序集?

[英]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.

相关问题 Microsoft Office应用程序的主互操作程序集 - Primary Interop Assemblies for Microsoft Office Applications Office 2007的主要互操作程序集(PIA)-32/64位? - Primary Interop Assemblies (PIA) for Office 2007 - 32/64bit? .NET项目中的Office主互操作程序集的多个版本 - Multiple versions of Office Primary Interop Assemblies in .NET project Office互操作程序集Windows 10 - Office interop assemblies Windows 10 我可以使用Microsoft Office 2010:主要互操作程序集将word,excel转换为PDF - Can I use Microsoft Office 2010: Primary Interop Assemblies to convert word,excel to PDF .NET部署Office 2003可再发行的主互操作程序集(o2003pia.msi) - .NET Deploying Office 2003 Redistributable Primary Interop Assemblies (o2003pia.msi) Office 2003互操作仅安装了Office 2010 - Office 2003 interop with only Office 2010 installed 选择Microsoft Office主互操作程序集版本 - Selecting a Microsoft Office Primary Interop Assembly version 我可以使用Microsoft.Office.Interop.Excel在未安装Microsoft Office Pack的系统上创建Excel文件吗? - Can I use Microsoft.Office.Interop.Excel to create Excel file on the system where Microsoft Office pack is not installed? 哪里可以找到x64版本的Office Interop程序集? - Where to find x64 version of Office Interop assemblies?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM