如何将多个Excel文件合并为具有多个工作表的单个Excel工作簿?

时间:2022-01-20 15:21:25

I need to develop a service (either WCF or Java) that can take multiple single-sheet Excel files and combine them into a single Excel workbook with multiple sheets. The Excel files are actually exported from crystal reports as individual files. Following are some of the requirements of the service:

我需要开发一个服务(WCF或Java),它可以获取多个单页Excel文件,并将它们组合成一个包含多个工作表的Excel工作簿。 Excel文件实际上是从Crystal报表导出为单个文件。以下是该服务的一些要求:

1) Should preserve all the formatting including images, color, font etc. 2) Should allow inserting of custom macros into the target file. The macros needs to be run only on the client side when they open the file.

1)应保留所有格式,包括图像,颜色,字体等.2)应允许自定义宏插入目标文件。只有在打开文件时,才需要在客户端运行宏。

I would like to know what technology/libraries is best suited for above functionality. Should I develope the service in WCF+VSTO or in Java using libraries like Apache POI, JXLS etc?

我想知道哪些技术/库最适合上述功能。我应该使用Apache POI,JXLS等库在WCF + VSTO或Java中开发服务吗?

3 个解决方案

#1


I obviously can't design the whole thing for you, but I can certainly suggest that you learn about the Excel API, because I'm sure you're going to have to use it to achieve what you are trying to.

我显然不能为你设计整个东西,但我当然可以建议你了解Excel API,因为我确信你将不得不用它来实现你想要的东西。

These days Microsoft offers it in the form of Visual Studio Tools for Office. Although the preceding MSDN link will help you get started, you may also want to purchase this book.

目前,Microsoft以Visual Studio Tools for Office的形式提供它。虽然前面的MSDN链接可以帮助您入门,但您可能还想购买此书。

#2


As far as I know, Excel is the only option if you want to manipulate VBA code.

据我所知,如果你想操纵VBA代码,Excel是唯一的选择。

SpreadsheetGear for .NET, Actuate e.Spreadsheet for Java and various other tools will enable you to combine multiple single sheet workbooks into a single workbook with varying levels of performance and fidelity, but I am quite sure that none of them have APIs for adding VBA code (SpreadsheetGear and some of the others will read and write VBA code, but not allow you to add VBA code).

用于.NET的SpreadsheetGear,用于Java的Actuate e.Spreadsheet和各种其他工具将使您能够将多个单页工作簿组合到具有不同级别的性能和保真度的单个工作簿中,但我确信它们都没有用于添加VBA的API代码(SpreadsheetGear和其他一些将读取和写入VBA代码,但不允许您添加VBA代码)。

Disclaimer: I own SpreadsheetGear LLC

免责声明:我拥有SpreadsheetGear LLC

#3


Use the Automation (COM/ActiveX) features of Excel.

使用Excel的自动化(COM / ActiveX)功能。

You can do this through Visual Basic or C++ or any other language (e.g MATLAB or JSDB) that has decent COM/ActiveX support.

您可以通过Visual Basic或C ++或具有良好COM / ActiveX支持的任何其他语言(例如MATLAB或JSDB)来完成此操作。

I've never been able to find the docs for the Excel object model, but here's an example on MSDN.

我从来没有能够找到Excel对象模型的文档,但这是MSDN上的一个示例。

#1


I obviously can't design the whole thing for you, but I can certainly suggest that you learn about the Excel API, because I'm sure you're going to have to use it to achieve what you are trying to.

我显然不能为你设计整个东西,但我当然可以建议你了解Excel API,因为我确信你将不得不用它来实现你想要的东西。

These days Microsoft offers it in the form of Visual Studio Tools for Office. Although the preceding MSDN link will help you get started, you may also want to purchase this book.

目前,Microsoft以Visual Studio Tools for Office的形式提供它。虽然前面的MSDN链接可以帮助您入门,但您可能还想购买此书。

#2


As far as I know, Excel is the only option if you want to manipulate VBA code.

据我所知,如果你想操纵VBA代码,Excel是唯一的选择。

SpreadsheetGear for .NET, Actuate e.Spreadsheet for Java and various other tools will enable you to combine multiple single sheet workbooks into a single workbook with varying levels of performance and fidelity, but I am quite sure that none of them have APIs for adding VBA code (SpreadsheetGear and some of the others will read and write VBA code, but not allow you to add VBA code).

用于.NET的SpreadsheetGear,用于Java的Actuate e.Spreadsheet和各种其他工具将使您能够将多个单页工作簿组合到具有不同级别的性能和保真度的单个工作簿中,但我确信它们都没有用于添加VBA的API代码(SpreadsheetGear和其他一些将读取和写入VBA代码,但不允许您添加VBA代码)。

Disclaimer: I own SpreadsheetGear LLC

免责声明:我拥有SpreadsheetGear LLC

#3


Use the Automation (COM/ActiveX) features of Excel.

使用Excel的自动化(COM / ActiveX)功能。

You can do this through Visual Basic or C++ or any other language (e.g MATLAB or JSDB) that has decent COM/ActiveX support.

您可以通过Visual Basic或C ++或具有良好COM / ActiveX支持的任何其他语言(例如MATLAB或JSDB)来完成此操作。

I've never been able to find the docs for the Excel object model, but here's an example on MSDN.

我从来没有能够找到Excel对象模型的文档,但这是MSDN上的一个示例。