leonardoanalista / java2word Goto Github PK
View Code? Open in Web Editor NEWJava2word is a Library to generate MS Word Documents from Java code without any special components.
License: MIT License
Java2word is a Library to generate MS Word Documents from Java code without any special components.
License: MIT License
This task needs a volunteer to set up travisci, codecov and badges on readme.
Had to fire this out on my own on making the library work without using servlet , making this work on a standard jframe netbeans application.
Here is what I used, I would like to see this on the main page to help others or atleast make a note of it somewhere so it could be of help to others.
//Create the word document
IDocument myDoc = new Document2004();
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File(".CorrectiveActionForm.doc"));
chooser.setDialogTitle("Save Doc to Where.");
chooser.setFileFilter(new FileNameExtensionFilter("Word Document (.doc)", "doc"));
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setAcceptAllFileFilterUsed(false);
String path = null;
if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION)
{
System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
}
else
{
System.out.println("No Selection ");
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
JOptionPane.showMessageDialog(this, "File Save Canceled.");
return;
}
if(!chooser.getSelectedFile().toString().isEmpty())
{
if(!chooser.getSelectedFile().toString().endsWith(".doc"))
{
path = chooser.getSelectedFile().toString() + ".doc";
}
else
{
path = chooser.getSelectedFile().toString();
}
}
else
{
System.out.println("No Selection made");
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
JOptionPane.showMessageDialog(this, "File Save Canceled.");
return;
}
PrintWriter writer = null;
try {
writer = new PrintWriter(path);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
SimpleDateFormat format1 = new SimpleDateFormat("MM-dd-yyyy");
String dateOneFrom = format1.format(new Date());
// sets up creating the document
myDoc.encoding(Encoding.UTF_8); //or ISO8859-1. Default is UTF-8cvbcv
myDoc.getHeader().addEle(Paragraph.withPieces(ParagraphPiece.with("Corrective Action Form ").withStyle().bold().create()));
addTitlePage(myDoc);
addContent(myDoc);
String myWord = myDoc.getContent();
writer.println(myWord);
writer.close();
This application seems to be no longer supported on new MSWORD versions and Windows 10
Hi
two feature i will add
1-Android Support
2-XHTML to DOCX
I'm trying to get java2word to create .doc files compatible with WPS Office. As it is I have to tweak TestUtils.createLocalDocument() to get the api to write any kind of file but the os doesn't even recognize the file I create. And further it's my understanding that a .doc file is binary whereas myDoc.getContent() is all xml. How do I create a .doc file I can pull up in WPS Office?
Hi,
Is it possible to change the paper size by an A5?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.