• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Could not able to add properties to the pargraph in doc file using apache poi HWPF

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi frds i am new to the coderanch
i am using this code


the problem I am facing here is I am able to generate the doc file but the properties are not assigned to the paragraphs.
one more issue is that the doc file generated contains these paragraphs in every page and the number of pages also increasing continuously.
if any one know the solution please help me.
thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

the problem I am facing here is I am able to generate the doc file but the properties are not assigned to the paragraphs.


What do you mean by "properties" - bold, font size and such?

one more issue is that the doc file generated contains these paragraphs in every page and the number of pages also increasing continuously.


This code only creates a single page, so what do you mean by "in every page"? Under which circumstances are you getting more than one page?

Which version of POI are you using? If it's anything but 3.5, get the latest one.
 
varun narisetty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the POI 3.5 what you said is correct here properties I mean are bold italic e.t.c
here the doc file generated contains more than one page and the page numbers are increasing continuously.

thanks for your reply
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post replies once, not 5 times.

Just to make sure I understand: The file "empty.doc" contains absolutely nothing at the beginning, the file "new-hwpf-file.doc" does not exist, then you run the above code once and end up with a file "new-hwpf-file.doc" that contains multiple pages? That doesn't sound right. And what do you mean by "continuously"?
 
varun narisetty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have generated a document using above code in Java , and when ever I try to open this document , number of pages are getting added automatically with the same content that I have given to the first page and subsequently the pc is hanging , You are right that this code should generate only one page, but its not happening here , it is generating multiple pages and its halting nowhere!!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't open the document until the code has finished running. Are you saying opening the document somehow causes the code to run again?
 
varun narisetty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not opening the document before its running.
even i try to open the document in another system also I am getting the same result.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I used the program and when i compile i get

Exception in thread "main" java.lang.NullPointerException
at action.CreateWordDoc.main(CreateWordDoc.java:47)


I believe line 47 is CustomProperties cp = dsi.getCustomProperties(); i tried to debug and the object dsi is null. I did create empty.doc and gave the path correctly. I know this for sure because at first i was getting file not found exception and after i created the file and specified the path this exception went away.


I also tried commenting the entire setting custom document property part. When i did this, the program runs but nothing was getting written into new-hwpf-file.doc.

Any pointers on why this is happening? I am using poi 3.5, i also tried with poi 3.6.


Thanks,
Ashok
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashok and welcome to Javaranch! You may be best off starting a new thread with your specific question and the code you are using.
 
Ashok Sarathy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The code i am using is



when i compile i get

Exception in thread "main" java.lang.NullPointerException
at action.CreateWordDoc.main(CreateWordDoc.java:47)


I believe line 47 is CustomProperties cp = dsi.getCustomProperties(); i tried to debug and the object dsi is null. I did create empty.doc and gave the path correctly. I know this for sure because at first i was getting file not found exception and after i created the file and specified the path this exception went away.


I also tried commenting the entire setting custom document property part. When i did this, the program runs but nothing was getting written into new-hwpf-file.doc.

Any pointers on why this is happening? I am using poi 3.5, i also tried with poi 3.6.


Thanks,
Ashok
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi varun narisetty, did you got any solution for your problem?
I am facing the same !!
I there any sample sites for this(word creation using apache poi)?
Please help me, Thanks, Johns

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic