This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
create word document(.doc) using apache poi-scratchpad 3.7 jar Please help me i have to finish this job today itself.
it throws this exception
I have added code tags to your code, and you can see how much better it looks. Why are you not closing the file output stream in a finally block? Why are you calling flush(); I thought you did not need that.
Don’t know about the Exception; there are no obvious arrays in your code, unless there is an array in the insertAfter method. Are you sure it is the code you posted which is causing that Exception? Unless insertAfter requires an array, which has 23 elements or fewer, I can’t see where the Exception came from.
Thank you for your Precious and quick reply Ritchie.
Actually my requirement is to create word 2003 format document using apache poi.Please let me know what changes need to be done in the above code.Also post your suggestions for creating word 2003 document.I have to create table in the document.
velMurugan vasu wrote:Actually my requirement is to create word 2003 format document using apache poi.Please let me know what changes need to be done in the above code.Also post your suggestions for creating word 2003 document.I have to create table in the document.
Well your exception appears to be occurring in the constructor itself.
Why, I don't know - I'm no POI expert - but one possibility is that the file doesn't exist. Have you checked this?
It also seems an odd way to create a document (ie, from a class that appears to refer to a file system, rather than a file or stream). Have you tried creating it directly from the input stream itself? HWPFDocument seems to allow you to do that but, as I say, I'm no expert.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
This is the new program i tried and i got the word document with the given word.But how to
display table inside word.I know how to create table using XWPFDocument but that will not work
in MSWord 2003.so i want yours help.
I doubt that this is the correct approach to create documents. I think it's more likely that DirectoryEntry and its methods deal with content inside of a file, rather than files inside of a file system. Your first approach looks better to me. This may help: http://www.coderanch.com/how-to/java/CreateWordDocument