I want to add a cell in xlsx workbooks sheet containing the quote prefix, and i am trying to create that sheet using POI library. How do I add this type of cell
I found a reference to this with CTXf.setQuotePrefix(boolean quotePrefix) on maven central, but dont know how to add this to the XSSFCell
I have tried using below code
XSSFCell cell=row.createCell(cellIndex);
CTXfImpl ctxf= new CTXfImpl(XmlObject.Factory.newInstance().schemaType());
ctxf.setQuotePrefix(true);
cell.getCTCell().set(ctxf);
cell.setCellValue(data);
getting exception
Exception in thread "main" java.lang.NullPointerException
at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTXfImpl.setQuotePrefix(Unknown Source)
Can anyone help me with this
The
CTXf
and also thequotePrefix
property is part of theXSSFCellStyle
and not theXSSFCell
.So we must create a
XSSFCellStyle
, set thequotePrefix
there and then apply thisXSSFCellStyle
to theXSSFCell
.