Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7557691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:11:55+00:00 2026-05-30T12:11:55+00:00

I am working with the Spreadsheet::ParseExcel module. I want to create a hash of

  • 0

I am working with the Spreadsheet::ParseExcel module. I want to create a hash of hash with the Excel data:

{
    'P343453' => {
        'Date'   => 03022011,
        'Method' => 'No',
        'Time'   => 1440,
    },
    'P343763' => {
        'Date'   => 03022011,
        'Method' => 'YES',
        'Time'   => '1745',
    }
}

What I have now is something like this:

{
    'P343453' => [
        '03022011',
        'No',
        '1440',
    ],
    'P343763' => [
        '03022011',
        'YES',
        '1745',
    ],
}

Here is my code:

my @worksheets = $workbook->worksheets();
warn "More than 1 worksheet found\n" if @worksheets > 1;

# Only work with first page.
my $worksheet = $worksheets[0];

my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
my @required_col = (1 .. $col_max);
my @value;

##to get the headers of the excel file;
for my $row ( 0 .. 0 ) {
    @value = map {
        my $cell = $worksheet->get_cell($row, $_);
        $cell ? $cell->value() : '';
    } @required_col;
}

# Skip header row
my $sample_details = {};
for my $row (1  .. $row_max ) {
    my @data = map {
        my $cell = $worksheet->get_cell($row, $_);
        $cell ? $cell->value() : '';
    } @required_col;
    $sample_details->{$worksheet->get_cell($row,0)->value()} = \@data
        if defined $worksheet->get_cell($row, 0)->value();
}

How should I modify the code to assign the keys to the hashrefs of the hash from the array @value?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:11:57+00:00Added an answer on May 30, 2026 at 12:11 pm
    # Skip header row
    my $sample_details = {};
    for my $row (1  .. $row_max ) {
      my  @data = map {
            my $cell = $worksheet->get_cell($row, $_);
            $cell ? $cell->value() : '';
        } @required_col;
    
      foreach my $col (@values) {
        $sample_details->{$worksheet->get_cell($row,0)->value()}{$col} = shift @data  if defined $worksheet->get_cell($row, 0)->value();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a vb.net application which imports from an Excel spreadsheet. If rdr.HasRows
I am trying to start working with Excel documents through the OpenXML SDK Spreadsheet
I am working on a Excel Spreadsheet that when a dropdown box value is
I've been working intermittently on an Excel spreadsheet for a customer that does some
I have an Excel spreadsheet with a table of data in it. The columns
I am working for a client who gets data in Excel spreadsheets but wants
I'm working on some code that generates an Excel spreadsheet server-side and then downloads
I am working with 2 sheets in a single spreadsheet and I want to
I'm grabbing data from a published google spreadsheet, and all I want is the
I am working with some spreadsheet data and I have a set of cell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.