apache-poi

how to remove warnings in excel generated by POI ?

痞子三分冷 提交于 2019-12-10 16:07:03
问题 I am using Apache POI for writing content into excel sheet. after generating an excel in all the cells which ever cell has numbers, it contains one blue mark(each cells left top corner). its like a warning. how can i remove them while writing the content to excel? PFA screen shot. Thanks! 回答1: You can try to set the cell type: HSSFCell cell = row1.createCell(i); cell.setCellType(Cell.CELL_TYPE_STRING); // =0, or Cell.CELL_TYPE_NUMERIC = 1 cell.setCellValue(value); See the API docs for more

Java code for excel row in Bold text style with Background color

点点圈 提交于 2019-12-10 15:34:51
问题 I have googled some code and found some answers but not able to get my excel file output in Bold and set background color. I have tried with following code. can you please tell me where am I going wrong? Please take a look. Thanks. FYI: I am going to make 1st Row in BOLD with blue or any Light color background. If you know please help with the code. // Excel file generation code HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Readings"); CellStyle style =

How to read font color of each text in cell in apache poi 3.9

无人久伴 提交于 2019-12-10 15:34:35
问题 [Text in 1 Cell] ABC (Pink Color) DEF (Black Color) GHI (Red Color) I have to check font color of text in cell like above. (I'm sorry that I can't upload image) Color of first row is pink. Color of next rows are black and red. As you see, I can't use getCellStyle() method because the cell has 3 font attribute. I typed source code like below. XSSFCell cell = row.getCell(0); XSSFRichTextString value = cell.getRichStringCellValue(); String[] info = value.getString().split("\n"); for(int i = 0; i

Creating the border for the merged cells in POI

一个人想着一个人 提交于 2019-12-10 15:29:27
问题 Could anyone explain me how to create the borders for the merged cells using Apache POI? The Code I'm using is only affecting one cell. sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 3)); Cell monthCell = subheaderRow.createCell(2); monthCell.setCellValue(2); monthCell.setCellStyle(styles.get("month")); style = wb.createCellStyle(); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderLeft(CellStyle.BORDER_THIN); style.setBorderRight

hyperlink to a different sheet within the same workbook using apache poi

点点圈 提交于 2019-12-10 14:51:18
问题 I am using Apache POI to generate an excel workbook containing multiple sheets. I want to create a hyperlink from one sheet to another. How to accomplish this ? There are solutions I found for establishing hyperlinks to websites, even other excel files but not to other sheets within the same workbook. Does Apache POI allow us to do this ? 回答1: Yes, Apache POI allows you to create a hyperlink to another sheet in the same workbook. According to the Apache POI Quick Guide: cell = sheet.createRow

Inserting a base64 encoded image into xsl-fo file while using apache-poi

淺唱寂寞╮ 提交于 2019-12-10 14:31:30
问题 I am using Apache POI to convert .doc to .fo using the WordToFoConverter class, I have converted the images in the word file to base64, but how do i append it to the xsl-fo code generated by apache-poi? Consider the sample fo file generated by Apache-POI- <?xml version="1.0" encoding="UTF-8" standalone="no"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="page-page0" page-height="11.0in" page-width="8.5in"> <fo:region-body

What is the difference between getRichStringCellValue() and getStringCellValue() methods of POI HSSFCell class?

强颜欢笑 提交于 2019-12-10 14:24:51
问题 I am trying to read data stored in a Excel sheet using Java POI. I am confused with these two methods because both methods reutrn string value stored in the cell. Could anyone explain the difference between these two methods? 回答1: The important clue is to look @ the documentation and note the different return types. getRichStringCellValue() returns the type of XSSFRichTextString while getStringCellValue() returns a plain old java String. You probably only want to use getStringCellValue(),

Poi Formula evaluation

你离开我真会死。 提交于 2019-12-10 14:02:26
问题 I am facing difficulties while reading formula cell values with POI I have created formula cell as follows: cell.setCellType(HSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("SUM(D8..F8)"); And I am reading it as follow: double formulaCellValue = row.getCell((short) 7).getNumericCellValue(); When read this way(using getNumericCellValue() ), I am always getting the value of 0.0. Any quick help in this regard would be highly appriciated. 回答1: After you're done setting all your formulas, you

How to merge cells and set value at the same time by using Apache POI?

自闭症网瘾萝莉.ら 提交于 2019-12-10 13:54:28
问题 I want to merge some cells in my excel template file, and then set values in merged cells. Here is my java code. Before I add set value part , it works well on merging cells. But when I just add set value part , it seems like nothing changed even no cells merged. I also try to move set value part after merge cells part , then office remind me repair the output excel file. What should I do to merge cells and set value at the same time? for (int sht = 0; sht < 3; sht++) { sheet = workbook

Excel biff5 to biff8 conversion

99封情书 提交于 2019-12-10 13:45:38
问题 My system uses Apache-POI to manage some xls files. Now I've got almost 300 xls files, but it appears that they are in an old format so i got this exception: The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003) Is there a way to handle that or to automatically convert all those files to a biff8 format? 回答1: Go with converting it to OOXLS format, POI supports both BIFF8 and newer OOXLS. Download official