apache-poi

How to read numeric values from excel in java?

元气小坏坏 提交于 2019-12-25 00:43:02
问题 I have a code to read a xls file in java. But the problem is that when I am read the numeric value that time it gives me wrong format value. My code is String fname = "D:/Vijay/BRS_docs/10168/19.11.2014/19.11.2014/Bank/Debit Open Item File/INF 21 Case.xls"; FileInputStream fis = new FileInputStream(fname); HSSFWorkbook wb = new HSSFWorkbook(fis); HSSFSheet sheet = (HSSFSheet) wb.getSheetAt(0); FormulaEvaluator formulaEval = wb.getCreationHelper().createFormulaEvaluator(); fis = new

Apache POI - Generated Word document works but invokes a security warning

自闭症网瘾萝莉.ら 提交于 2019-12-25 00:30:24
问题 I'm using Apache POI in a Java project to generate a word document based on a template. Specifically I'm using the HWPFDocument class and both the template and the output file is in the old .doc format (Word 97-2004). The reason why I'm using the old format is that I couldn't find any examples on how to search/replace placeholders in a template with the new .docx format. The code works just fine and I have no problem opening the generated .doc file on my Mac (Word 2011). But on Windows

how to create .doc file using java?

情到浓时终转凉″ 提交于 2019-12-25 00:17:43
问题 Can anyone tell me how to create doc files using java? I know, there's a POI library, but it seems like it can save only simple documents. You can read anything you wish, but you can't save it all back again. Or may be i missed something? How can i save whole document with pictures, tables and styles? 回答1: Docmosis lets you do heaps of styling easily via the template. Uses OpenOffice and Java to do the job. Its free and free to distribute. 回答2: It ain't cheap, but you could try Aspose.Words.

How to retrieve the Date from Excel with Formula by Apache POI

旧巷老猫 提交于 2019-12-25 00:16:20
问题 I have an Excel Sheet where the Date Cell is assigned with the Date Formula in Excel TODAY() + 1 . So basically today it's showing as 03/10/2018 by default. I've created a code to read the data from Excel which has the formula in it but when I'm getting the date it's coming differently. Code : Cell c = CellUtil.getCell(r, columnIndex); CellType type = c.getCellType(); if (type == CellType.FORMULA) { switch (c.getCachedFormulaResultType()) { case NUMERIC: if (DateUtil.isCellDateFormatted(c)) {

Java.lang.StackOverflowError Excel in spring boot jpa

◇◆丶佛笑我妖孽 提交于 2019-12-24 23:08:25
问题 I have a problem I dont know how to track the StackOverFlowError it says And the converting to datatypes is okay but I dont know what the error comes from: How to fix this issue? Can you please help what is the most approach to track this error to generate the list and save it to database? at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at com.pioneer.ams.backend.entity.AbstractEntity.toString(AbstractEntity.java:178) at java.lang.String

How to remove a row from an Excel (csv) file using Java?

喜你入骨 提交于 2019-12-24 22:44:57
问题 I have a GUI program in which I write the personal details of people to an Excel spreadsheet saved as a CSV file. I can read and write to it just fine, however, I must be able to remove people from the file. My current code is down below: JButton btnDeleteClient = new JButton("Delete Client"); btnDeleteClient.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Client deleteClient = null; try { String line = ""; br = new BufferedReader(new FileReader(

How to save an xslm file as xslx in Apache POI

只愿长相守 提交于 2019-12-24 22:27:18
问题 All: I am pretty new to Excel and APche POI, I wonder how to read in Excel .xlsm file(Macro Enable excel) and save it as .xlsx file using Apache POI? Any example will be appreciated 回答1: Making an answer from my comments. Hope it will be more clear then. The following code does creating a XSSFWorkbook from a Workbook.xlsm template which remains unchanged. It does changings in this workbook then and, before saving a copy as *.xlsx , the current state will be saved as WorkbookNew.xlsm file. So

IndexOutOfBoundsException when trying to read MS Excel file using Apache POI-HSSF

戏子无情 提交于 2019-12-24 21:14:33
问题 Whilst trying to parse MS Excel file using POI-HSSF v3.2 I am getting IndexOutOfBoundsException. The spreadsheet I am trying to read isn't empty it has been created using MS Excel 2003 and BiffViewer included with the POI package has no problem parsing it. My code is as follows: package src; import java.io.*; import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.eventusermodel.*; class Excel implements HSSFListener { public static void main (String[] args) throws Exception {

getCachedFormulaResultType() of Apache POI returns incorrect type

谁说我不能喝 提交于 2019-12-24 20:13:53
问题 I am reading an Excel sheet. Initially (till rowid 30) I am getting the correct (CELL_TYPE_STRING) result type for the formula cell, but from row id 31 onwards I receive the incorrect (CELL_TYPE_NUMERIC) result type. Please see the logs below: I have used ==== as delimiter for separating logs for each row. Column number 1 is the point to focus, where for rowID=30 I get type=String whereas for rowId=31 I get type=Numeric, but column 1 for each row is of type string therefore I am missing how

Change a String (Put brackets around file name and get TWO Backslashes)

眉间皱痕 提交于 2019-12-24 19:48:11
问题 My project is based on Apache POI.I'm trying to use a formula on a cell. My formula is as follows. sheet7.createRow(0).createCell(0).setCellFormula("+'C:\\Users\\Desktop\\[Test.xlsx]Average_Graph'!A2"); Im using a JFileChooser, which allows users to select the file. Therefore the filepath will be changed every time the program is used. From the JFileChooser, I'm getting a filepath as follows. String filepath= "C:\Users\Desktop\Sheet.xlsx In order to work the formula correctly, the filepath