apache-poi

Choosing an excel java api [closed]

人走茶凉 提交于 2019-12-18 04:24:23
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . All I need to do is open an MS excel sheet - not sure which kind yet (2003, 2007, etc.) - and parse the information in each row into

Word document creation API in Java

混江龙づ霸主 提交于 2019-12-18 02:50:37
问题 I would like to create a word document using a template, replace some variables (fields) and save it as a new word document. I was thinking using Apache POI, http://poi.apache.org/ is it the best for this purpose? can you share your impression from it? 回答1: I've worked with POI before and it's certainly able to generate Word documents. But the devil is in the details. Word has thousands of features: You can put numbered lists starting at #13 with negative indents into two joined cells of a

Apache POI Word tutorial.

匆匆过客 提交于 2019-12-18 02:48:24
问题 Does someone know good tutorials about working with MS Word using Apache POI library? I want to understand how I can create word documents .doc (or may be I need to create template .dot ) to create variables like ${customer.name} inside docs(templates), and then replace it via Range.replaceText("${customer.name}","Microsoft CO"); Or maybe ${customer.name} is not a variable and is only plain text (which is named like variable name for more clarity)? Also I didn't find tutorials about working

How do I change the Text Color and the Fillcolor

China☆狼群 提交于 2019-12-18 02:48:12
问题 How do I change the header font color to white and the fill green? These are the classes that I am using: import static org.apache.poi.ss.usermodel.CellStyle.* import static org.apache.poi.ss.usermodel.IndexedColors.* import org.apache.poi.hssf.usermodel.* import org.apache.poi.hssf.usermodel.HSSFWorkbook import org.apache.poi.ss.usermodel.Cell import org.apache.poi.ss.usermodel.CellStyle import org.apache.poi.ss.usermodel.Row import org.apache.poi.ss.usermodel.Sheet import org.apache.poi.ss

get number of columns of a particular row in given excel using Java

两盒软妹~` 提交于 2019-12-17 22:26:49
问题 I want the number of columns of a particular row in excel. How is that possible? I used POI API but I could get only columns count to 7 . try { fileInputStream = new FileInputStream(file); workbook = new HSSFWorkbook(fileInputStream); Sheet sheet = workbook.getSheet("0"); int numberOfCells = 0; Iterator rowIterator = sheet.rowIterator(); /** * Escape the header row * */ if (rowIterator.hasNext()) { Row headerRow = (Row) rowIterator.next(); //get the number of cells in the header row

Get excel sheet names for large excel files using Apache POI

丶灬走出姿态 提交于 2019-12-17 21:32:25
问题 I have the following code that I use to get the sheet names of an excel file(.xlsx) XSSFWorkbook workBookXlsx = new XSSFWorkbook(new FileInputStream(pathToFile)); ArrayList<String> sheetNames = new ArrayList<>(); int numberOfSheets = workBookXlsx.getNumberOfSheets(); for (int i = 0; i < numberOfSheets; i++) { sheetNames.add(workBookXlsx.getSheetAt(i).getSheetName()); } workBookXlsx = null; The issue I have with the above code is that it takes a lot of memory(~700MB) & a long time(5-6s) to

Read Excel Numeric cell values as they are in Java

谁都会走 提交于 2019-12-17 21:07:28
问题 When I am reading excel numeric cell values, i am getting the output with decimals. eg: 79 is reading as 79.0, 0.00 reading as 0.0. The code for my application I have written is: int type = cell.getCellType(); if (type == HSSFCell.CELL_TYPE_NUMERIC) System.out.println(cell.getNumericCellValue()); 回答1: This question comes up a lot on Stack Overflow, so you'd be well advised to look through many of the similar ones to see there answers! Excel stores almost all numbers in the file format as

Read drop down list content from Excel using apache poi

こ雲淡風輕ζ 提交于 2019-12-17 19:42:31
问题 I need to create a drop down list (Data Validation) on a particular cell in an Excel sheet and read them back. With the help of tutorials provided by Apache POI , I am able to create a Drop-down list in an Excel sheet, but I also need to read the drop-down list content when reading that again, so that I can render a similar drop-down list on a UI. Any suggestions? 回答1: I can't seem to find any mechanism in HSSF to retrieve the DataValidation s from the HSSFSheet . So if you have a .xls file,

Write number in excel cells using Apache POI

可紊 提交于 2019-12-17 19:27:12
问题 How can I write my full value in cell with help of poi ? i.e. if value is 1000.000 then how can I write this full value without truncating 000 after "." with POI? means I want full value. In my case, it only takes 1000 but this is not right format for me. 回答1: You have to set "Format" of the cell where this number is getting stored. Example code: Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet("format sheet"); CellStyle style; DataFormat format = wb.createDataFormat(); Row row;

How deal with blank cells in excel files java

故事扮演 提交于 2019-12-17 19:04:23
问题 I am making a program where I am reading data from excel files and store them in tables. I have made the program using Apache POI and works fine. But when files have blank cells as the one here I have some problems. The program skip the blanks and read the next data. Could anyone help me how I would do it? I know that there are several posts for this issue but I have not found something useful for me. The code for reading the data from excel file is the below. As you can see I have 3 types of