The Office Document Toolbox for Creating RTF Documents and Spreadsheet Files Using ABAP: Part 2 — Reading and Writing Excel Documents

  • by Cord Jastram, Ph.D., Consultant
  • December 15, 2009
As an alternative to using the COM interface (which can be cumbersome) for creating Microsoft Word and Excel files in ABAP, you can use the Office Document Toolbox, an open-source solution, to create word processing documents in Rich Text Format (RTF) and spreadsheets in Excel XLS format. Learn how to read and write Excel files using ABAP and to create a new Excel file. Also, learn how to extend the functionality of the toolbox.
Key Concept

The Office Document Toolbox is built upon two external Java libraries: the iText library (at www.lowagie.com/iText) for creating RTF documents and the Apache HSSF library (at http://poi.apache.org/hssf/index.html) for reading and writing Excel spreadsheets. The toolbox contains three ABAP object-oriented (OO) classes and a private programming interface. It also contains a Java RFC server that can run on any computer equipped with a Java runtime environment (JRE) 5 and with SAP Java Connector (SAP JCo). You don’t need a Java 2 Platform Enterprise Edition (J2EE) system; the JRE 5 is sufficient.

When you need to create Microsoft Office files, such as Microsoft Word documents and Microsoft Excel spreadsheets, from an ABAP system, you can use the Microsoft Component Object Model (COM) interface. Although this interface is a valid option, there are some challenges to using it:

  • First, you need detailed knowledge of the Office application’s API that you want to expose as the COM interface for it to function properly.

  • Second, you can’t use the COM interface in the background because you need to use an SAP GUI to use an application’s COM interface.

  • Third, using the COM interface for Office applications in ABAP necessitates technical knowledge of the tool, which not all developers may have.

To address these challenges, I developed an open-source toolbox solution as an option for ABAP developers creating word processing documents in Rich Text Format (RTF) and spreadsheets in Microsoft Excel file format (XLS) — the focus of this article. 

Cord Jastram

Cord Jastram works for Computer Sciences Corporation (CSC) in Germany as a software developer. His main focus lies in software development using Java, ABAP, and C++. He holds a Ph.D. from Hamburg University, where he did research in the field of numerical seismic modeling. Before joining CSC in 2000, Cord worked as a software developer for various companies.

See more by this author


Comments

No comments have been submitted on this article. 


Please log in to post a comment.

To learn more about subscription access to premium content, click here.