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

Hi monks, I understand you can use the $worksheet -> Range("C2") -> {ColumnWidth} = 3; but this changes the entire column width not just one cell. Is it possible to change a single cell width rather than a column width? Edit: Sorry about not being clear and thankyou for your time and helping me out. what I am trying to achieve is that the first cell of the column should be the header it should be twice the size of cell below it.

<A1> cell width --->20

<A2> cell width --->10

<B2> cell width --->10

Is it even possible?

Replies are listed 'Best First'.
Re: Possible to change a single cell width of an excel file
by kcott (Archbishop) on May 31, 2012 at 18:31 UTC

    What you're describing sounds like normal behaviour for a spreadsheet. Furthermore, I'd expect a change to a {ColumnWidth} value to change the column width. Perhaps you could explain how you would achieve what you want to do manually; for instance, what menu selections would provide this functionality.

    Also, please advise what module you're using.

    -- Ken

Re: Possible to change a single cell width of an excel file
by poj (Abbot) on May 31, 2012 at 20:55 UTC
    You can merge cells A1 and B1 into one
    my $format_header = $workbook->add_format( valign=>'vcenter', align=>'center' ); $worksheet->merge_range('A1:B1','Header Text',$format_header);
    poj
Re: Possible to change a single cell width of an excel file
by ww (Archbishop) on May 31, 2012 at 20:19 UTC
    How would that work; the changed cell would have wider or narrower cells above and/or below?

    Like this?

    |    |      |    |
    |    /      \    \
    |   |        |    |
    |   |       /    /
    |   |      |    |

    Thimk! Note1

    Note1 For extra points, is this a Mad MAGAZINE reference or just a %hash?

    Update: The response above was posted prior to ballbreaker's unacknowledged revision of the OP providing a more precise, if still fatuous, spec.

      |     |

      |  |  |

      |  |  |

      the manual way of doing it is Use two columns and then for the ones you need to be wider, select them and merge them. (Format-> Cells-> Alignment-> check the "merge cells" box) They you essentially have wide cells for the ones you merged and then two narrower ones for the ones you didn't merge.