apache-poi

Creating cell comments in apache poi (for .xlsx files) with show comments disabled

隐身守侯 提交于 2019-12-07 01:07:29
问题 I am trying to create cells comments using apache poi. I am able to create the comments, but by default they are always displayed in excel. I have to manual right click on the cell and un-tick show comments to make them invisible(now they appear only when I hover on the cell). Is it possible to make cell comments invisible by default(so that they don't appear in the excel until user hover over the cell.) Here is the code I used : Drawing drawing = cell.getSheet().createDrawingPatriarch();

Are there any alternatives to using Apache POI Java for Microsoft Office?

寵の児 提交于 2019-12-07 00:53:41
问题 I discovered Apache POI for doing a lot with MS Office programmatically in Java, but its documentation leaves me wanting, as well as a few other things. Does a better alternative exist? I thought to myself that OpenOffice.org might have something, but cannot find any concise site that would have a Library that would allow you to open and store Word, Powerpoint, Excel, or other MS Office applications through Java. Do any better alternatives exist? 回答1: I think POI is the best among other

Make the entire row bold using Apache POI

℡╲_俬逩灬. 提交于 2019-12-06 21:42:31
问题 I am using Apache POI's HSSFWorkbook to write data to Excel spreadsheets. I want to make an entire row bold. Can someone please suggest how to do it? 回答1: Would something like this work with what you have: public static void makeRowBold(Workbook wb, Row row){ CellStyle style = wb.createCellStyle();//Create style Font font = wb.createFont();//Create font font.setBold(true);//Make font bold style.setFont(font);//set it to bold for(int i = 0; i < row.getLastCellNum(); i++){//For each cell in the

Why can't I link one workbook to another in Apache POI?

半腔热情 提交于 2019-12-06 20:50:38
问题 I have one workbook that has some data in it. I am taking that workbook and creating another workbook with a line chart in it based off of the data in the other workbook. The code runs fine, but whenever I open up the graph file, I get the warning We can't update some of the links in your workbook right now . If I click the Edit Links... button in the warning menu, it shows that the data workbook cannot be found. If I click on Change Source... , and select the proper workbook, it then works

Java POI cannot find symbol WorkbookFactory

家住魔仙堡 提交于 2019-12-06 17:13:59
问题 im doing a conversion of the HSSF model to XSSF. Im getting lil errors here and there. I donwloaded the latest POI and dropped all the jar files in and did the apache includes in my java class.....getting this error: import org.apache.poi.ss.usermodel.Workbook; Workbook wb = WorkbookFactory.create(); 275: cannot find symbol [javac] symbol : variable WorkbookFactory [javac] location: class mil.usmc.logcom.chassis.util.HSSFUtils [javac] Workbook wb = WorkbookFactory.create(); 回答1: There is no

Merge and align center cell using apache poi

女生的网名这么多〃 提交于 2019-12-06 16:46:10
问题 I want to export data to excel using Apache poi . Now the problem that I am facing is that I am unable to merge rows and align them in the center. Code for export data is: List<LinkedHashMap<String,Object>> lstReportHeader = null; HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); //Set Header Font HSSFFont headerFont = wb.createFont(); headerFont.setBoldweight(headerFont.BOLDWEIGHT_BOLD); headerFont.setFontHeightInPoints((short) 12); //Set Header Style CellStyle

Display percentage values in Excel using POI API

纵然是瞬间 提交于 2019-12-06 16:32:06
问题 I need to display a value in an excel cell formatted like a percentage, e.g. like 12.3% . By default the value is displayed as Text, but I need to display it as a number. What is the appropriate method to achieve this? 回答1: You need to: Set your data as number (floating-point), not as text. Specify cell format as percentage. Something like: cell.setCellValue(0.123); // set value as number CellStyle style = workbook.createCellStyle(); style.setDataFormat(workbook.createDataFormat().getFormat(

How to get the whole row for a if specific column has a certain text with POI

我只是一个虾纸丫 提交于 2019-12-06 14:31:19
I need to filter my excel spreadsheet for the word "GHH" anywhere in the text of a cell in a specific column. I have managed to do this by I then need to have returned the whole row that this text is found in. This I can't do as there doesnt seem to be a way of using the getRowIndex method to then display the whole row. Here is my code: public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream(new File("myfile.xls")); HSSFWorkbook workBook = new HSSFWorkbook(fis); HSSFSheet sheet = workBook.getSheetAt(0); Iterator < Row > rows = sheet.rowIterator();

How to set PivotTable Field Number Format Cell with Apache POI

喜你入骨 提交于 2019-12-06 14:26:40
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 of Balance pivot table Value select Field Settings click Number... set Format Cells Help please with