WJJK has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I am asking for your eternal wisdom. I use Perl to automatically generate reports in MS Word. This report contains a table with results, and I wish to add to each result some additional info in superscript, e.g. a particular cell contains the results "12.4" and I want to add in superscript "(3)". In other words, the cell contains the text "12.4(3)", with "(3)" in superscript. My current code is as follows:
$Table->Cell($Row, $Col)->Range->{Text} = "12.4"; $Table->Cell($Row, $Col)->Range->Font->{Superscript} = 1; $Table->Cell($Row, $Col)->Range->InsertAfter("(3)"); $Table->Cell($Row, $Col)->Range->Font->{Superscript} = 0;
What I notice is that "12.4" is written in normal font. Then it changes into superscript, "(3)" is written in superscript, and finally everything changes to normal font again. Is there anyone who knows how to get it right?

Thanks,
Walter

Replies are listed 'Best First'.
Re: superscript in MS Word
by Jenda (Abbot) on Oct 30, 2007 at 22:30 UTC

    The behaviour is quite understandable ... you are reseting the Font for the whole table cell.

    Does it really have to be Word? You might cheat by generating the report in HTML and then name it Something.doc, a reasonably recent Word (read "anything newer than MS Word 95") should read it just fine.

      HTML is an option, but the reports I am generating using Word look good to me. I only started using Perl very recently, so it took some effort to come where I am now. The only thing that is annoying me is this superscript thing. It was clear to me that my code changes the font of the whole cell, but I can't find how to turn on superscript for only part of the text in a cell.