While practicing the jxl API, i cant extract details from certain Excel sheet its throwing the following exception
Unable to recognize OLE stream
at jxl.read.biff.CompoundFile.(CompoundFile.java:116)
at jxl.read.biff.File.(File.java:127)
at jxl.Workbook.getWorkbook(Workbook.java:221)
at jxl.Workbook.getWorkbook(Workbook.java:198)
at Com.Parsing.ExcelFile.excel(Extract.java:13)
at Com.Parsing.Extract.main(Extract.java:35)
It sounds like there's something wrong with the Excel file.
You might have better luck posting the question on The JExcelApi Yahoo Group - the guy who created JExcelApi hangs out there and often answers questions.
If you are using maven and filters, check that your .xls file is not filtered.
Related
I want to write some java code to read, write, edit and do other things with sets of Microsoft Word files (different Word versions). What is the best API for this, and how do I get started?
P.S. I searched StackOverflow and found that this question has been asked before, but several years ago. I would like to know the best available API today. Thanks.
Check out apache POI : https://poi.apache.org/
As quoted on their website.. "Apache POI - the Java API for Microsoft Documents"
Personally I have only used this for EXCEL spreadsheet manipulation, but it does support word documents as well...
The best part is it's open source and completely free!
Does anyone knows if I can specify the name(s) of the sheets that I want to read using Apache Poi?
Right now I'm using a for to read all sheets in a workbook.
Ok, so to answer the question and save you a lot of time...
Yes, it is possible and can be easily done via getSheet(java.lang.String name) on the org.apache.poi.ss.usermodel.Workbook.
As a side note I'd strongly suggest going through POI Busy Developers' Guide and the API documentation, as it's a really powerful library which familiarity with can save you a lot of time in the future.
I have been using Apache POI for quite sometime and it works great but I am not able to find a reliable answer about filter support in the library.
For reference, I mean the filter option available in data tab in excel which allows you to show all unique values of a column as a combo box in the header of the Column.
I know there is already a question about it generate excel in java where this question was asked.
And I see that Apache POI people checked in something recently for this
https://issues.apache.org/bugzilla/show_bug.cgi?id=35125
Is there anyone who has used POI new version to try filter option?
As waiting for the final release of POI with this feature may not be possible for us, can anyone point out other Excel Java API which allow this option (JExcel does not as far as I found out). I do see many websites allowing export to excel with filtering available. If there is no good API to provide it, is there any other way or post processing on excel which i can do to add this option
Sorry for the repeated question, but I could not see any other way to resolve my issue other than approaching stackoverflow community
It's already enabled in Apache POI 3.7. How? take a look...
sheet.setAutoFilter(CellRangeAddress.valueOf("A1:C200"));
I am very new to java. I am trying to fetch some data from a database and the result set is displayed in excel. I am able to inetract with database. But how should I go ahead for inserting data into excel sheet.Its simple Java program and in future I would like to generate files in other format say PDF, doc etc.
I am looking for an approach with lesser load on CPU, faster.
thanks in advance for help.
Just spit out a CSV file. It's lightweight and portable. You can grab a csv writer from Apache commons I think but spending the 10 min it would take to write one might be a good learning exercise as well.
If you want a real solution where you want different outputs (eg excel, pdf, rich text etc) then use a reporting tool. There are plenty of opensource tools like ireport which will let you create a template then write a simple java app that renders that to pdf, excel etc. Otherwise you will end up doing it by hand. It's a bit heavyweight but anything more than trival tabular output will be easier.
Apache POI is for you in this case, but you will find it a little bit overwhelmed if you just need to write/read data from an excel file.
Try jExcel instead, the API is simple and straightforward, you can also manipulate sheets within an excel workbook.
The easiest and standard way of doing this is to use POI library:
http://poi.apache.org/spreadsheet/quick-guide.html
The new xlsx format is based on Open-XML and would provide a method of generating these files without any dependency on Microsoft-office COM libraries -- the same could done for docx and pptx formats later, as well as other open-Xml formats like EPUB.
The Apache POI project looks like it might provide one possible solution. There's also an article on the MSDN interop blog that discusses this in some detail.
The key words you should google for are OLE and DDE.
Though, Java is not the best language for interface Microsoft's software.
for generating excel i think you should try simreport in jsimreport.com. in my opinion, it's quite simple to make an excel report, it uses the excel sheet to generate report so easy to config and visually
A question that seems to have quite a few options for Python, but none for Java after googling for two days. Really really could use some help all I have found so far is a recommendation to use gaeVFS to build an excel file from the xml components and then zip it all together which sounds like a slap in the face. Oh yes and if you were wondering I am questioning my use of Java rather than python but at 5,000 lines of code it would be insane to turn back now...
Other things you might find useful
Client: GWT
Server: Servlets running
on google app engine storing data
into the google data store
Excel file: mandatory, CSV isn't good
enough, no need to save the file just
to be able to "serve" it to the
client i.e. open a "Save As" box.
Have you checked out this api already: Java Excel API ?
You could also take a look at the Apache POI project. You can read and write MS Excel documents with this library.
Take a look at this post.
It's a step by step tutorial on how to generate excel files on google app engine.
Try this :
http://code.google.com/p/gwt-table-to-excel/
google app engine do not support input/output stream classes, you need to use google app engine virtual file system.