apache-poi

Expanding an existing table in Excel using Apache POI

↘锁芯ラ 提交于 2019-12-20 05:49:07
问题 I've got an table in excel with formulae I would like to add data to. My motivation for this is the fact that tables in excel can dynamically expand to the range of data you add to them, meaning that the formula rows automatically keep up with the amount of data rows. I'm however having a hard time finding out if this is possible using apache-POI. One thing I was going to try (see code below) was to expand the AreaReference of the table to cover the data, however both AreaReference(CR,CR2);

Apache POI - Conditional formatting - need to set different cell range for rule and formatting

左心房为你撑大大i 提交于 2019-12-20 05:48:06
问题 I am trying to create an empty excel template using apache poi java. I need to add a rule - when column no. 3 is populated then columns from 7 to 12 need to be highlighted in some color (as a mandatory indicator for the user). I could find below code which colors the cell when the condition is met on the same cell. But I want to color/format different cells when the condition is met on current cell. ` XSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();

Error With creating an excel file from java POI

牧云@^-^@ 提交于 2019-12-20 05:45:34
问题 Hi I would like to create an excel file from a java code, I put this code on eclipse but nothing happen import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import java.io.FileOutputStream; public class TestPOI1 { public static void main(String[] args) { //create the new workbook Workbook workbook = new HSSFWorkbook(); try { //create the output stream to save the document on the hard drive FileOutputStream output = new FileOutputStream("Test1.xls");

cant find close() method on Apache WorkbookFactory

依然范特西╮ 提交于 2019-12-20 05:43:10
问题 i read about Apache WorkbookFactory the guide are saying to close workbook when done. "Workbook should be closed after use" but i dont have a close method to close it. how could it be closed ? Workbook wb = WorkbookFactory.create(tempFile); wb.close(); i'm working with Apache poi Maven, version 3.9 The method close() is undefined for the type Workbook ... line 423 Java Problem Note 1: that in order to properly release resources the Workbook should be closed after use. Note 2: also that

How can add different colour for each worksheet in excel using Apache POI

与世无争的帅哥 提交于 2019-12-20 05:41:49
问题 When you have multiple worksheets in a workbook, you usually click on a sheet's name at the bottom of the page to view it. My question is then to know, if that "button" containing the sheet's name can take a color such as blue, green and so on. XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet(); CTColor color = CTColor.Factory.newInstance(); color.setIndexed(IndexedColors.RED.getIndex()); sheet.getCTWorksheet().getSheetPr().setTabColor(color); I have tried above but no

How to read content from ms word files using Jakarta POI

感情迁移 提交于 2019-12-20 05:24:49
问题 I've included jakarta-poi-1.5.1-final-20020615.jar file to read content from ms word. I am unable to do this ...can anyone help me? 回答1: Here is quick guide 回答2: You need to move to a newer version of POI - the one you're on is about 9 years old! Grab the latest version of POI (it's just Apache POI now, hasn't been Apache Jakarta POI for a few years now), you'll want either 3.7 Final or 3.8 beta 2 as of writing. Then, have a read through the HWPF docs and you should be good to go. 回答3: Use

Add watermark in word document using Apache POI

左心房为你撑大大i 提交于 2019-12-20 05:01:21
问题 I want to add text watermark in word document using Apache POI. I have used headerFooterPolicy.createWatermark("Watermark"); but diagonal grayed text isn't displayed. 回答1: The private XWPFParagraph getWatermarkParagraph(String text, int idx) is simply not finished until now. You can waiting until it gets ready or manipulating it using the low level objects after the default was created. The needed settings are in CTShape. Example: import java.io.*; import org.apache.poi.xwpf.usermodel.*;

how to set background color of a cell using apache pio 4.1.0

五迷三道 提交于 2019-12-20 04:57:15
问题 I am trying to set background color using setFillBackgroundColor method , but it seems necessary to use setFillPattern with it. But using setFillPattern method I am not able to find the plain FillPatternType. cellStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index); cellStyle.setFillPattern(HSSFCellStyle.SPARSE_DOTS); I am not able to find the plain fillPatternType, If I use NO_FILL then the background color is not applying. Without using setFillPattern, I am not able to see the

how to remove all formulas from an excel sheet by java POI api?

≯℡__Kan透↙ 提交于 2019-12-20 04:54:21
问题 we can remove formula from one cell by cell.setCellFormula(null) . but if i want to make the whole sheet formula free. 回答1: See the Apache POI site that exactly answers your question. 来源: https://stackoverflow.com/questions/10991820/how-to-remove-all-formulas-from-an-excel-sheet-by-java-poi-api

Parse Excel by poi and target cell is empty sometimes parse ok sometimes throw nullpointexception

心已入冬 提交于 2019-12-20 04:39:24
问题 I found a strange phenomenon of parse excel by poi. See code goods.subtitle = row.getCell(headerNameIndexMap.get("subtitle")).getStringCellValue(); parse subtitle column and set value to object. There are two excel, both subtitle column is empty, but parse one of them is ok, just subtitle property is null, but when parse another excel, it throws exception: java.lang.NullPointerException After copying some same name column from success excel to fail excel, before parse failed column could