У меня есть эта строка:
Prueba
Lista:
- li1
- li2
- li3
- li4
Tabulado
Tabulado Tabulado Tabulado Tabulado
Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado
Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado
но когда я готовлю свой .docx, строка печатается так:
Prueba Listas: - li1 - li2 - li3 - li4 Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado
Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado Tabulado
Вот где я получаю строку:
String escDesc = report.getDescription();
if (escDesc.contains("\n")){
//escDesc = escDesc.replaceAll("\\n", System.getProperty("line.separator"));
//escDesc = escDesc.replaceAll("\\n", "<w:br/>");
}
escDesc = StringEscapeUtils.escapeXml(escDesc);
valuesAdd.put("DESCRIPCION", escDesc);
И здесь я добавляю все переменные:
private void replacePlaceholders()
throws Exception {
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
VariablePrepare.prepare(wordMLPackage);
documentPart.variableReplace(valuesAdd);
List<SectionWrapper> sectionWrappers = wordMLPackage.getDocumentModel().getSections();
String xml = null;
for (SectionWrapper sw : sectionWrappers) {
HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
if (hfp != null) {
HeaderPart headerPart = hfp.getDefaultHeader();
if (headerPart != null) {
xml = XmlUtils.marshaltoString(headerPart.getJaxbElement());
}
Object obj = null;
try {
obj = XmlUtils.unmarshallFromTemplate(xml, valuesAdd);
} catch (JAXBException e) {
e.printStackTrace();
}
// Inject result into docx
headerPart.setJaxbElement((Hdr) obj);
}
}
}
Я хочу сохранить \n, но я не знаю, что мне делать прямо сейчас. Я надеюсь, что кто-нибудь может дать мне несколько советов.
Это System.out.println(escDesc);
:
А это строка в документе: