apache-poi

HTML Formatted Cell value from Excel using Apache POI

拟墨画扇 提交于 2019-12-29 06:28:08
问题 I am using apache POI to read an excel document. To say the least, it is able to serve my purpose as of now. But one thing where I am getting struck is extracting the value of cell as HTML. I have one cell wherein user will enter some string and apply some formatting(like bullets/numbers/bold/italic) etc. SO when I read it the content should be in HTML format and not a plain string format as given by POI. I have almost gone through the entire POI API but not able to find anyone. I want to

How do I get the (Java Apache POI HSSF) Background Color for a given cell?

喜欢而已 提交于 2019-12-29 05:23:22
问题 I have an existing excel spreadsheet, which I am accesssing and reading values from, I am using Apache POI HSSF. It is initialised like this: HSSFSheet sheet; FileInputStream fis = new FileInputStream(this.file); POIFSFileSystem fs = new POIFSFileSystem(fis); HSSFWorkbook wb = new HSSFWorkbook(fs); this.sheet = wb.getSheet(exsheet); I am iterating over all the cells that exist in the sheet, which makes a cell object: HSSFCell cell = (HSSFCell) cells.next(); Please can someone familiar with

How do I get the (Java Apache POI HSSF) Background Color for a given cell?

风格不统一 提交于 2019-12-29 05:23:09
问题 I have an existing excel spreadsheet, which I am accesssing and reading values from, I am using Apache POI HSSF. It is initialised like this: HSSFSheet sheet; FileInputStream fis = new FileInputStream(this.file); POIFSFileSystem fs = new POIFSFileSystem(fis); HSSFWorkbook wb = new HSSFWorkbook(fs); this.sheet = wb.getSheet(exsheet); I am iterating over all the cells that exist in the sheet, which makes a cell object: HSSFCell cell = (HSSFCell) cells.next(); Please can someone familiar with

How can I set background colour of a run (a word in line or a paragraph) in a docx file by using Apache POI?

巧了我就是萌 提交于 2019-12-29 01:01:33
问题 I want to create a docx file by using Apache POI. I want to set background colour of a run (i.e. a word or some parts of a paragraph). How can I do this? Is in possible via Apache POI or not. Thanks in advance 回答1: Word provides two possibilities for this. There are really background colors possible within runs. But there are also so called highlighting settings. With XWPF both possibilities are only possible using the underlying objects CTShd and CTHighlight . But while CTShd is shipped with

Excel Drop down list using Apache POI

这一生的挚爱 提交于 2019-12-28 13:19:28
问题 I need to create a drop down list in excel file using Apache POI. and I am able to do that so But I am not able to make first item in drop down list as default Item. public class sd { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { DataValidation dataValidation = null; DataValidationConstraint constraint = null; DataValidationHelper validationHelper = null; XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet1=(XSSFSheet) wb.createSheet(

XSSFWorkbook takes a lot of time to load

别来无恙 提交于 2019-12-28 05:56:25
问题 I am using the following code: File file = new File("abc.xlsx"); InputStream st = new FileInputStream(file); XSSFWorkbook wb = new XSSFWorkbook(st); The xlsx file itself has 25,000 rows and each row has content in 500 columns. During debugging, I saw that the third row where I create a XSSFWorkbook, it takes a lot of time (1 hour!) to complete this statement. Is there a better way to access the values of the original xlsx file? 回答1: First up, don't load a XSSFWorkbook from an InputStream when

XSSFWorkbook takes a lot of time to load

喜夏-厌秋 提交于 2019-12-28 05:55:28
问题 I am using the following code: File file = new File("abc.xlsx"); InputStream st = new FileInputStream(file); XSSFWorkbook wb = new XSSFWorkbook(st); The xlsx file itself has 25,000 rows and each row has content in 500 columns. During debugging, I saw that the third row where I create a XSSFWorkbook, it takes a lot of time (1 hour!) to complete this statement. Is there a better way to access the values of the original xlsx file? 回答1: First up, don't load a XSSFWorkbook from an InputStream when

Excel Cell Style issue

回眸只為那壹抹淺笑 提交于 2019-12-28 02:16:24
问题 I am using below code to get date value from XLSX file. This is working absolutely fine for some xlsx file . But It is not giving exact date format which is in xlsx file. This issue is for some file. eg; I have date like this 21/01/2016 (dd/mm/yyyy) but after reading, it gives date as 01/21/16(mm/dd/yy) Is there any other way to get cellstyle? Is it issue of xlsx file?? String dateFmt = cell.getCellStyle().getDataFormatString(); if (DateUtil.isCellDateFormatted(cell)) { double val = cell

org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException:

我们两清 提交于 2019-12-28 01:56:13
问题 I'm using the following jar files: dom4j-1.6.1.jar poi-3.9-20121203.jar poi-ooxml-3.9-20121203.jar poi-ooxml-schemas-3.9-20121203.jar xmlbeans-2.3.0.jar Code: package ExcelTest; import java.io.File; import java.io.FileInputStream; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class Test { public static void main(String[] args)

Create an excel file for users to download using Apache POI

。_饼干妹妹 提交于 2019-12-27 19:13:28
问题 I'm able to create an excel file using apache poi. however, i want users to be able to download this as a "true" excel file. the effect i want to achieve would be to have a popup box allowing the user to download the file. this is similar to using <%@ page contentType="application/vnd.ms-excel" pageEncoding="ISO-8859-1"%> <%response.setHeader("Content-Disposition", "attachment;filename=myfile.xls"); %> with one critical exception: i must allow the user to download a proper excel file. i read