I am asked to generate MS Words document using Java.
The contents of the Words document have to be presented similar to the style of a tree with nodes. Except that I have to write out the ‘full title’ (i.e. a longer String of text) of all nodes and use indentation instead of dotted lines. For example:
First Level Node 1: Today is Sunday
Second Level Node 1: I am going to take care of household chores.
Third Level Node 1: sweep floors
Third Level Node 2: mow lawn
Third Level Node 3: do laundry
Second Level Node 2: I am going to go grocery shopping
Third Level Node 1: buy meat
Third Level Node 2: buy fruits
Third Level Node 3: buy soft drinks
Third Level Node 4: buy cereal
First Level Node 2: Today is Monday
Second Level Node 1: I am going to drive to work.
Second Level Node 2: I am going to ran errand.
What is the best way to generate a Word document in the style described above? Should the First Level Node be considered as a new Section or a new Paragraph?
I have some very preliminary draft of the Aspose code. It does not iterate as I expected and I am having problem with indenting the second level and the third level titles:
//Creating document for the report
Document wordDailyTasksReport = new Document();
//Making the current document empty
//Creating a new section node
Section wordDailyTasksReportSection = new Section(wordDailyTasksReport);
//Appending section to the document
//Setting properties for the section
//Creating the wordDailyTasksReportBody section for the document
Body wordDailyTasksReportBody = new Body(wordDailyTasksReport);
//For the Day of a Week
//Creating wordDailyTasksReportParagraph for the wordDailyTasksReportBody -- Title
Paragraph dayTitle = new Paragraph(wordDailyTasksReport);
//Formatting the wordDailyTasksReportParagraph
//Create a run of text in the wordDailyTasksReportParagraph.
Run titleRun = new Run(wordDailyTasksReport);
Day d_list = plan.getDays();
for (int i=0; i<d_list.length; i++)
Paragraph daysParagraph = new Paragraph(wordDailyTasksReport);
Run paragraphRun = new Run(wordDailyTasksReport);
Thanks for helping me.