apache-poi

How do I edit the presProps.xml file with ApachePoi

我的梦境 提交于 2019-12-24 10:35:43
问题 I need to have a powerpoint loop until the user hits the escape key. Through saving and unzipping the file after checking the "Loop continuously until 'ESC'" option in the powerpoint's Slideshow Setup options I have a diff of the file that changes(ppt/presProps.xml) Not fixed: <p:presentationPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006

Updating Pivot Datasource using Apache POI

淺唱寂寞╮ 提交于 2019-12-24 10:13:09
问题 I am working on a task in which there is an excel template which have a pivot table and an excel sheet as a datasource for that pivot table. I am updating the datasource sheet using Apache POI library in Java. If there are 1 or 2 records in the Datasource sheet, the pivot table is fine. But if there is more than 5 or 6, then it overflows from Pivot table. Attached is the screen shot for the issue I am facing. What can possibly the issue? And how can I get away with this? Thanks! 来源: https:/

How to remove charts from Excel using apache POI?

[亡魂溺海] 提交于 2019-12-24 09:54:43
问题 I will need to remove all the charts using Apache POI. I tried using the following code :- public XSSFSheet removeCharts(XSSFSheet sheet) { XSSFDrawing drawing = sheet.getDrawingPatriarch(); List<XSSFChart> charts = drawing.getCharts(); charts.stream().forEach(v -> { v.getCTChartSpace().setNil(); }); return sheet; } But on saving and then opening the sheet it says corrupted XML. 回答1: Please try the below code : sheet.getDrawingPatriarch().getCTDrawing().setNil(); 来源: https://stackoverflow.com

Apache POI: content in excel file gets corrupted

时光毁灭记忆、已成空白 提交于 2019-12-24 09:36:36
问题 I am writing a method which writes to an Excel file. Before calling I create a Workbook and a Sheet. The code executes without any errors, but when opening the created Excel file I get the message: We found a problem with some content in... My method looks like this: public void writeToCell(int rowNumber, int cellNumber, Double content) { Row row = sheet.createRow(rowNumber); Cell cell = row.createCell(cellNumber); cell.setCellValue(content); try (FileOutputStream outputStream = new

Generate different header for each Section in Apache POIFS

℡╲_俬逩灬. 提交于 2019-12-24 08:58:07
问题 I am trying to concatenate difference document (Docx) with Apache POIFS, but can't success defining the appropriate header on each section. My first page is displayed with its own header, then I have only one header for all other pages. And just can't succeed in finding how to have different headers for each Section. Please, if someone knows how to do this... Here is my code, which simply concat all my additional headers to the original one (at the end, I have only one header, with all values

Excel 2007(.xlsx) Reading code using POI 3.5 in java?

核能气质少年 提交于 2019-12-24 08:39:24
问题 I have downloaded latest POI version 3.5 . I want to read the Excel file (.xlsx format) using the POI. If anybody has any Example source code or any URL or any other code snippet which can read the Excel file (.xlsx format) using the latest version of POI,which would be appreciated. Thanks, Mishal Shah 回答1: Here is the XLSX to CSV Converter example for POI, and you can dig into svn for more examples here 回答2: Below is the code snipet which can help you for reading excel 2007 format file...

Extracting data in spreadsheet columns in Apache POI API

本小妞迷上赌 提交于 2019-12-24 08:39:24
问题 Just want to make sure one thing. Does the Apache POI API have any built-in collection/object, like row and cell, for a column in a spreadsheet? Or do I have to build one myself and add all the cells in the column there to do the sorting etc? Is there any other better way to do it? 回答1: The excel format is row based not column based - the file is written with each cell in a row in order, followed by a few bits of row info, then the cells of the next row in order etc. So, if you want to do

Apache Poi set data field style for pivot table

会有一股神秘感。 提交于 2019-12-24 08:23:16
问题 I need to set the style for 2 sheets in 1 workbook, but I have a total of 6 sheets. I can set the style for all with wb.createDataFormat().putFormat((short) 0, "_($* #,##0.00_);_($*(#,##0.00);_($* \"-\"??_);_(@_)"); ,but this is not what I want, since its applying the style to a sheet which doesn't represent data about money. Does anyone has an idea on how to set the style only for specific sheets? PS: the style should apply to pivot tables 回答1: So i actually found a solution on setting the

Does setDataFormatForType() work at all for Dates in XLConnect?

孤街醉人 提交于 2019-12-24 07:01:18
问题 I recently tried all sorts of formatting arguments on the function setDataFormatForType(wb, type=XLC$DATA_TYPE.DATETIME, format="d/m/yy") for example format="d/m/yy" as shown above, besides numerous others. This then is followed up by setStyleAction(wb, XLC$"STYLE_ACTION.DATA_FORMAT_ONLY") and then I write a worksheet and save the workook. No form of format tweaking seems to work. As soon as I mess with any format in the setDataFormatForType command the result is that the numeric time value