You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Nick Burch <ni...@apache.org> on 2021/12/22 18:04:37 UTC
XWPF - worth adding helpers for creating styles?
Hi All
I found myself wanting to create a DOCX file from scratch today, and in
order to have it look nice that meant setting up a bunch of styles. It's a
bit fiddly, and would've been pretty tough if I hadn't already been happy
with reading the XML from word and re-doing that in CT xmlbeans classes.
Based on StackOverflow posts, it's a fairly common thing for our users to
want to do.
I was wondering about adding a couple of friendly helper methods on
XWPFStyles, which would either set you up with some sensible default
styles (inspired by the ones Word pops in a new file), or let you quickly
add a bunch of header or paragraph styles by font size/colour/family.
Anyone have any objections to me doing that? Anyone have strong
preferences for what to call the methods / what to put on XWPFStyles vs
XWPFStyle?
(I wouldn't be doing a full set of XWPFStyle get/set/etc methods, just
enough to help you easily create new ones. The alternative to all this is
to start with a template .docx file, having set the styles up by hand in
Word, but I wanted to avoid that.)
Cheers
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: XWPF - worth adding helpers for creating styles?
Posted by Nick Burch <ni...@apache.org>.
On Wed, 22 Dec 2021, Nick Burch wrote:
> I was wondering about adding a couple of friendly helper methods on
> XWPFStyles, which would either set you up with some sensible default styles
> (inspired by the ones Word pops in a new file), or let you quickly add a
> bunch of header or paragraph styles by font size/colour/family.
>
> Anyone have any objections to me doing that? Anyone have strong preferences
> for what to call the methods / what to put on XWPFStyles vs XWPFStyle?
My current idea, if no objections, would be
* XWPFStyle.createHeaderStyle(String name, int headingLevel,
String fontFamily, String fontColor, int fontSizeHalfPoints)
* XWPFStyle.createParagraphStyle(String name, String fontFamily,
String fontColor, int fontSizeHalfPoints)
* XWPFStyle.createDefaults()
- calls the XWPFStyle.create* methods with sensible defaults
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org