title: How to read data from xlsx in perl
body: <p>Need a few good people help me with reading excel file with extension "xlsx" my script works for "xls" but not "xlsx", here is the code I get error: <code>Can't call method "worksheet" on an undefined value</code> if the file is "xlsx" here is the code I do have:</p>
  
  <pre><code>#!/usr/bin/perl -w
  
  use warnings;
  use strict;
  use Spreadsheet::ParseExcel;
  use Spreadsheet::XLSX;
  use Date::Format;
  
  my $filename = "../test.xlsx";
  #Parse excel file
  my $parser = Spreadsheet::ParseExcel-&gt;new();
  my $workbook = $parser-&gt;parse("$filename");
  
  #Get cell value from excel sheet1 row 1 column 2
  my $worksheet = $workbook-&gt;worksheet('Sheet1');
  my $cell = $worksheet-&gt;get_cell(0,1);
  
  # Print the cell value when not blank
  if ( defined $cell and $cell-&gt;value() ne "") {
      my $value = $cell-&gt;value();
      print "cell value is $value \n";
  }
  </code></pre>