xssf

Extracting data in spreadsheet columns in Apache POI API

本小妞迷上赌 提交于 2019-12-24 08:39:24
问题 Just want to make sure one thing. Does the Apache POI API have any built-in collection/object, like row and cell, for a column in a spreadsheet? Or do I have to build one myself and add all the cells in the column there to do the sorting etc? Is there any other better way to do it? 回答1: The excel format is row based not column based - the file is written with each cell in a row in order, followed by a few bits of row info, then the cells of the next row in order etc. So, if you want to do

NoSuchFieldError when reading Excel sheet in java

断了今生、忘了曾经 提交于 2019-12-23 09:37:45
问题 I've followed a simple guide to constructing a workbook using Apache POI XSSF. Following the same guide I was able to WRITE an Excel sheet, however when attempting to read from one, I'm receiving the error displayed after the code. Code: try { FileInputStream file = new FileInputStream(new File("howtodoinjava_demo.xlsx")); // Create Workbook instance holding reference to .xlsx file XSSFWorkbook workbook = new XSSFWorkbook(file); // Get first/desired sheet from the workbook XSSFSheet sheet =

How to import both xls and xlsx files using java in spring mvc

一个人想着一个人 提交于 2019-12-23 05:29:26
问题 In this method i used xssf class which is used to read xlsx file but we cant do it for xls file.for xls we need to have Hssf class .User can import any format there .My requirement,Is there any Class that can be used instead of xssf and hssf to read both kind of file. in my example i used xssf. @RequestMapping(value="/import",method = RequestMethod.POST) public ModelAndView imports(Model model, @RequestParam("excelFile") MultipartFile excelfile){ try { List<DepartmentModel> lstUser = new

java.lang.OutOfMemoryError: GC overhead limit exceeded when loading an xlsx file

天大地大妈咪最大 提交于 2019-12-23 02:32:54
问题 I understand what the error means, that my program is consuming too much memory and for a long period of the time it is not recovering. My program is just reading 6,2Mb xlsx file when the memory issue occures. When I try to monitor the program, it very quickly reaches 1,2Gb in memory consumption and then it crashes. How can it reach 1,2Gb when reading 6,2Mb file? Is there a way to open the file in chunks? So that it doesn't have to be loaded to the memory? Or any other solution? Exactly this

Jersey @Produces Apache XSSFWorkbook

人盡茶涼 提交于 2019-12-22 12:14:09
问题 I am trying to produce a XSSFWorkbook using Jersey. I have tried the following headers and nothing seems to work: @Produces("application/xml") @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Produces("application/vnd.openxml" All return the following error: Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.apache.poi.xssf.usermodel.XSSFWorkbook, and Java type class org.apache.poi.xssf.usermodel.XSSFWorkbook, and MIME media

Jersey @Produces Apache XSSFWorkbook

a 夏天 提交于 2019-12-22 12:13:49
问题 I am trying to produce a XSSFWorkbook using Jersey. I have tried the following headers and nothing seems to work: @Produces("application/xml") @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Produces("application/vnd.openxml" All return the following error: Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.apache.poi.xssf.usermodel.XSSFWorkbook, and Java type class org.apache.poi.xssf.usermodel.XSSFWorkbook, and MIME media

Getting error “Your InputStream was neither an OLE2 stream, nor an OOXML stream” when created file through apache POI

邮差的信 提交于 2019-12-22 10:17:44
问题 I am trying to check if my excel file already exists. If it doesn't exists, I want to create a new one and if it exists I will delete it and create a new one. I wrote following program but I am getting error at line - workbook= WorkbookFactory.create(instream); The error is-> java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:89) at tryIng.main(tryIng.java:84) Here is a

Adding border to a merged region in POI XSSF workbook

烂漫一生 提交于 2019-12-20 12:30:48
问题 I'm using apache poi 3.7 and I need to put border to a range of cells or merged region. how can I to apply border to a merged region when the sheet and workbook type is XSSF. In HSSF type I use RegionUtil-/HSSFRegionutil, but if use the first object (Regionutil) in XSSF type its doesn't works and puts a black background color to the range of cells. Regionutil ussually works with CellRangeAddress and i don't find information about this trouble. I don't know if the CellRangeAddres causes this.

XSSFWorkbook when written creates a corrupted .xlsx document in Spring Boot application using JDBC

穿精又带淫゛_ 提交于 2019-12-18 07:07:41
问题 For a project I need to create an .xlsm excel document automatically filling out a template file. Problem is, that the output is corrupted and cannot be read by Excel 365 nor by Apache POI. I have distilled it down to the following minimal example, that can run in a main method. To be completely safe it is using the .xlsx format. public static void main(String[] args) { XSSFWorkbook document = new XSSFWorkbook(); XSSFSheet spreadsheet = document.createSheet("Test"); spreadsheet.createRow(0)

How to load a large xlsx file with Apache POI?

早过忘川 提交于 2019-12-17 03:57:20
问题 I have a large .xlsx file (141 MB, containing 293413 lines with 62 columns each) I need to perform some operations within. I am having problems with loading this file ( OutOfMemoryError ), as POI has a large memory footprint on XSSF (xlsx) workbooks. This SO question is similar, and the solution presented is to increase the VM's allocated/maximum memory. It seems to work for that kind of file-size (9MB), but for me, it just simply doesn't work even if a allocate all available system memory.