apache-poi

Modifying existing xlsx spreadsheet using Apache POI leads to unreadable content error

孤街醉人 提交于 2019-12-11 01:47:21
问题 So the topic of unreadable content errors in Excel with Apache POI seems common. However, I was surprised that I still could not find an example of my issue, especially since it seems extremely simple what I'm trying to do. This leads me to believe something is probably just going over my head with my understanding of some java objects, specifically File and FileInputStream. I found out through lots of trial and error how to make it work, but my question is WHY one works and why the other

How to copy entire sheets from large excel files without parsing them using Apache POI?

大憨熊 提交于 2019-12-11 01:39:33
问题 I am new as an official user, I always found my answers here but now I have got to ask. I am working with the last apache-poi 3.8 release (from 2012/03/26) and I have to manipulate a single file with multiple sheets in which only one contains a big amount of data (over 1000 columns and 10 000 rows). I only need to had more columns to the big sheet. Therefore, with the current tools that exist I should use SAX to read it and SXSSF to rewrite it. The Excel file is already preformatted with

Initialisation of record 0x5B left 1 bytes remaining still to be read. Apache POI Java

若如初见. 提交于 2019-12-11 01:15:29
问题 I am using the following code to convert an xls to csv and I get the error : Initialisation of record 0x5B left 1 bytes remaining still to be read . I thought it might be the file, I have tried different files and it's not the case. import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; import org

How to add page numbers in format X of Y while creating a word document using apache poi api?

时光怂恿深爱的人放手 提交于 2019-12-11 00:58:42
问题 Is there any method specified in POI API to get the total number of pages, I am able to add page number in the footer of the document but i am not able to add the total number of pages value. 回答1: Page count in Word is dependent of much things like font size, paragraph top/bottom margins and padding, printer settings, manually inserted page breaks and so on. So it cannot be stored directly in the file. It will be calculated on the fly while Word is rendering its pages. But we can use fields

Reading a range of excel sheet data using POI

耗尽温柔 提交于 2019-12-11 00:52:55
问题 I am doing some POC on reading data within a range from an excel file to an array in Java in singleshot. I have to read an excel file using POI in Java where the no: of rows will be near to 1,00,000 and the no: of columns will be near to 240. Most of the examples which I got from internet tells about using rowIterator and cellIterator for getting this job done. But since the rowcount and columncount is huge, iterating through each cell and adding data to an array is not a feasible solution.

Getting error with Apache POI which is not able to read file passed using FileInputStream

别来无恙 提交于 2019-12-11 00:49:08
问题 While executing below code, FileInputStream fis = new FileInputStream("C:\\Users\\deepa\\Downloads\\TestDocument.xlsx"); XSSFWorkbook workbook = new XSSFWorkbook(fis); I am getting error as InputStream of class class org.apache.commons.compress.archivers.zip.ZipArchiveInputStream is not implementing InputStreamStatistics. I have included all the apace poi jar files and common -compress jar file. Please help. 回答1: Not a java expert of any sorts, but I use Selenium for test automation and was

Apache POI blank values

。_饼干妹妹 提交于 2019-12-11 00:00:42
问题 I am using Apache POI to import data from excel file to database .(newbie to APACHE POI) In which I am allowing user to select columns from excel sheet and Map those columns to the Database columns. After mapping the columns, when I try to insert the records from Excel to Database then: If Columns with NO blank values in them are Mapped then Proper data is inserted into the database If columns are Mapped with BLANK values in them, then if a Excel Cell has blank value then previous value of

apache poi upgrade from 2.5 to 3.8 gives Excel error

这一生的挚爱 提交于 2019-12-10 23:12:07
问题 We need to provide support for Excel 2010 so have upgraded to Apache poi 3.8. But while downloading the excel it takes so much time for opening and also provides error message as "EXCEL found unreadable content. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click yes" And after clicking "yes", it gives me one more pop up which says, Excel completed file level validation and repair. Some parts of this workbook may have been repaired or

Focus on first cell in excel

对着背影说爱祢 提交于 2019-12-10 21:59:54
问题 HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file)); HSSFSheet s = wb.getSheetAt(0); wb.setActiveSheet(0); s.showInPane(0, 0); FileOutputStream out = new FileOutputStream(file); wb.write(out); out.close(); I am using above code for taking focus to first cell (when I open excel first cell shouldd be selected). It is opening the excel correctly because of showInPane , but selecting the first cell is not working. 回答1: Something like this HSSFWorkbook wb = new HSSFWorkbook(new

apache poi: how to create chart with both bar and line?

给你一囗甜甜゛ 提交于 2019-12-10 21:49:59
问题 Is it possible to create a chart in apache poi with both bar and line in it? You can find an example here. If yes, can you please provide sample code to achieve this? Looking forward to hearing from you. Thanks in advance. 回答1: This is the solution I found. I unfortunately couldn't change the axis for the line chart. However you can easily change this manually on the file.When you open it, click on top of the line series with the right button and select "Format Data Series" you can change it