Bug 65797 - XWPF Helpers for creating Styles in a new file
Summary: XWPF Helpers for creating Styles in a new file
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 5.3.x-dev
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-10 21:28 UTC by Nick Burch
Modified: 2022-01-10 23:00 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Burch 2022-01-10 21:28:39 UTC
As mentioned on dev@, when creating a DOCX file from scratch, no default styles are setup. That means that your initial document can set paragraphs to eg Heading1, but it won't look any different in Word. Previous advice for this kind of case was to start from a Template document, but can be a bit of a pain.

It is possible to setup some default styles in a new document, but you have to mess around with the CT* xmlbeans classes, and normally unzip a new Word-generated file to ensure you got everything you needed. Possible, but not very user friendly!

We should therefore have a friendly helper on XWPFStyle to create a new Heading or Paragraph style (by font size/colour/family), and something on XWPFStyles to generate a sensible set of defaults.
Comment 1 Nick Burch 2022-01-10 23:00:39 UTC
Proposed methods are https://gist.github.com/Gagravarr/e7cfb245f53de334f02032fa790d7504 - feedback welcome :)

Need to write some unit tests before it can be committed though!