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

I need to print "67%" right justified. If I leave off the '%' the default justification for a numbe is 'right-justified'....the default for test is 'left' and that's what I'm getting. I can't use 'write_number' because with the '%' it's not a number any more.
  • Comment on right justify strings in EXCEL::WRITE::XLSX

Replies are listed 'Best First'.
Re: right justify strings in EXCEL::WRITE::XLSX
by Corion (Patriarch) on Jul 16, 2014 at 17:14 UTC

    The module name is Excel::Writer::XLSX I presume.

    You will have to use a format for the cell.

    Either write the string as a string and format the cell to right-align, or write the number 0.67 and format the cell as percentage.

    Both approaches are what one would do within the Excel application too.

      found it! $format->set_align('right') thanks again

        The percentage format is documented in the documentation for set_num_format(). I found this by looking in the "Cell Formats" section and seeing set_num_format there for numeric formats.

        As the formats are readable as well as writable, maybe you could have created an Excel file and read the format given to a cell that shows the value like you want it?