Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ How to use Java to read OpenOffice document     - Oracle metadata Reconstruction experiments (Database)

- Valgrind * not * leak check tool (Linux)

- MySQL migration tool used in the production environment (Database)

- Comparison of sorting algorithms (Programming)

- CentOS7 virtual machine creation failed Solution (Linux)

- Java, boolean operators & =, | = ^ = use (Programming)

- To restore the last time applications running when Ubuntu user log in again (Linux)

- Using Java arrays implement sequential stack (Programming)

- Gentoo: existing preserved libs problem solving (Linux)

- Hadoop scheduling availability of workflow platform - Oozie (Server)

- Linux system started to learn: Teaches you install Ubuntu 15.04 on VirtualBox (Linux)

- Ubuntu UFW firewall settings Introduction (Linux)

- Installation salt-minion on RHEL5 (Linux)

- Spring AOP custom annotation way to achieve log management (Programming)

- Spark build standalone version cluster (Server)

- Linux file permissions bit forced bits and adventure Comments (Linux)

- Help you make Git Bisect (Linux)

- Linux uses the SMTP proxy to send mail (Linux)

- Android Scroller call mechanism and the relationship of computeScroll (Programming)

- Use the command line MySQL database backup and recovery (Database)

 
         
  How to use Java to read OpenOffice document
     
  Add Date : 2018-11-21      
         
         
         
  Due to the need of the project, we need to read the document in OpenOffice Java programs, and data processing. This article describes how to use the ODF Toolkit to read the contents of the OpenOffice SpreadSheet.

1. OpenOffice Spreedsheet document

The above documents are also included in the source code for this article.

OpenOffice document is actually stored in XML format that contains the document content and format control.

If you are using Unzip unzip tool, you will find that after decompression, a OpenOffice document actually contains the following elements
2. Download ODF4j

Odf4j is used to read OpenOffice documents (ODF) pure Java toolkit. At present, although not yet officially released, but already it has a deal with the basic functions of OpenOffice document.

Use Odf4j, Java programmers can easily create, modify OpenOffice documents.

3. Use ODF4j read OpenOffice document

Use ODF4j read OpenOffice document consists of two levels: Package Layer and Document Layer.

Package Layer

In the Package Layer, OpenOffice documents in a variety of resources as a named resource to deal with. Usually at this level for operating binary files, such as pictures.

Document Layer

In the Document Layer, is on the main content of the document operation. At this level, the content of the document is to be operated as a hierarchy, because the content of the document is saved in an XML file mode, it can be very easy to DOM approach to the operation. The following example will read a Document Layer OpenOffice Spreadsheet document.

4. Read the document OpenOffice Spreadsheet

import org.openoffice.odf.OdfPackage;

import org.openoffice.odf.OpenDocumentFactory;

import org.openoffice.odf.spreadsheet.SpreadsheetDocument;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

......

OdfPackage odfPackage;

odfPackage = (SpreadsheetDocument) OpenDocumentFactory.load (path);

Document doc = odfPackage.getDocument (OdfPackage.STREAMNAME_CONTENT);

Element root = doc.getDocumentElement ();

......

Source code

After obtaining root Element, we can read the image reading xml files as OpenOffice document content.
5. The result of the program

Download the article source into the root directory NetBean Project, and then run: ant run. Operating results
References: Element

1. ODF4j: http://wiki.services.openoffice.org/wiki/Odf4j

2. Source code for this article.
     
         
         
         
  More:      
 
- Oracle table space is too large processing time (Database)
- Ubuntu15 core CLR (Server)
- Linux character device - a simple character device model (Linux)
- Analyzing Linux server architecture is 32-bit / 64-bit (Server)
- Use MD5 transform algorithm to prevent exhaustive decipher passwords (Linux)
- Java memory analysis tool uses detailed MAT (Programming)
- How to monitor Nginx (Database)
- How to Install Xombrero 1.6.4 (minimalist Web browser) on Ubuntu and Archlinux (Linux)
- PostgreSQL transaction model introduction (Database)
- MyCAT log analysis (Database)
- Five strokes to find out the IP address you want to know (Linux)
- These days have been tossing in the Linux under the ASP.NET 5, on the next in the other operating systems in the ASP.NET 5 or. NET applications, in order to complete the MS VM (CoreCLR) run is not far Reach, the effect of the application.

Cur
(Server)
- Apache Kafka: the next generation of distributed messaging system (Server)
- How MAT Android application memory leak analysis (Programming)
- Ubuntu study notes and related problem solving (Linux)
- Use GNU / Linux broadcasting of television programs (Linux)
- Xshell configure SSH free password (Server)
- CoreOS Linux introduces Kubernetes kubelet (Server)
- Lsblk command lists using Linux block device information (Linux)
- Oracle Sql Loader tool has shown signs (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.