Java POI the supplied data appears to be in the Office 2007+ XML

According to the Apache POI Quick Guide, the POIFSFileSystem (or similarly, NPOIFSFileSystem) is only used with .xls (Excel versions through 2003) documents. The equivalent for .xlsx documents (Excel 2007+) is OPCPackage. OPCPackage pkg = OPCPackage.open(new File(“file.xlsx”)); You can create an XSSFWorkbook from the OPCPackage: XSSFWorkbook wb = new XSSFWorkbook(pkg); Or you can just create it … Read more

Apache POI Line Chart colors

It works for me. Groovy, PieChart, random colors. def ctChart = chart.getCTChart() def ctPieChart = ctChart.getPlotArea().addNewPieChart() def ctPieSer = ctPieChart.addNewSer() byte[] b = new byte[3]; (0 .. rows).each { random.nextBytes(b) def x = ctPieSer.addNewDPt() x.addNewIdx().setVal(it) x.addNewBubble3D().setVal(false) x.addNewSpPr().addNewSolidFill().addNewSrgbClr().setVal(b) }

How can I change charts generated by apache poi to not use smoothed lines and show empty cells as gaps?

Thanks to Etienne for the code to set blanks as gaps. I got help from a POI developer and here is the solution that solves both issues mentioned in the original question. XSSFChart chart = (XSSFChart)drawing.createChart(anchor); // this will set blank values as gaps in the chart so you // can accurately plot data series … Read more

POI 4 XPages – document generation works only once

Oliver, add the client-side JS call XSP.allowSubmit() to your button in order to allow new submits after pressing the button: <xp:button id=”button5″ styleClass=”btn btn-sm printbutton” style=”display:none”> <i class=”fa fa-print”></i> &#160; <xp:text> <xp:this.value><![CDATA[#{javascript:”Nach MS Word exportieren”}]]></xp:this.value> </xp:text> <xp:eventHandler event=”onclick” submit=”true” refreshMode=”complete”> <xp:this.action> <xp:actionGroup> <xp_1:generateDocument documentId=”wordprint” loaded=”true”> </xp_1:generateDocument> </xp:actionGroup> </xp:this.action> <xp:this.script><![CDATA[XSP.allowSubmit()]]></xp:this.script> </xp:eventHandler> </xp:button>

Embed files into XSSF sheets in Excel, using Apache POI

I’ve applied a patch via #60586, so embedding is now much easier. The following snipplet is taken from the corresponding JUnit test. Workbook wb1 = new XSSFWorkbook(); Sheet sh = wb1.createSheet(); int picIdx = wb1.addPicture(getSamplePng(), Workbook.PICTURE_TYPE_PNG); byte samplePPTX[] = getSamplePPT(true); int oleIdx = wb1.addOlePackage(samplePPTX, “dummy.pptx”, “dummy.pptx”, “dummy.pptx”); Drawing<?> pat = sh.createDrawingPatriarch(); ClientAnchor anchor = pat.createAnchor(0, … Read more

Convert Word to HTML with Apache POI

This code is now working for me! HWPFDocumentCore wordDocument = WordToHtmlUtils.loadDoc(new FileInputStream(“D:\\temp\\seo\\1.doc”)); WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter( DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument()); wordToHtmlConverter.processDocument(wordDocument); Document htmlDocument = wordToHtmlConverter.getDocument(); ByteArrayOutputStream out = new ByteArrayOutputStream(); DOMSource domSource = new DOMSource(htmlDocument); StreamResult streamResult = new StreamResult(out); TransformerFactory tf = TransformerFactory.newInstance(); Transformer serializer = tf.newTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, “UTF-8”); serializer.setOutputProperty(OutputKeys.INDENT, “yes”); serializer.setOutputProperty(OutputKeys.METHOD, “html”); serializer.transform(domSource, streamResult); … Read more

Apache POI evaluate formula

To promote a comment to an answer… You firstly need to ensure you’re using the same version of POI for the main jar, and the OOXML part. Your maven snippet was showing 3.7 for one, and 3.8 beta 1 for the other. You need to make sure they’re both the same. (You might even want … Read more