Export to Microsoft Word Document

R

RP

I have a text file with certain plain text in it. I am also asking for
user input on my form. I want to get the text file data and the text
entered by the user to a Microsoft Word Document.

Please let me know how to write a Java code to:

1. Read text from a text file
2. Export the text to Microsoft Word Document. (Office XP).
 
L

Lew

RP said:
Please let me know how to write a Java code to:

1. Read text from a text file

2. Export the text to Microsoft Word Document. (Office XP).

If you just want to export the text to Word, and not formatting, then the text
file is already usable by MS Word. You just open the text file in Word.
 
A

Andrew Thompson

RP said:
I have a text file with certain plain text in it. I am also asking for
user input on my form. I want to get the text file data and the text
entered by the user to a Microsoft Word Document.

Why a .doc?
Please let me know how to write a Java code to:

1. Read text from a text file
2. Export the text to Microsoft Word Document. (Office XP).

Who is going to read the .doc? You(a), the user(b)?

a) If the doc is to send to you, be aware that there are a
lot 'lighter' (less bytes) wrapper formats than '.doc'.
b) If it is for the user, consider that some users will not
have Word, and might prefer plain text or a more generic
format, like HTML or RTF.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1
 
P

peder

RP skrev:
I have a text file with certain plain text in it. I am also asking for
user input on my form. I want to get the text file data and the text
entered by the user to a Microsoft Word Document.

Please let me know how to write a Java code to:

1. Read text from a text file
2. Export the text to Microsoft Word Document. (Office XP).

Not sure about the .doc, but to read text from a file you should look
into the Scanner class (java.util.Scanner). Check the API at
java.sun.com.

Good luck.
 
P

Philipp Leitner

I usually generate RTF Files if the user demands 'Word Documents'.
Realistically what the user really wants to have is a file that opens
with MS Word and has basic formatting in it. The user usually cannot
care less whether the file is actually a *doc or RTF file. RTF can be
generated on many platforms (unlike *doc), and can be opened with
other word processors if necessary (unlike *doc).

Short googling reveals that iText can for instance be used to generate
RTF with Java (http://www.devx.com/tips/Tip/31236, http://www.lowagie.com/iText/),
but there are many alternatives.

/philipp
 
L

Lew

Philipp said:
I usually generate RTF Files if the user demands 'Word Documents'.
Realistically what the user really wants to have is a file that opens
with MS Word and has basic formatting in it. The user usually cannot
care less whether the file is actually a *doc or RTF file. RTF can be
generated on many platforms (unlike *doc), and can be opened with
other word processors if necessary (unlike *doc).

Short googling reveals that iText can for instance be used to generate
RTF with Java (http://www.devx.com/tips/Tip/31236, http://www.lowagie.com/iText/),
but there are many alternatives.

iText also generates PDF, which is a good read-only format for when the
recipient shouldn't change the document.
 
C

Chris ( Val )

iText also generates PDF, which is a good read-only format for when the
recipient shouldn't change the document.

The example demonstrated via the first link does not compile.

An identifier 'myDoc' is created, but the remainder of the
program expects to use an identifier named 'document'.
 
P

Philipp Leitner

The example demonstrated via the first link does not compile.

Sorry - as I said, I only did a quick Google search ... However, last
time I used iText (granted, I was to generate PDF, not RTF) it was not
so hard to find good documentation ...

/philipp
 
R

Ramon F Herrera

I have a text file with certain plain text in it. I am also asking for
user input on my form. I want to get the text file data and the text
entered by the user to a Microsoft Word Document.

Please let me know how to write a Java code to:

1. Read text from a text file
2. Export the text to Microsoft Word Document. (Office XP).

I highly recommend the OpenOffice API. You don't even need to download
the SDK, as all OpenOffice installations already come with the Java
classes needed to remote-control OO. You could have the application
working before your eyes, doing formatting, saving, etc. or it could
be working by itself in quiet mode.

Here's is a good tutorial, if you are of the NetBeans persuasion :)

http://platform.netbeans.org/tutorials/nbm-open-office.html

NetBeans is the most integrated IDE for work on OOo projects. There's
even a plugin specific for that purpose.

-Ramon
 
W

Wayne

RP said:
I have a text file with certain plain text in it. I am also asking for
user input on my form. I want to get the text file data and the text
entered by the user to a Microsoft Word Document.

Please let me know how to write a Java code to:

1. Read text from a text file
2. Export the text to Microsoft Word Document. (Office XP).

The current document type of MS ".doc" files is actually XML,
and the format is "open" (and available). Thus you should be
able to directly create .doc files from any data you have
using standard Java XML stuff.

Without using fancy formatting, I would guess it wouldn't be
very hard to craft such an XML document containing the
desired text in the default format.

I saw last week where both the open document format and the
MS version (I forget the exact name) have both now been
rejected for standardization, and OASIS is now pushing
the W3C's "common document format" (CDF) documents.
Don't ya love format wars? As someone else wisely said,
"The great thing about standards is that you have so many
to chose from."

-Wayne
 
R

Ramon F Herrera

I saw last week where both the open document format and the
MS version (I forget the exact name) have both now been
rejected for standardization...

On one hand we have this:

"ISO Rejects Microsoft's OOXML as Standard - Microsoft has failed in
its attempt to have its Office Open XML document format fast-tracked
straight to the status of an international standard by the
International Organization for Standardization."

And OTOH:

http://www.pcworld.com/article/id,136711-c,techindustrytrends/article.html

"The OpenDocument format (ODF, ISO/IEC 26300, full name: OASIS Open
Document Format for Office Applications) is a file format for
electronic office documents, such as spreadsheets, charts,
presentations and word processing documents."

http://en.wikipedia.org/wiki/OpenDocument

"The Open Document Format has been approved as an international
standard by the International Standards Organization, a move that
supporters say will serve as a springboard for the adoption and use of
ODF around the world.

The ODF allows the retrieval of information and the exchange of
documents without regard to the application or platform in which the
document was created. The format is supported by Corel, IBM, Novell,
Opera Software, Oracle, Red Hat and Sun Microsystems. Microsoft, which
is pushing its OpenXML document format as an alternative to ODF, plans
to seek ISO approval for OpenXML as well."

http://www.eweek.com/article2/0,1759,1957321,00.asp

"The OpenDocument v1.0 specification was approved as an OASIS Standard
on 1 May 2005. It is available in PDF and in OpenOffice.org XML
formats. The OpenDocument v1.0 (Second Edition) specification was
approved as a Committee Specification on 19 July 2006. It is available
in OpenDocument and in PDF formats. OpenDocument v1.0 has been
approved as the ISO and IEC International Standard ISO/IEC
26300:2006."

http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office

....and last, but not least, let's hear it from the horse's mouth:

http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=43485

-Ramon
 
W

Wayne

Ramon said:
On one hand we have this:

"ISO Rejects Microsoft's OOXML as Standard - Microsoft has failed in
its attempt to have its Office Open XML document format fast-tracked
straight to the status of an international standard by the
International Organization for Standardization."

And OTOH:

http://www.pcworld.com/article/id,136711-c,techindustrytrends/article.html

"The OpenDocument format (ODF, ISO/IEC 26300, full name: OASIS Open
Document Format for Office Applications) is a file format for
electronic office documents, such as spreadsheets, charts,
presentations and word processing documents."

