Is Apache POI supports replacing merge fields in docx? - apache-poi

To replace ms word merge-fields with values with apache-poi both in paragraphs and tables with multiple columns.
As docx4j provides the function to replace merge-fields, is there any equivalent function by apache poi. Since I am using some custom tags in Docx file, reading the file in docx4j is ignoring custom tags(xml format "w:xyz").
Input Template
Name «name»
Table : (Need to add n- number of records to the template)
ID Name
«id» «name»
Output expected :
Name: Stack
ID Name
1 Java
2 Apache

It doesn't.
However there is an apache library for it, called Freemarker. It is a template engine and fully supports what are you looking for.

Related

I want to add new column that contains html files in solr indexer using nutch 1.17 version

I want to add new column that contains htmls files(raw html files).May I know what configurations changes are required.I read segment reader that contains content folder but output is text file i want to index the htmls files in a column.May I know how could I achieve.
You may have to face special character issues in raw HTML when indexing in Solr. Anyhow, first you should1 customize index-basic plugin in Nutch. Its class name is BasicIndexingFilter.java. Update this class with followings:
String htmlcontent = parse.getData();
doc.add("htmlContent", StringUtil.cleanField(htmlcontent));
After this, you also have to add a field with Solr Schem "htmlContent". Hopefully it will solve your issue.
There may be others options also for this task.
I found another option as commented that works best. Use nutch CLI
bin/nutch index crawldb-path -dir segments-directory -addBinarycontent -base64

Docx4j, there is no prefix registered for Bibliography

I'm trying to add bibliography & citation to docx file using Docx4j. However the XML generated by library has automatically created namespace:
<ns30:Source>
MS Word unfortunetely doesnt show such kind of source as a source. After some trials & erros I discovered that enough is to change the namespace:
<b:Source>
Probably the problem is that in Docx4J this namespace is not defined in NamespacePrefixMappings class.
How Can I add or define my own namespace prefix mappings? Or can I somehow force Docx4j for using particular prefix for part? Anything where the result will be XML with namespace "b" will be good advice for me. I would like to avoid downloading Docx4j source, modyfing source and having customized version of library.
http://www.docx4java.org/docx4j/docx4j-3.3.0-SNAPSHOT-20151020.jar contains https://github.com/plutext/docx4j/commit/089bce035e847dc473b95080a7106f35470fa48e which adds the mapping to NamespacePrefixMappings

Extract Excel data to transform to a simple XML

I am working on creating orders/receipts for a certain client that provides the data using Excel. However, it is not a common Excel table format but an actual form to be printed. I am having issues with the data mapper since it cannot be parsed correctly.
Is there a way to get the data so I can transform it to a simple XML?
I'm thinking if I can just get the data by declaring which column/row.
I can suggest you to use a custom transformer using Apache POI from XLS to a simple java POJO, then you can get your XML using the object-to-xml-transformer.
apache POI: https://poi.apache.org/spreadsheet/quick-guide.html#Iterator
object-to-xml-transformer:
https://docs.mulesoft.com/mule-user-guide/v/3.6/xmlobject-transformers

Load Tree based xls using a Java API

How to read a tree based xls using a Java API like Apache POI, etc. I want to read a xls which is in a tree based format i.e the data is grouped.

How to send data into an OpenOffice word template from NodeJS

How can I get data passed from NodeJS into placeholders of a OpenOffice template file? Is there any npm packages available to parse an ODT template file so that I can print data into it?
I have a 13 page word file (a template for printing reports) and I want to populate it with certain details from the DB into the different pages of this file. I like to pass the data in JSON format.
What I know is how to write into a plain text/excel file from node, but I want to write into the placeholders of a word template without loosing other parts of the template. I did the same with VBScript (with microsoft word template) in the past. Now want to achieve the same using nodejs. Please share with me your ideas..thanks

Resources