create text box in document .docx using apache poi

后端 未结 2 1436
予麋鹿
予麋鹿 2021-01-26 09:49

I want create a text box in a document .docx but I didn´t find a method that help me do it and any example. Someone know how can i do it?

2条回答
  •  日久生厌
    2021-01-26 10:46

    For HWPF (i.e. the old binary doc format) there is a very rudimentary interface via HWPFDocument.getMainTextBoxRange(). I believe it is only suitable for reading, though.

    For XWPF (the newer docx format that you asked for) it appears that Text Boxes are always embedded in a Drawing (using DrawingML; please correct me if I am wrong). At least this is how I interpret clauses 17.3.1.40, 20.4.2.37 and 20.4.2.38 of ECMA-376, Part 1. Thus, your method of choice should be XSSFDrawing.createTextbox(). However, I haven't yet come across an easy to use link between this drawing class (which stems from POI's Excel component) and XWPF.

提交回复
热议问题