Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Saving results of programs work in some (not any particular) document format

Thread view: 
jb - 24 Jun 2006 20:14 GMT
Well I'm writing a program, that has to save some results in some
(editable!) document format. Since it will mostly be tables so some
spreadsheet format would be great.

Do you have any hints concerning choice of format, any free java
classes that would make whole process easier, or have you encountered
such problems and have other advices.

I have considered using ods (open document spreadsheet), because:
1. It is open, and I can download it's reliable spec. - I really don't
want create ods file from scratch, but if it is a must...
2. OpenOffice.org is free, which is important since i write it for a
non-profit organisation - Polish scout association.
3. I could just create csv (comma separated values) and later write a
macro that will do the formatting.

What do uou think of my choice?

But I'm very open to other options.
But keep in mind that implementing/and programs for editing must be
free. Printing support is essential.
And also know that I have a ~20 day deadline so it cant be to complex
solution.

Thanks in advance!.

P.S. I know it is not very java orientated question, but I thing that
no were else I could get pointers to java classes that would come
handy.

P.S. If you really think that is a better group to post this question,
point it - I couldn't find better one.
Chris Smith - 24 Jun 2006 20:31 GMT
> I have considered using ods (open document spreadsheet), because:
> 1. It is open, and I can download it's reliable spec. - I really don't
[quoted text clipped - 3 lines]
> 3. I could just create csv (comma separated values) and later write a
> macro that will do the formatting.

I don't think you've given all your requirements yet.  Why not just
write it out in CSV?

Signature

Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation

jb - 25 Jun 2006 10:22 GMT
> I don't think you've given all your requirements yet.  Why not just
> write it out in CSV?

Well  thought to do so, but the result should look pretty - variable
font size, variable columns sizes, etc. Ideally result could be printed
straight from my program and look "official". So csv won't do. And
macros approach (creating a csv, then format it by a macro) is
problematic because I don't really want to learn new programming
language just now, and just for that.

So the next requirement is that doc look pretty.
Any hints?

Moiristo wrote:

> I'm doing something similar, I guess. I save the results in my own made
> up XML format, which I can convert to several output formats using XSLT.

Could you tell me something more?
How much time were you implementing it?
Something about your format - if it is possible of course?
Patricia Shanahan - 25 Jun 2006 13:22 GMT
>> I don't think you've given all your requirements yet.  Why not just
>> write it out in CSV?
[quoted text clipped - 17 lines]
> How much time were you implementing it?
> Something about your format - if it is possible of course?

I've found one trick for producing pretty documents automatically, from
Java program output. Do you know LaTeX? It's an old-fashioned,
non-WYSIWYG formatting system used mainly for preparing academic papers
in subjects with a lot of mathematics and the like, including computer
science. The source for the document is in ASCII, but there are ways of
specifying accented characters and formatting such as tables.

One of the nice things about it is pdflatex, a program that generates an
Adobe Acrobat document.

I've written a converter that takes table output one of my programs
leaves in an XML file and converts it to the LaTeX source for a
formatted table. In my makefile, that gets run through pdflatex,
producing a formatted document. Of course, I could have made the main
program output LaTeX directly, but I find the XML-and-converter approach
more flexible.

Patricia
Moiristo - 25 Jun 2006 14:29 GMT
> I've written a converter that takes table output one of my programs
> leaves in an XML file and converts it to the LaTeX source for a
> formatted table. In my makefile, that gets run through pdflatex,
> producing a formatted document. Of course, I could have made the main
> program output LaTeX directly, but I find the XML-and-converter approach
> more flexible.

Nice! Is it an XSL sheet? I'm very interested in seeing it, could save
me a lot of time finding out how to work with pdflatex. Is it big or can
you post it in a message?
Patricia Shanahan - 25 Jun 2006 15:55 GMT
>> I've written a converter that takes table output one of my programs
>> leaves in an XML file and converts it to the LaTeX source for a
[quoted text clipped - 6 lines]
> me a lot of time finding out how to work with pdflatex. Is it big or can
> you post it in a message?

I use a combination of Java programs and shell scripts. I don't know
whether that is the best way of doing it, I just needed a way that
worked. I'm afraid it isn't generalized at all.

Here's a sample of some Java code, generating the preamble for a LaTeX
"tabular", a table format. "titles" is a List of column headings, and my
objective was a table with equal column widths totaling "totalWidth"
inches. I don't think it will help much unless you understand LaTeX:

  private void putHeader(PrintStream out) {
    out.print("\\begin{tabular}{|");
    int cols = titles.size() + 1;
    double colWidth = totalWidth / cols;
    colWidth = Math.rint(colWidth * 100) / 100;
    for (int i = 0; i < cols; i++) {
      out.print("p{" + colWidth + " in}|");
    }
    out.println("} \\hline");
    out.print("Cut Off\t\t");
    for (Iterator it = titles.iterator(); it.hasNext();) {
      out.print(" & " + it.next() + "\t\t");
    }
    out.println("\\\\ \\hline");
  }

This is a shell script, makedoc, for taking some LaTeX fragments and
packing them with a header and trailer to produce a complete document:

#!/bin/ksh
echo '\\documentclass{article}'
echo '\\begin{document}'
cat $@
echo '\\end{document}'

These are a couple of makefile rules for producing .pdf from pieces of
LaTeX source, using makedoc.

%.pdf: %.sect.tex
    ./makedoc $*.sect.tex >$*.tex
    pdflatex $*.tex

summary.pdf: ${SHORT_SECTIONS}
    ./makedoc $^ >summary.tex
    pdflatex summary.tex

Hope some of this helps.

Patricia
Jeffrey Schwab - 26 Jun 2006 04:28 GMT
> I've found one trick for producing pretty documents automatically, from
> Java program output. Do you know LaTeX? It's an old-fashioned,
> non-WYSIWYG formatting system used mainly for preparing academic papers
> in subjects with a lot of mathematics and the like, including computer
> science.

Holy crap have we come a long way.  Once upon a time, TeX (pronounced
"tech") was /the/ way to produce fancy text, and LaTeX seemed like alien
technology.
Moiristo - 24 Jun 2006 21:08 GMT
> Well I'm writing a program, that has to save some results in some
> (editable!) document format. Since it will mostly be tables so some
> spreadsheet format would be great.

I'm doing something similar, I guess. I save the results in my own made
up XML format, which I can convert to several output formats using XSLT.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.