ODFDOM for Java: Simplifies program control of documents and their data, part 3rd

Source: Internet
Author: User
Tags root directory

Use ODFDOM to create text, spreadsheets, and presentation graphics documents

First, let's briefly describe the ODF document structure. The ODF document is saved in a ZIP-compressed package that contains Content.xml, Style.xml, and several other documents.

Content.xml is used to save document content, Style.xml to save document style information. The Content.xml file also contains some style information that can be used to automatically create default values, such as fonts and colors.

In general, the operation of an ODF document is divided into four steps:

Load an existing ODF document or create an ODF document.

Inserts content into the ODF document.

Sets the style for different parts of the information.

Save the document.

ODFDOM now provides APIs that allow you to easily complete these four-step operations.

Create a text file

In this section, we will demonstrate a simple use case: Reading an XML file and outputting it to the ODF document.

As a text file, the content.xml level is as follows (see Listing 1):

The first element is <office:body>, which is a child element of the document's root directory.

The next level is the <office:text> element, which represents all the document elements to be saved in the output document.

The <office:automatic-styles> before <office:body> is another child element of the document root that holds various style information for the element.

Listing 1. Content.xml-level structure of text files

<office:document- content>
  <office:automatic-style/>
    <office:body>
     <office:text/>
    </office:body>
</ office:document-content>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.