in reply to Spreadsheet::WriteExcel cell formatting.

If you want to display numbers, why are you using the write_string() method instead of the write_number(),method?

Your method call is missing the format specification (the 4th parameter). You should be passing the format instead of hard coding it as a string, like you're currently doing.

The 3rd example Spreadsheet::WriteExcel#Example_3 in the module documentation shows how to specify a currency format.

Replies are listed 'Best First'.
Re^2: Spreadsheet::WriteExcel cell formatting.
by anonymonk (Acolyte) on Sep 22, 2015 at 19:41 UTC

    I want it to be formatted as a string. and i am passing the formatting parameter on the actual script, the green warning triangle still appears.

      I just ran a test using your code snippet and couldn't reproduce your problem.

      Maybe the problem is due to some other portion of code in your script?

      I want it to be formatted as a string

      Then your only option is to muck around with Excel itself (either a different version, or some macro to get rid of the warning).

      From what you describe, you want the cell to be formatted as text, however Excel is detecting that there is a number in the cell formatted as text and is attaching a warning to the cell indicating this. There is nothing Perl can do about that.

      fishmonger's previous suggestion to correctly format the cell is the only way Perl can affect the warning triangle you are seeing in Excel.

        well thats a bummer, i was hoping to be able to do all of this from a perl script. Thanks for the help.

      If you tell Excel it should be treated as string, you actually forbid Excel to use it in calculations. That's why it doesn't want to work the way you want.

      Of course, you could write an Excel-alike in Perl. A CPAN search finds Spreadsheet::Perl, Tk::TableMatrix::Spreadsheet and others.