apache-poi

Replacing a text in Apache POI XWPF

↘锁芯ラ 提交于 2020-01-18 11:35:31
问题 I just found Apache POI library very useful for editing Word files using Java. Specifically, I want to edit a DOCX file using Apache POI's XWPF classes. I found no proper method / documentation following which I could do this. Can somebody please explain in steps, how to replace some text in a DOCX file. ** The text may be in a line / paragraph or in a table row/column Thanks in Advance :) 回答1: The method you need is XWPFRun.setText(String). Simply work your way through the file until you

Read images from Excel sheet row by row

回眸只為那壹抹淺笑 提交于 2020-01-17 13:48:50
问题 I have stuck up in reading images from an Excel sheet. I have one Excel sheet which includes employee information like name, address and photo of an employee. I want to read it using Java and store it into some user management system. Following is my code: int idColumn = ...; POIFSFileSystem poifs = ...; HSSFWorkbook workbook = new HSSFWorkbook(poifs); HSSFSheet sheet = workbook.getSheetAt(0); List<HSSFPictureData> pictures = workbook.getAllPictures(); for (int i = 0; i < pictures.size(); i++

Apache POI Double Values in ComboBox

北战南征 提交于 2020-01-17 07:35:12
问题 I want to have a ComboBox with the following entrys: {"0,5", "1", "1,5", "2", "2,5"} I use DataValidation: DataValidation dataValidation = null; DataValidationConstraint constraint = null; DataValidationHelper validationHelper = null; validationHelper = new XSSFDataValidationHelper(sheet); CellRangeAddressList addressList = new CellRangeAddressList(row, row, col, col); constraint = validationHelper.createExplicitListConstraint(list); dataValidation = validationHelper.createValidation

Copy a XSSF/HSSF-Cells into a new XSSFWorkbook

百般思念 提交于 2020-01-17 05:37:11
问题 My problem I need to exactly copy cells from XSSFWorkbook s and HSSFWorkbook s to a new XSSFWorkbook . So my cells can be of both types: XSSFCell and HSSFCell . By exactly , I mean that I also need to copy the CellStyle including the CellBorder and CellFill properties as well as the DefaultRowHeight and DefaultColumnWidth of the workbook itself. Also the height and width for each row and column should be copied. (Copying CellStyle sometimes results in strange behaviour like I already asked

Same Apache poi (excel) code acting differently depending on system types (32bit, 64bit)

…衆ロ難τιáo~ 提交于 2020-01-17 05:04:33
问题 I have successfully generated an excel file using apache poi 3.10, the program only runs as expected on 32bit systems. BUT when tried to run it on 64bit systems, most of the cells data are left out, they simply don't show up (but the same code will work just fine on 32bit systems). what can I do so that all the generated cell data can show even on 64bit systems? HSSFWorkbook my_xls_workbook = new HSSFWorkbook(input_document); HSSFSheet my_worksheet = my_xls_workbook.getSheetAt(0); Cell cell =

apache poi: images in spreadsheet are associated with workbook and can not be retrieved/linked with individual worksheet ..

回眸只為那壹抹淺笑 提交于 2020-01-16 18:42:09
问题 I am trying to read images from xl_sheet using method wbook.getAllpicture(); but I found that these images are returning as whole I can not keep images separated according workshets. 回答1: In Excel the pictures data are stored on Workbook level. This is what Workbook.getAllPictures actually gets. Each sheet has a Drawing layer which hovers over the sheet. In this Drawing are Shapes which are anchored to the sheet and may also be linked to the pictures data stored on Workbook level. If so, the

POI 3.7 java.lang.IncompatibleClassChangeError when instantiating a Font

假如想象 提交于 2020-01-16 11:38:27
问题 I am getting a java.lang.IncompatibleClassChangeError with the following snippet: Workbook workbook = new HSSFWorkbook(); Font arial = workbook.createFont(); // java.lang.IncompatibleClassChangeError thrown here I am using POI 3.7 with WebSphere 7 Portal Server. The same code (and as far as I can tell, the same jars) worked with Netbeans console application. It also seems that the 3.7 jar is the only one in the classpath. The project also uses JasperReports 4.1.2. Can I provide more

How to add multiple equations inline with text in Apache POI Word?

那年仲夏 提交于 2020-01-16 10:18:51
问题 I am converting text with latex style equation into MS word document using Apache POI. with some help, I was able to implement it successfully but if the line has more than one equation then it produces an incorrect result. following is my code: import java.io.*; import org.apache.poi.xwpf.usermodel.*; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMath; import org.openxmlformats.schemas.officeDocument.x2006

How to add multiple equations inline with text in Apache POI Word?

寵の児 提交于 2020-01-16 10:18:10
问题 I am converting text with latex style equation into MS word document using Apache POI. with some help, I was able to implement it successfully but if the line has more than one equation then it produces an incorrect result. following is my code: import java.io.*; import org.apache.poi.xwpf.usermodel.*; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMath; import org.openxmlformats.schemas.officeDocument.x2006

Exception in org.apache.poi

跟風遠走 提交于 2020-01-16 10:12:06
问题 I was trying to write a program that it can read and write a .xlsx file, the code provided below is designed to be able to write its first excel program. package excel_reader; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; public class ExcelWriter{ public static void main(String[] args)