...

"... The OpenDocument v1.0 (Second Edition) specification was
approved as a Committee Specification on 19 July 2006. ...
OpenDocument v1.0 has been
approved as the ISO and IEC International Standard ISO/IEC
26300:2006."

http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office

...and last, but not least, let's hear it from the horse's mouth:

http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=43485

-Ramon

Now you made me look up my reference. From http://opendocumentfoundation.us/ :
"The OpenDocument Foundation, Inc. is a 501c(3) non profit chartered to work
in the public interest to support, promote and develop highly interoperable
solutions based on the fluid exchange and processing of portable XML/RDF
documents. ...
"For the past five years we have been hell bent on a quest for a universal
file format. ...
"Our quest ended in April of 2006, when we gave up all hope of ever getting
our ODF iX interoperability enhancements accepted by OASIS. At that point
we went back to the W3C stable of Internet Technologies, and went to work
on CDF, the "Compound Document Format". ..."

A closer reading of this website shows this group is no longer
affiliated with OASIS, so perhaps no one cares what this group thinks.

-Wayne
 
R

Ramon F Herrera

Now you made me look up my reference. Fromhttp://opendocumentfoundation.us/:
"The OpenDocument Foundation, Inc. is a 501c(3) non profit chartered to work
in the public interest to support, promote and develop highly interoperable
solutions based on the fluid exchange and processing of portable XML/RDF
documents. ...
"For the past five years we have been hell bent on a quest for a universal
file format. ...
"Our quest ended in April of 2006, when we gave up all hope of ever getting
our ODF iX interoperability enhancements accepted by OASIS. At that point
we went back to the W3C stable of Internet Technologies, and went to work
on CDF, the "Compound Document Format". ..."

A closer reading of this website shows this group is no longer
affiliated with OASIS, so perhaps no one cares what this group thinks.

-Wayne


What the hell is a person who obviously has his nose deeply thrust,
breathing Bill Gates' gaseous intestinal atmosphere doing in a Java
newsgroup?

You are spreading FUD and lies, sir.

How about making a comment about what the International Standards
Organization have to say about ODF?

-Ramon
 
W

Wayne

Ramon said:
What the hell is a person who obviously has his nose deeply thrust,
breathing Bill Gates' gaseous intestinal atmosphere doing in a Java
newsgroup?

You are spreading FUD and lies, sir.

How about making a comment about what the International Standards
Organization have to say about ODF?

-Ramon

Huh? Those are harsh words to someone who just agreed
with you! Maybe you confused "this group" to mean c.l.j.p
and not (as was intended) the opendocumentfoundation.us group?
Maybe one of us (or perhaps both of us) shouldn't post
so late at night anymore. :)

-Wayne
 
R

Ramon F Herrera

Huh? Those are harsh words to someone who just agreed
with you! Maybe you confused "this group" to mean c.l.j.p
and not (as was intended) the opendocumentfoundation.us group?
Maybe one of us (or perhaps both of us) shouldn't post
so late at night anymore. :)

-Wayne

Wayne:

For a second, I thought I was in comp.lag.java.advocacy, where such
language is more widespread. :)

After realizing it, I did remove the posting from Google, but I guess
you got anyway.

Oh well...

-RFH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top