简体   繁体   English

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

[英]How to combine multiple Excel files into single Excel workbook with multiple sheets?

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. 我需要开发一种服务(WCF或Java),该服务可以采用多个单页Excel文件并将它们合并为一个包含多张工作表的Excel工作簿。 The Excel files are actually exported from crystal reports as individual files. Excel文件实际上是从Crystal报表导出为单个文件。 Following are some of the requirements of the service: 以下是该服务的一些要求:

1) Should preserve all the formatting including images, color, font etc. 2) Should allow inserting of custom macros into the target file. 1)应保留所有格式,包括图像,颜色,字体等。2)应允许将自定义宏插入目标文件。 The macros needs to be run only on the client side when they open the file. 宏打开文件时仅需要在客户端运行。

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中开发服务吗?

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 . 如今,Microsoft以Visual Studio Tools for Office的形式提供它。 Although the preceding MSDN link will help you get started, you may also want to purchase this book . 尽管前面的MSDN链接将帮助您入门,但是您可能还需要购买这本书

As far as I know, Excel is the only option if you want to manipulate VBA code. 据我所知,Excel是您要操纵VBA代码的唯一选择。

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

Use the Automation (COM/ActiveX) features of Excel. 使用Excel的自动化(COM / ActiveX)功能。

You can do this through Visual Basic or C++ or any other language (eg MATLAB or JSDB ) that has decent COM/ActiveX support. 您可以通过Visual Basic或C ++或任何具有不错的COM / ActiveX支持的其他语言(例如MATLABJSDB )来执行此操作。

I've never been able to find the docs for the Excel object model, but here's an example on MSDN . 我从未能够找到Excel对象模型的文档,但是这是MSDN上的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM