I am using apache poi 3.12 to generate excel using database data. For some cells I am using formulas also, all calculations are working properly and file was generated successfully. Below is my issue.
1) Opened the generated file using MS Excel application.
2) Verified the values and all are Ok.
3) As the excel file was password protected after verification I tried to close the file.
4) While closing it was showing message as "MS EXcel recalculates formulas when opening files last saved by an earlier version of excel".
I added "workbook.setForceFormulaRecalculation(false);" before writing my input stream to workbook.
From API docs it says it will not recalculate the formulas one workbook is opened if set the value to "false".
FYI, I have used unimplemented excel function "YIELD" in one cell.
Can anybody help on this.
Related
I am using Apache poi library in java for generating excel report.
For generating excel report, i am reading text file which is delimited using PIPE and writing that into excel sheet.
Most of the cases say 98%, i don't see any issue. Some times the excel file generated unable to open. Says "Unreadable content".
I am fixing the issue by adding /removing one or two character(i.e XX or AA) to/from the data in the text file resolves this issue. I have compared data file of working one as well as corrupted one. I don't see any difference at all.
I am not sure what could be the reason for this issue. I don't see any exception or error while writing data in to excel file.
Datafile is thousands of lines and the source code has around 15 classes each goes around 300 to 400 lines. So, it's hard to post both. Sharing partial feed or class is not worth since the any addition/removal of character makes the sheet readable
This excel report has 10 to 15 sheets and multiple formats and cell merge as well as formula.
Does anyone have suggestion on this. Is there chance for memory issue while reading or writing. File is read line by line and written as sheet by sheet.
I went through the whole application and i could not find any trace. So i upgraded the application from Apache poi HSSF to Apache poi XSSF and refactored all the methods in the application that fixed this issue.
I have two excel documents excel1.xls and excel2.xlsm. Where I read the data from excel1 and write it to excel2 using Apache API. In excel2 file, some cells have the formulas to auto update.
Problem: When the excel2 file is last opened/saved with Microsoft Excel 2007, everything works fine. But, when its last opened/saved with 2013 version, the auto update cell doesn't work anymore. All the computers at work are now moved to Office 2013, So I can't use Excel 2007 anymore.
I have already checked/set the setting Formulas - > Calculations Options -> Automatic in Excel
I also tried to use evaluateFormulaCell() and evaluateAllFormulaCells()methods in the program, doesn't update anything.
I am not sure, whether the excel has some kind of security, which is stopping to auto update?
XSSFFormulaEvaluator.evaluateAllFormulaCells(workbook);
This method worked for me, before I only used to call this method at the end, but now I called it every time I set a single cell and it worked.
You might be able to re-save the excel files in 2007 format. This could solve it.
I need to write one java program which monitors a folder containing excel sheets (.xls format) . Once a new excel sheet is added I have to update the database in db2 and move the excel sheet to other place.
Please suggest
It sounds like you need to get notified if files appear in a directory. Java 7 has good support for this, see this article about the Watch Service API. The db2 part, well it isn't clear what you mean by "update", but likely you want to parse the content of the xls file and make some database updates. Apache POI is a good starting place for reading the content of the file into a Java process.
I am working on a struts based web application. In that application, we generate and download xls file from Jsp.
In Jsp file and web.xml, I have set the content-type as "application/vnd.ms-excel"
it seems xls files generated by the jsp pages are not real excel files, but a text format that is understood by the MS Excel. Hence excel opens the files and displays the output similar to excel files saved by MS Excel. Since newer versions of MS Office 2007/2010 checks the file extension and the content inside the file, they issue a warning that the file format does not match with the content.
To get rid of the warning how can i ensure that the generated xls is real office excel file .
Please help.
For future readers who might need this...
Excel will complain anyway, even if your excel file is 'correct', as long as its structure doesn't properly match the extension. So if you're saving as an .XLS, it expects to see the classic excel file.
The popup you are getting is because of the new security feature in Office 2007, called Extension Hardening and you can disable it if you want - either manually in the registry, or you can save the patch to a .REG file and share it to you clients etc.
Save those 2 line below into a GiveItSomeName.reg file, which you can then email to your clients and tell them to execute it.
[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security]
"ExtensionHardening"=dword:00000000
I wrote a Java method that uses POI HSSF API to convert an Excel file to my data structure.
The code worked just fine for a while. But now there are suddenly problems. I suspect it might be because recently we installed Office 2007 on all the client computers, previously we had Office 2003.
The problem I ran into is: Inside the XLS file I have a column of cells that is filled with serial-numbers by the user. When the Java application gets the cell, it has a cell type STRING. And when I ask for the string value of the cell I get an empty string.
The file is originally created by the application, then the users fill it with data and load it back into the aplication. So I don't think the file format is wrong, since it's created by the same version of the API.
What could be the problem?
EDIT:
Clarification: We upgraded Office installation to 2007, but the application still uses HSSF and XLS format. Only the users open and edit the files with Office 2007. Is that a problem?
Have you checked if Excel automatically switched the cell type to NUMERIC when the user entered the value?
Excel has this annoying feature to "intelligently guess" what kind of value the user enters which then often causes a problem in POI.
HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
read furthur
http://poi.apache.org/spreadsheet/index.html