Now you can use Templates with Java2word!
Take a look at the wiki page: https://code.google.com/p/java2word/wiki/TemplatesWithJava2word
It is not the most advanced solution but gets the job done!
https://code.google.com/p/java2word/
Leonardo Correa
coding for fun...
I write about life in Australia, soccer, social life, Java, Ruby, Information Technology and my work experience. There is also a lot about Java2word, which is an open source project I run for fun on my free time.
Showing posts with label java2word. Show all posts
Showing posts with label java2word. Show all posts
Tuesday, 22 March 2011
Sunday, 20 February 2011
Java2word in numbers statistics
Java2word started in August 2010. Since then, I have spent many hours of my own time to implement this code. There has been a lot of collaboration from people all over the world.
Last 30 days:
At all times(7 months):
Now we have style, fluent interface, over 92% test coverage.
Unfortunately I can't fit cucumber here...
TODO:
I decide to write in one unit test that uses all elements of the API. This works like a documentation/demonstration of what can be done with java2word.
Take a look at the project page and search (ctrol + f) for "testJava2wordAllInOne"
https://code.google.com/p/java2word/
thanks everyone for helping!
Leonardo Correa
Last 30 days:
- Visits: 850
- Pageviews: 3,189
At all times(7 months):
- Visits: 3,429
- Pageviews: 15,146
Now we have style, fluent interface, over 92% test coverage.
Unfortunately I can't fit cucumber here...
TODO:
- Knock off some cyclomatic complexity
- Get to 100% test coverage
- Make font-size work
- Implement bullet points
I decide to write in one unit test that uses all elements of the API. This works like a documentation/demonstration of what can be done with java2word.
Take a look at the project page and search (ctrol + f) for "testJava2wordAllInOne"
https://code.google.com/p/java2word/
thanks everyone for helping!
Leonardo Correa
Saturday, 19 February 2011
Java2word covariant return type
When I was studying for SCJP exam, in 2007, I had to learn a lot of things that didn't make sense and I thought that I would never use.
Today, in my Java2word library, I utilized Covariant Return Type.
This basically is when you override some method, you can return any subtype of the original return type. Eg.:
The class ParagraphPieceStyle extends AbstractStyle and overrides the method create().
public abstract class AbstractStyle implements ISuperStylin {
private IElement element;
public void setElement(IElement element) {
this.element = element;
}
public IElement create() {
return this.element;
}
}
public class ParagraphPieceStyle extends AbrstractStyle{
@Override
public ParagraphPiece create() {
return (ParagraphPiece) super.create();
}
}
The original return type is "IElement" but returns "ParagraphPieceStyle".The advantage of this is the flexibility to return any subtype of the original type.
this is the code without Covariant:
ParagraphPiece myParPiece01 = (ParagraphPiece) ParagraphPiece.with("...");
This is with covariant:
ParagraphPiece myParPiece01 = ParagraphPiece.with("...");
Now I don't need to do a type cast (downcast) of the type.
https://code.google.com/p/java2word/
cheers
Leonardo Correa
Today, in my Java2word library, I utilized Covariant Return Type.
This basically is when you override some method, you can return any subtype of the original return type. Eg.:
The class ParagraphPieceStyle extends AbstractStyle and overrides the method create().
public abstract class AbstractStyle implements ISuperStylin {
private IElement element;
public void setElement(IElement element) {
this.element = element;
}
public IElement create() {
return this.element;
}
}
public class ParagraphPieceStyle extends AbrstractStyle{
@Override
public ParagraphPiece create() {
return (ParagraphPiece) super.create();
}
}
The original return type is "IElement" but returns "ParagraphPieceStyle".The advantage of this is the flexibility to return any subtype of the original type.
this is the code without Covariant:
ParagraphPiece myParPiece01 = (ParagraphPiece) ParagraphPiece.with("...");
This is with covariant:
ParagraphPiece myParPiece01 = ParagraphPiece.with("...");
Now I don't need to do a type cast (downcast) of the type.
https://code.google.com/p/java2word/
cheers
Leonardo Correa
Thursday, 22 July 2010
Java2Word Microsoft Word Document Generator from Java code without any "special" components or libraries
I had a problem in my work a few weeks ago which was how to generate one Microsoft Word Document from Java code. Reports were composite by 40 pages around and over 30 database queries to bring data. It also had cover page, table of contents, header, footer and many tables.
We tried a lot of things but they were all crap solution. We had to delivery those "word" reports so the solution was pretty bad: Generate Jasper RTF and open as an Word Document.
When you open this rtf, the result is just horrible. You can't properly edit those dodge tables generated by jasper. Other problem is when you save this document as .doc, file size increased from 5 MB to 40 MB.
So... there were I again... playing around with the problem...
I decide to create an API in Java to generate Word documents from Java code. The Document generated HAS to be compatible with Microsoft Word and can't have any manipulation - so has to be ready for the end user!
I wrote two implementations: one for Word 97 - 2003 and another for Word 2004 +.
To be honest I spent more time in W2004 because this is the current standard.
I have created the java project and hosted in Google code:
http://code.google.com/p/java2word/
The philosophy is have something in Java and really easy like:
We tried a lot of things but they were all crap solution. We had to delivery those "word" reports so the solution was pretty bad: Generate Jasper RTF and open as an Word Document.
When you open this rtf, the result is just horrible. You can't properly edit those dodge tables generated by jasper. Other problem is when you save this document as .doc, file size increased from 5 MB to 40 MB.
So... there were I again... playing around with the problem...
I decide to create an API in Java to generate Word documents from Java code. The Document generated HAS to be compatible with Microsoft Word and can't have any manipulation - so has to be ready for the end user!
I wrote two implementations: one for Word 97 - 2003 and another for Word 2004 +.
To be honest I spent more time in W2004 because this is the current standard.
I have created the java project and hosted in Google code:
http://code.google.com/p/java2word/
The philosophy is have something in Java and really easy like:
IDocument myDoc = new Document2004();
myDoc.getBody().addEle(new Heading1("Heading01"));
myDoc.getBody().addEle(new Paragraph("This is a paragraph..."));
You are Java dev and deal with this API. You Don't need to worry about the implementation!
*Project has 97% of code test coverage.
** When I say no "special" components I mean not using any MS library.
In order to use the Java2Word you will need in your classpath xstream (if you use images) and log4j (for other than JBoss server).
Please refer to dependencies section in the project page.
Subscribe to:
Posts (Atom)