poi-hssf

Convert csv to xls/xlsx using Apache poi?

孤街浪徒 提交于 2019-11-27 11:23:18
问题 I need to convert csv to xls/xlsx in my project? How can i do that? Can anyone post me some examples? I want to do it with Apache poi. I also need to create a cell from java side. 回答1: You can try following method to create xlsx file using apache-poi. public static void csvToXLSX() { try { String csvFileAddress = "test.csv"; //csv file address String xlsxFileAddress = "test.xlsx"; //xlsx file address XSSFWorkbook workBook = new XSSFWorkbook(); XSSFSheet sheet = workBook.createSheet("sheet1");

Setting foreground color for HSSFCellStyle is always coming out black

喜欢而已 提交于 2019-11-27 04:21:39
问题 I am using POI to create an Excel spreadsheet in Java. I have the following code used for creating a header row: HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Report"); // some more code HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(cellNumber); HSSFCellStyle cellStyle = wb.createCellStyle(); cellStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); HSSFFont font = wb.createFont();

How to insert a row between two rows in an existing excel with HSSF (Apache POI)

天涯浪子 提交于 2019-11-26 21:53:40
Somehow I manage to create new rows between two rows in an existing excel file. The problem is, some of the formatting were not include along the shifting of the rows. One of this, is the row that are hide are not relatively go along during the shift. What I mean is(ex.), rows from 20 to 30 is hidden, but when a create new rows the formating still there. The hidden rows must also move during the insertion/creation of new rows, it should be 21 to 31. Another thing is, the other object in the sheet that are not in the cell. Like the text box are not move along after the new row is created. Its

Reading date values from excel cell using POI HSSF API

六月ゝ 毕业季﹏ 提交于 2019-11-26 13:02:55
问题 I\'m using POI HSSF API for my excel manipulations in Java. I\'ve a date value \"8/1/2009\" in one of my excel cell and while I try to read this value using HSSF API, it detects the cell type as Numeric and returns the \'Double\' value of my date. See the sample code below: cell = row.getCell(); // date in the cell \'8/1/2009\' switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_STRING: cellValue = cell.getRichStringCellValue().getString(); break; case HSSFCell.CELL_TYPE_NUMERIC: cellValue

How to insert a row between two rows in an existing excel with HSSF (Apache POI)

时光怂恿深爱的人放手 提交于 2019-11-26 07:26:08
问题 Somehow I manage to create new rows between two rows in an existing excel file. The problem is, some of the formatting were not include along the shifting of the rows. One of this, is the row that are hide are not relatively go along during the shift. What I mean is(ex.), rows from 20 to 30 is hidden, but when a create new rows the formating still there. The hidden rows must also move during the insertion/creation of new rows, it should be 21 to 31. Another thing is, the other object in the