apache-poi

read excel file using Apache POI

风流意气都作罢 提交于 2019-12-07 05:08:00
问题 I have created this code to read the contents of excel files using Apache POI. I am using eclipse as editor but when i ran the code i have problem in the line that I have in bold. What's the problem? The content of excel is the following: Emp ID Name Salary 1.0 john 2000000.0 2.0 dean 4200000.0 3.0 sam 2800000.0 4.0 cass 600000.0 import java.io.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi

Get Excel SheetNames using POI jar

北慕城南 提交于 2019-12-07 04:56:34
问题 I need all Excel sheet Names (what r all contains the datas) using POI jar. Like jxl jar - getSheetNames() 回答1: You don't say how you want them, so I'll guess at a list. You just need to iterate over the sheet indicies, getting the name for each. Your code would be something like: File myFile = new File("/path/to/excel.xls"); Workbook wb = WorbookFactory.create(myFile); List<String> sheetNames = new ArrayList<String>(); for (int i=0; i<wb.getNumberOfSheets(); i++) { sheetNames.add( wb

Standalone Jython: Import Error (Apache-POI)

左心房为你撑大大i 提交于 2019-12-07 04:53:07
问题 Jython standalone jar is throwing the ImportError exception at the time that I try to use Jython alongside Apache-POI. Below you'll find how I call my Jython script: java -cp C:\jAutoMailerScript\lib\poi-3.9-20121203.jar -jar jython.jar main.py Error: Traceback (most recent call last): File "main.py", line 32, in from org.apache.poi.hssf.usermodel import * ImportError: No module named apache This is the code at line#32: from org.apache.poi.hssf.usermodel import * Is there any restriction from

XMLBeans jar can't be signed when imported from custom class

妖精的绣舞 提交于 2019-12-07 04:46:59
问题 In NetBeans I created an Exporter class that exports some data to an EXCEL file using APACHE POI, which uses XMLBeans. I added the APACHE POI 3.10.1 libraries by downloading the zip binaries and adding the jars manually. When I use this class inside the same project, everything runs correctly. Then I added this class to another project, via right click Libraries -> Add Project. But when I tried running this I got the following error while compiling. Signing JAR: C:\Users\c\p\dist\lib\xmlbeans

How to merge cells (or apply colspan) using XWPFTable in POI in Java?

∥☆過路亽.° 提交于 2019-12-07 03:59:07
问题 Creating a table in poi was quite easy but it has very limited tutorials and I cannot find one that can create a simple merged cell in a table in generating a docx file. 回答1: If you have created table, row inside a table and cell inside a row, you can add gridSpan to cell properties: if (cell.getCTTc().getTcPr() == null) cell.getCTTc().addNewTcPr(); if (cell.getCTTc().getTcPr().getGridSpan() == null) cell.getCTTc().getTcPr().addNewGridSpan(); cell.getCTTc().getTcPr().getGridSpan().setVal(2);

Resource leak: workbook is never closed warning when using Apache.POI XSSFWorkbook

落爺英雄遲暮 提交于 2019-12-07 03:41:49
问题 So, I using Apache POI in order to parse an Excel file to my Database. For this I am initializing an XSSFWorkbook as follows: XSSFWorkbook workbook = new XSSFWorkbook(fIP); Then I proceed with my method. workbook.close() is not available as a method to close the workbook afterwards. Any ideas of how can I let garbage collection take the workbook after the task is finished? 回答1: I had this issue, and it was making little sense. In the end I tracked the issue down to my IDE (netbeans) was

Apache POI SXSSF and XSSF

╄→尐↘猪︶ㄣ 提交于 2019-12-07 03:36:01
问题 I have one question. Am I right that if I have a workbook which is created through xssf constructor then it is enough to change the constructor to sxssf workbook (with xssf wb passed as an argument) to make it work in a stream mode ? Thanks a lof for your answers. Solution: It all depends on the classes which you use for streaming. If your class gathers more stream buffers than it can hold, this thing won't work. Otherwise it will 回答1: Yes, you're right. The difference between these two

What is the C# equivalent of Apache POI api?

元气小坏坏 提交于 2019-12-07 02:48:31
问题 I have a need to replicate a framework I built ij Java using the Apache POI api to read data from MS Excel. I have no idea what to use that is an equivalent of apache POI library. Any ideas please anyone? 回答1: It depends on what you want to do. One option is NPOI, which is a .Net port of Apache POI to .Net Another option is to use IKVM, and then Apache POI itself directly from within .Net. 回答2: You could use Open XML SDK for manipulating MS Office document formats since Office 2007. 来源: https

read the contents of a file upload in java

泄露秘密 提交于 2019-12-07 02:32:13
问题 I know how to upload a file: <html> <head> <title>File Uploading Form</title> </head> <body> <form action="UploadServlet" method="post" enctype="multipart/form-data"> File :<input type="file" name="file" size="50" /> <input type="submit" value="Upload File"/> </form> </body> </html> This is the class for reading the file: import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class BufferedReaderExample { public static void main(String[] args) { try

POI Excel Merging Causing “Repaired Records: Format from /xl/styles.xml part (Styles)”

五迷三道 提交于 2019-12-07 02:27:03
问题 I have merged two excel files using the code specied here http://www.coderanch.com/t/614715/Web-Services/java/merge-excel-files this the block applying the styles for my merging cells if (styleMap != null) { if (oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()) { newCell.setCellStyle(oldCell.getCellStyle()); } else { int stHashCode = oldCell.getCellStyle().hashCode(); XSSFCellStyle newCellStyle = styleMap.get(stHashCode); if (newCellStyle == null) { newCellStyle = newCell