Hi,
I need to export a report I create to MS Word in a very specific format. I can export it as a PDF file which is very close to how I want it to look in MS Word, but I need to improve the look of it as much as I can, to minimize the amount of editing that it will need after having been exported. To illustrate what I'm trying to do, I enclose below a short script that creates a simple report containing some titles, a couple of tables and a footer, and then exports that report in three different formats, namely a PDF file, an MS Word document and an HTML file.
The PDF version of the report is created pretty much as I want it to appear in the MS Word version, with titles centered, different-sized fonts and the table styles ("heading separator" and "bordered") specified in the script. The MS Word version has however lost the centering of the titles, the font size settings and the table styles - and I'd like to retain all of these features if at all possible.
Also in the MS Word version, every line is actually a box of text (you can see this by opening the document in Word, highlighting everything with <Control>-A and then adding borders to the selection). This is of course how everything was exported in the first place and therefore isn't at all surprising; however I note that the HTML version doesn't consider the two titles and the footer to be boxes, but simply lines of text - and this is actually how I would like them to appear in the MS Word version.
My questions are therefore:
- Is it possible to retain (a) the centering and/or (b) the font size settings when exporting to MS Word?
- Is it possible to export simply lines of text (as opposed to text boxes) to MS Word?
- It is possible to retain the designated table style (e.g. "bordered" or "heading separator") when exporting to MS Word?
I’m guessing that some, if not all, of these are not going to be possible - but I know from past experience that there's often a way around such little problems if you just happen to know how to do it. Can anyone help me with any of the above?
Many thanks – here’s the demo script I mentioned:
myTableBox1 = table box(
string col box("Position", {"First", "Second", "Third", "Fourth", "Fifth"}),
string col box("Description", {"Water", "Sulphuric Acid", "Oxygen", "Hydrogen Sulphide", "Sodium Chloride"}),
string col box("Formula", {"H2O", "H2SO4", "O2", "H2S", "NaCl"}),
<< table style("heading separator")
);
myTableBox2 = table box(
string col box("Town", {"Aberdeen", "Cardiff", "London", "Manchester"}),
number col box("Population", [212125, 324800, 8174000, 512000]),
<< table style("bordered")
);
myTitle = text box("This is my Main Title", << justify text(center), << set font size(14), << font color({0, 0, 0.5}), << set width(200));
mySubtitle = text box("This is my Subtitle", << justify text(center), << set font size(9), << font color({0, 0, 1}), << set font style("italic"));
myBlankLine = text box(" ", << set font size(12));
myFootnote = text box("This is my footnote", << set font size(9), << justify text(center));
lub = line up box(ncol(1),
myTitle,
mySubtitle,
myBlankLine,
myTableBox1,
myBlankLine,
myTableBox2,
myBlankLine,
myFootnote
);
nw = new window("My Window", lub);
lub << save PDF("C:\Documents\My Report.pdf");
lub << save MS Word("C:\Documents\My Report.doc");
lub << save HTML("C:\Documents\My Report.html");