apache-poi

how to convert doc,docx files to pdf in java programatically

血红的双手。 提交于 2019-12-22 14:58:09
问题 I am able to generate pdf from docx file using docx4j.But i need to convert doc file to pdf including images and tables. Is there any way to convert doc to docx in java . or (doc to pdf)? 回答1: docx4j contains org.docx4j.convert.in.Doc, which uses POI to read the .doc, but it is a proof of concept, not production ready code. Last I checked, there were limits to POI's HWPF parsing of a binary .doc. Further to mqchen's comment, you can use LibreOffice or OpenOffice to convert doc to docx. But if

PPT to PNG conversion with Apache POI

左心房为你撑大大i 提交于 2019-12-22 12:39:27
问题 By following the example provided at http://poi.apache.org/slideshow/how-to-shapes.html i got the conversion to work. FileInputStream is = new FileInputStream("slideshow.ppt"); SlideShow ppt = new SlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); Slide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++){ BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); graphics.setPaint

Encoding issue with Apache POI

旧城冷巷雨未停 提交于 2019-12-22 12:30:58
问题 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 {

How to set PivotTable Field Number Format Cell with Apache POI

旧街凉风 提交于 2019-12-22 12:29:22
问题 I'd like to set number format cell of pivot table Value field Sum of Balance as # ##0 . Pivot table created with code based on Official POI Sample CreatePivotTable Code below do create and get CTPivotField pivotField . But how to set its number format? pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 2); CTPivotField pivotField = pivotTable .getCTPivotTableDefinition() .getPivotFields() .getPivotFieldArray(2); In MS Excel this is doing by next steps (see screenshot): right click on Sum

Jersey @Produces Apache XSSFWorkbook

人盡茶涼 提交于 2019-12-22 12:14:09
问题 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

Jersey @Produces Apache XSSFWorkbook

a 夏天 提交于 2019-12-22 12:13:49
问题 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

Accessing Field Settings of Pivot Table using Apache POI

南楼画角 提交于 2019-12-22 11:24:44
问题 I am creating a workbook with a sheet populated data from a data source then creating a second sheet with a pivot table view of that data. Everything works fine, but I can't seem to change the default look of the pivot table. I am trying to get the setting ( Row Labels-->Click one from the list-->Field Settings-->Subtotals-->None and Row Labels-->Click one from the list-->Field Settings-->Layout & Print-->'Show item labels in tabular form' ) checked while creating the pivot table but couldn't

Apache POI Libraries error in Android Studio..?

爷,独闯天下 提交于 2019-12-22 10:53:25
问题 I added 5 jar files of Apache POI so that I can save an text as .docx document but I can't run the application first I had 210 error in the grade now i have this error can someone please help me ..!? i followed this example https://www.tutorialspoint.com/apache_poi_word/apache_poi_word_quick_guide.htm apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.0" defaultConfig { applicationId "com.example.mike.textword" minSdkVersion 19 targetSdkVersion 25

NoClassDefFoundError org/apache/poi/ss/usermodel/Workbook

余生颓废 提交于 2019-12-22 10:26:37
问题 I am running a shell script which calls a java class to get some data from database and create an excel report with that data. I get the error Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook when the code hits the below line in my java class: XSSFWorkbook workbook = new XSSFWorkbook (); This is how I have defined the classpath: CLASSPATH=${CLASSPATH}:<path-to-jars>/poi-2.5.1-final-20040804.jar CLASSPATH=${CLASSPATH}:<path-to-jars>/poi-ooxml-3.11

Getting error “Your InputStream was neither an OLE2 stream, nor an OOXML stream” when created file through apache POI

邮差的信 提交于 2019-12-22 10:17:44
问题 I am trying to check if my excel file already exists. If it doesn't exists, I want to create a new one and if it exists I will delete it and create a new one. I wrote following program but I am getting error at line - workbook= WorkbookFactory.create(instream); The error is-> java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:89) at tryIng.main(tryIng.java:84) Here is a