poi-hssf

Java. HSSF. Apache-poi. How to modificate code

自作多情 提交于 2019-12-04 06:28:55
问题 My data is stored in a format(look down): [-] means a blank cell, on the right may be only 10 columns, after the space. Something like this: [string0] [-] [string1] [string2] [string3] .. [string10] [-] How to change this code for: 1) obtain only [string0] 2) obtain only [string1] [string2] [string3] .. [string10] [-] try { FileInputStream file = new FileInputStream("C:\\Users\\student3\\"+sfilename+".xls"); //Get the workbook instance for XLS file HSSFWorkbook workbook = new HSSFWorkbook

Java POI: How to find an Excel cell with a string value and get its position (row) to use that position to find another cell

旧街凉风 提交于 2019-12-04 03:04:25
问题 I'm looking for a cell in a spreadsheet that has the string 'Total' and then use the row in which that cell is to find the total value in another cell which is always the same cell/column (the 10th cell in a 0 based index). I have the following code, which has no errors (syntax), but the findCell method is not returning rowNum value: public static void main(String[] args) throws IOException{ String fileName = "C:\\file-path\\report.xls"; String cellContent = "Total"; int rownr=0, colnr = 10;

POI / Excel : applying formulas in a “relative” way

时光毁灭记忆、已成空白 提交于 2019-12-03 09:43:04
问题 I'm using Apache's POI to manipulate Excel (.xls) files with Java. I'm trying to create a new cell whom content is the result of a formula as if the user had copied/pasted the formula (what i call the "relative" way, as opposite to "absolute"). To make myself clearer, here is a simple example: Cell A1 contains "1",B1 contains "2", A2 contains "3", B2 contains "4". Cell A3 contains the following formula "=A1+B1". If I copy the formula to the A4 cell under excel, it becomes "=A2+B2" : excel is

Delete an excel sheet using Apache POI

谁说胖子不能爱 提交于 2019-12-03 05:39:32
I have to delete a sheet from the Excel file. Here's my code snippet : FileInputStream fileStream = new FileInputStream(destFile); POIFSFileSystem fsPoi = new POIFSFileSystem(fileStream); HSSFWorkbook workbook = new HSSFWorkbook(fsPoi); int index = 0; HSSFSheet sheet = workbook.getSheet("Setup"); if(sheet != null) { index = workbook.getSheetIndex(sheet); workbook.removeSheetAt(index); } return destFile; After this I'm getting exactly the same workbook which I passed, without the removal of the sheet "Setup" Help me resolve this. Any help would be appreciated After editing your workbook, you

POI / Excel : applying formulas in a “relative” way

谁说胖子不能爱 提交于 2019-12-02 22:43:14
I'm using Apache's POI to manipulate Excel (.xls) files with Java. I'm trying to create a new cell whom content is the result of a formula as if the user had copied/pasted the formula (what i call the "relative" way, as opposite to "absolute"). To make myself clearer, here is a simple example: Cell A1 contains "1",B1 contains "2", A2 contains "3", B2 contains "4". Cell A3 contains the following formula "=A1+B1". If I copy the formula to the A4 cell under excel, it becomes "=A2+B2" : excel is adapting the content of the formula dynamically. Unfortunately I cannot get the same result

Java. HSSF. Apache-poi. How to modificate code

徘徊边缘 提交于 2019-12-02 12:31:35
My data is stored in a format(look down): [-] means a blank cell, on the right may be only 10 columns, after the space. Something like this: [string0] [-] [string1] [string2] [string3] .. [string10] [-] How to change this code for: 1) obtain only [string0] 2) obtain only [string1] [string2] [string3] .. [string10] [-] try { FileInputStream file = new FileInputStream("C:\\Users\\student3\\"+sfilename+".xls"); //Get the workbook instance for XLS file HSSFWorkbook workbook = new HSSFWorkbook(file); //Get first sheet from the workbook HSSFSheet sheet = workbook.getSheetAt(0); //Iterate through

Apache Poi: Converting from HSSF to SS?

a 夏天 提交于 2019-12-02 08:10:50
问题 I've converted all of my old code in HSSF to SS except for the portion where I make the work book. Old Code: HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file)); New Non-working Code: Workbook[] wb2 = new Workbook[] {new FileInputStream}; This is an example of conversion that the site gave: NEW: Workbook[] wbs = new Workbook[] { new HSSFWorkbook(), new XSSFWorkbook() }; OLD: HSSFWorkbook wb = new HSSFWorkbook(); 回答1: Workbook is an interface, you can't instantiate it. Instead, what

I want to read particular string from a text file and store them in Excel sheets

回眸只為那壹抹淺笑 提交于 2019-12-02 07:07:25
问题 My Text file Contains line like this FLTR TID: 0000003756 RPC ID: 0000108159 USER: Remedy Application Service FLTR TID: 0000003756 RPC ID: 0000108159 USER: Remedy Application Service FLTR TID: 0000003756 RPC ID: 0000108159 USER: ibsdr FLTR TID: 0000003756 RPC ID: 0000108159 USER: Vinay.k@in.uni.com FLTR TID: 0000003756 RPC ID: 0000108159 USER: Vinay.k@in.uni.com FLTR TID: 0000003756 RPC ID: 0000108159 USER: wsdl FLTR TID: 0000003756 RPC ID: 0000108159 USER: stefan.hummel@uni.com I want to

Getting error using POI HSSF

核能气质少年 提交于 2019-12-02 06:54:34
问题 I'm getting an error when trying to open an Excel sheet with MS office 2003. This Excel sheet is created using HSSFWorkbook, implementing the usermodel scope org.apache.poi.hssf.usermodel In Microsoft Excel 2003: "Too many different cell formats". In Microsoft Excel 2007/2010, files may produce the following error message: "Excel found unreadable content in the file". This is regarding cell formats, please refer to the below page: http://support.microsoft.com/kb/213904 So how can I fix this