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

J

jb

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.
 
C

Chris Smith

jb said:
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.

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

Moiristo

jb said:
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.
 
J

jb

Chris said:
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?
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?
 
P

Patricia Shanahan

jb said:
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?


Could you tell me something more?
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
 
M

Moiristo

Patricia said:
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?
 
P

Patricia Shanahan

Moiristo said:
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?

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
 
J

Jeffrey Schwab

Patricia said:
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.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top