apache-poi

Encoding issue with Apache POI

≯℡__Kan透↙ 提交于 2019-12-06 05:09:20
I'm creating MS Excel file using Apache POI and everything works fine while I'm using it at localhost. But when I deploy project on Google App Engine and then try to open created file in MS Excel I can notice that all my special characters changed into question marks "?". Does anyone of you could tell me why it works on localhost but fail to show special character after deploying. public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { OutputStream out = null; try { String dataa = req.getParameter("dataa"); String json = URLDecoder

Apache POI 3.17 in OSGi

旧城冷巷雨未停 提交于 2019-12-06 05:07:50
问题 Preamble: I've seen this question, but it's obviously about an older version of POI, and Apache went contra to every Java standard since then. Problem: My goal is to get POI to work with OSGi. As of now I'm pretty sure that's not possible, but maybe one of you guys has a good idea. What I tried so far: 1) Bundling the JARs The easiest would be to add bundle information directly to the POI jars (the other answer has details on how to do that). This cannot work, because the JARs export the same

Convert byteArray to XSSFWorkbook using Apache POI

三世轮回 提交于 2019-12-06 04:54:34
I am using Apache POI and I am trying to send a xlsx file as HTTP request and get it back as response. I am using jayway restassured for making HTTP requests. Here is the part of the code where I send the request File file = new File("path"); String response = given().multipart(file).when().post("URL").getBody().asString(); byte[] bytes = response.getBytes("ISO-8859-1"); InputStream stream = new ByteArrayOutputStream(bytes); try { XSSFWorkbook workbook = new XSSFWorkbook(stream); } catch(Exception e){ e.printStackTrace(); } Here is the code where the response is generated for the request

Jersey @Produces Apache XSSFWorkbook

守給你的承諾、 提交于 2019-12-06 04:18:47
I am trying to produce a XSSFWorkbook using Jersey. I have tried the following headers and nothing seems to work: @Produces("application/xml") @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Produces("application/vnd.openxml" All return the following error: Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.apache.poi.xssf.usermodel.XSSFWorkbook, and Java type class org.apache.poi.xssf.usermodel.XSSFWorkbook, and MIME media type application/xml was not found ... 37 more Essentially I have a function which creates the

How can one programmatically read the graph values from a Powerpoint presentation using Apache's POI?

被刻印的时光 ゝ 提交于 2019-12-06 03:46:53
I have a Powerpoint presentation with an graph which I want to access using Java and Apache's POI . When I edit the graph data using Powerpoint an Excel window opens with the values, I want to access these values from my Java application. How does one access the values of the graph programmatically? In the first part we need to navigate to an XSLFChart object: final String filename = "resources/fptbenchmark/Powerpoint Import.pptx"; final XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(filename)); final XSLFSlide slide = ppt.getSlides()[5]; The slide contains different parts (

Java Web Start causing slow execution

≡放荡痞女 提交于 2019-12-06 03:37:16
I have an application that I'm deploying with Java Web Start. When I was doing unit testing, I noticed a slight problem: whenever my application is run with Java Web Start, a particular operation takes a long time to execute. When run locally, however, it is quite fast. The particular operation I'm talking about is reading in a large (5k row) Excel file to parse it. This is the line of code: Workbook wb = WorkbookFactory.create(new FileInputStream(new File(inputFile.getText()))); To figure out the problem, I added a way to record the time: long time1 = System.currentTimeMillis(); Workbook wb =

Is there any Java library which supports both Microsoft office and Open Office?

拟墨画扇 提交于 2019-12-06 03:13:33
As Apache POI supports Microsoft office and JExcelApi supports Open Office, is there any Java library which supports both Microsoft office and Open Office? Note: In the pom.xml file we are using either POI and JExcel utilities in order to fetch/read data from the Excel sheet in Microsoft office and Open Office respectively. So my question: Is there any library which supports both? Aspose covers all of Microsofts formats, but it is not free and not open source. Regarding open source Java API, you can find a review on each available java library here, http://www.esupu.com/open-source-office

Number and cell Formatting in apache poi

空扰寡人 提交于 2019-12-06 02:39:58
问题 I am creating excel sheet using apache poi. I have numbers like - 337499.939437217, which I want to show as it is in excel without rounding off. Also the cell format should be number (for some columns) and currency (for some columns). Please suggest which BuiltinFormats should I use to achieve this. Many thanks for the help. 回答1: At first you need to know how to use DataFormats. Then you need to know the guidelines for customizing a number format. For your number -337499.939437217 which will

Reading .xlsx file using apache poi gives org.apache.poi.POIXMLException on linux machine

我是研究僧i 提交于 2019-12-06 02:08:26
I have an application which reads an .xlsx file and displays the content to the user. The application works fine on a windows environment. I deployed the .war file of this web app on tomcat6 on a ubuntu server. I also copied the .xlsx files on the server. The path of the files in the code is correct. But the line FileInputStream file = new FileInputStream(new File(FileName)); XSSFWorkbook workbook = new XSSFWorkbook(file); gives an error java.lang.reflect.InvocationTargetException org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException org.apache.poi.xssf.usermodel

how create a Word document from a template or existing document with Java?

不羁的心 提交于 2019-12-06 02:00:04
I have a document template where some fields are static and others are dynamic. I need to replace some data (name, last name, salary) and generate the new file. What library do you recommend to do this? Is POI appropriate? I am working with Spring, Java EE6 and Oracle. max You can give Apache POI a try but the HWPF and XWPF part of POI which are required to manipulate word files are really complicated to use - you need to have at least a good understanding how a word file is structured! Solution using iText and PDF I did something similar with PDF (this might be an option for you) 1) You can