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

I am stumped on this problem. I have imported an excel file through means of Spreadsheet::ParseExcel. My exported plain-text file will be pipe delimited. My current excel sheet has a column with URL's with a link format to each row. When I run my script the URL field comes back as 0. I noticed that the values of the URL fields are numeric. I want to capture the actual url name not the numeric value.

Here is a bit of my code:
my $excel_obj = Spreadsheet::ParseExcel->new(); my $workbook = $excel_obj->Parse($arg{xls}); die "Workbook did not return worksheets!\n" unless ref $workbook->{Worksheet} eq 'ARRAY'; for my $worksheet ( @{$workbook->{Worksheet}} ) { my $last_col = $worksheet->{MaxCol} || 0; my $last_row = $worksheet->{MaxRow} || 0; for my $row ( 0 .. $last_row ) { for my $col ( 0,1,$last_col ) { my $cell = $worksheet->{Cells}[$row][$col]; print ref $cell ? $cell->Value : ''; print $arg{field_sep} unless $col == $last_col; } print $arg{record_sep}; # record ends } print "\n"; # worksheet ends }

Thanks!
Derek Perriero

Replies are listed 'Best First'.
Re: Spreadsheet-ParseExcel Problem Reading URL in Cell
by Limbic~Region (Chancellor) on Jan 18, 2006 at 20:02 UTC
    dperriero,
    You are using the Value() method which, per TFM, gives you the formatted value of the cell. Since you have text formatted as a number - I am not terribly suprised you are getting 0. You may want to use the Val() method instead which gives the original value.

    Cheers - L~R

      Thank-you L~R,
      I'm still having trouble with gaining the true cell values. I've tried numerous combos pertaing to the cells' function's.

      i.e.
      my $col_name = ref $cell ? $cell->{Val} : '';
      I still get the number 0.
      my $col_name = ref $cell ? $cell->{Type} : '';
      I get output of "Text|Text|Numeric"

      Any help would be great.
      Thanks!
      Derek
        I'll answer my own question and venture to say I should have RTFM more before I asked anybody. The TODO in the manual says:
        - Spreadsheet::ParseExcel : Password protected data, Formulas support, HyperLink support, Named Range support.
        So I guess no HyperLink support yet.