Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Manage Tables in Edited HTML Using GroupDocs Editor for Java

This repository shows how to edit a Word table programmatically with GroupDocs.Editor for Java: change cell text and table borders, then save back to DOCX.

How it works

GroupDocs does not give you raw DOCX XML. It converts the document to HTML + CSS so you can edit it like a web page:

flowchart LR
    A[input.docx] --> B["Editor.edit()"]
    B --> C[EditableDocument]
    C --> D["getBodyContent()"]
    C --> E["getCssContent()"]
    C --> F["style.css, fonts, …"]
    D --> G["Edit cell text"]
    E --> H["Edit table borders"]
    F --> I["Save resources folder"]
    G --> J["fromMarkupAndResourceFolder()"]
    H --> I
    I --> J
    J --> K["editor.save()"]
    K --> L[output.docx]
Loading

Important: table text is in the body HTML; table borders are usually in style.css. If you only edit the body and call fromMarkup(body) without the CSS folder, borders will be wrong or missing.

What the sample changes

Part API Change
Cell status text getBodyContent() ReviewSupported
Section title getBodyContent() “before HTML edit” → “after HTML table edit”
Table borders getCssContent() stronger border on table.table001 and cells

See ManageTablesInHtmlExample.java — the run() method is written as Steps 1–8 with comments.

Prerequisites

  • Java 8 or higher
  • Maven 3.x
  • Input file: resources/input/input.docx (create with python scripts/create_input_docx.py if needed)

License

Free temporary license or purchase. Optional file: groupdocs.editor.lic in the project root.

Setup & Run

mvn compile exec:java

Output: resources/output/output.docx

FAQ

Q: Why not use getEmbeddedHtml()?
A: That returns one big HTML string with all resources embedded. Splitting body and CSS is closer to how WYSIWYG editors work and is easier to understand.

Q: Can I edit merged cells?
A: Yes — merged cells use rowspan / colspan in the body HTML from getBodyContent().

Q: Will replace() work on any document?
A: The sample uses fixed strings from our demo input.docx. For real documents, inspect body/CSS once (print to console) and adjust the strings you replace.

Documentation

GroupDocs Editor for Java

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages