apache-poi

Apache POI XSSFPivotTable setDefaultSubtotal

痴心易碎 提交于 2019-12-18 07:09:12
问题 I am having an issue with the setDefaultSubtotal method for axisRow pivotFields. When I set the value to false for a RowLabel field Excel doesn't like it. Manually setting things up how I want them in Excel and then saving produces dramatically different XML, too different for me to contemplate fixing behind the scenes. I can't (so far) manipulate the XML to get the POI spreadsheet to open cleanly in Excel. The actual code is a little long and unwieldy to post, but here is a runnable piece

How to display the Excel Cell content along with its styling in XHTML page?

不问归期 提交于 2019-12-18 07:07:50
问题 I am developing a Java Web Application using JSF, Primefaces and XHTML . In which, I am trying to read the Cell content from Excel using POI . In cell, it contains some styling like (bold, color, line-through, underline and etc) along with the value. So now, I need to show the value as well all the styles of the cell in XHTML page. Kindly help me to solve this. 回答1: The style is either applied to the whole cell or to parts of the cell content in rich text string content. If applied to the

XSSFWorkbook when written creates a corrupted .xlsx document in Spring Boot application using JDBC

穿精又带淫゛_ 提交于 2019-12-18 07:07:41
问题 For a project I need to create an .xlsm excel document automatically filling out a template file. Problem is, that the output is corrupted and cannot be read by Excel 365 nor by Apache POI. I have distilled it down to the following minimal example, that can run in a main method. To be completely safe it is using the .xlsx format. public static void main(String[] args) { XSSFWorkbook document = new XSSFWorkbook(); XSSFSheet spreadsheet = document.createSheet("Test"); spreadsheet.createRow(0)

Write 16 bits character to .xlsx file using Apache POI in Java

被刻印的时光 ゝ 提交于 2019-12-18 06:57:45
问题 I have a problem in Apache POI. The problem is, I try to put a 16 bits character value (such as CJK Unified Ideographs Extension B) to .xlsx file. However, the cell value become a question mark(like ????) in generated .xlsx file. Anyone know how to handle the 16 bits character value in Apache POI with .xlsx format??? My POI version is 3.14 Code sample as below: XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet("Test"); XSSFRow row1 = sheet.createRow(0);

Reading time values from spreadsheet using poi api

℡╲_俬逩灬. 提交于 2019-12-18 05:53:56
问题 I am trying to read a date column and a time column from a spreadsheet. I am able to retireve the date column from the sheet, but not the time column. For example, my sheet will have rows of the form: date time 11/2/2012 12:15:01 I have the following code to get the date column: while(cellIterator.hasNext()) { HSSFCell cell = (HSSFCell)cellIterator.next(); switch(cell.getCellType()){ case HSSFCell.CELL_TYPE_NUMERIC: HSSFCellStyle style = cell.getCellStyle(); if (HSSFDateUtil

Find merged cell in Excel, split the cells and write those in new spreadsheet?

瘦欲@ 提交于 2019-12-18 05:49:12
问题 I have been given a Assignment that I need to Split the data of a Spreadsheet and Write it into the new Spreadsheet. The Conditions are, Given Spreadsheet may have multiple numbers of Merged Cells and I need to find those Merged cells and write those Data in a New SpreadSheet. ie, the data or cells between one merged cell till to another Merged cell must be written in another Spreadsheet. My Code of Effort is given below, import java.io.BufferedInputStream; import java.io.BufferedOutputStream

Apache-POI: Unable to write to an existing workbook

我是研究僧i 提交于 2019-12-18 05:46:16
问题 I'm working on a project which needs to read an Excel Workbook, calls the necessary Web Services, and then takes the response from the webservices and enters that information in to the same Excel Workbook that was read. Here is the error I'm seeing when trying to write to the Excel Workbook: Exception in thread "main" org.apache.poi.POIXMLException: java.io.IOException: Can't obtain the input stream from /docProps/app.xml at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:141)

POI DataFormatter returns 2 digits year instead of 4 digits year for date cells

风格不统一 提交于 2019-12-18 05:26:10
问题 Excel cell has date format m/d/yyyy and show date with 4 digits year. However POI returns date in another format m/d/yy . The cell style returns the same format with 2 digits year cell.getCellStyle().getDataFormatString() . Is it possible to get the same format as I see in Excel with POI? 回答1: In Excel Cell Style issue I have shown that if a date in Excel which is formatted using the default date format ( Short Date ) only has the format id 0xE (14) stored in the file and there is not a

Exception using POI

吃可爱长大的小学妹 提交于 2019-12-18 05:22:34
问题 I'm using poi 3.7 , upload the file is .xlsx The console show: org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13] at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:186) at poi.POITest.ReadAndPrintExcelFile(POITest.java:15) at poi.POITest.main(POITest.java:59) Caused by: org.apache.poi.openxml4j.exceptions

NoClassDefFoundError: Failed resolution of :Ljavax/XML/stream/XMLEventFactory with Apache POI on Android

假如想象 提交于 2019-12-18 05:02:58
问题 I have been trying to write excel sheets to external storage using apache poi library on android but every time I run the app I am getting the error Failed resolution of :Ljavax/XML/stream/XMLEventFactory I have read the official documentation for poi and searched Google but in vain. Also I use jdk1.8 but still the error occurs. 回答1: Currently Apache POI will not work on Android out of the box due to various problems that you will encounter when using the libraries from Apache POI directly.