in reply to Re^2: Read excel column and compare with array
in thread Read excel column and compare with array

Hello again snehit.ar,

Well you can iterate over the array of arrays and simply choose to keep or print the second value of the array (I am not going to create the foreach loop for you). A minimum amount of effort is required, read more here perldsc/ARRAYS OF ARRAYS. Regarding the column straight data read my update.

Minor note, my username on the forum is thanos1983, BR stands for (Best Regards) :)

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^4: Read excel column and compare with array
by snehit.ar (Beadle) on Jul 17, 2017 at 10:34 UTC
    Hi thanos1983, I am sorry for your name. I have tired this ...
    #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Spreadsheet::Read; use Spreadsheet::XLSX; use Text::Iconv; my $converter = Text::Iconv -> new ("utf-8", "windows-1251"); my $excel = Spreadsheet::XLSX -> new ('C:/SLB/Dashboard/DCSS_Applicati +ons.xlsx', $converter); my @DCSS_ss; foreach my $sheet (@{$excel -> {Worksheet}}) { printf("Sheet: %s\n", $sheet->{Name}); $sheet -> {MaxRow} ||= $sheet -> {MinRow}; foreach my $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) { $sheet -> {MaxCol} ||= $sheet -> {MinCol}; my $cell = $sheet -> {Cells} [$row] [2]; s/^\s+|\s+$//g for $cell->{Val}; if ($cell) { push @DCSS_ss, { SSRID =>$cell -> {Val} }; } } } print Dumper \@DCSS_ss;
    TY

      Hello snehit.ar,

      Are you getting an error? Is it not working? What is the problem? (I have not run your updated code).

      Update: I just found that you are copying pasting the example given from the module Spreadsheet::XLSX. You can not mix modules and expect them to work. The methods do not apply on both modes. Decide which module you want to use and create your solution.

      Hint: read again module Spreadsheet::Read/sheets and find the line my $sheets = $book->sheets; I think this is what you are looking for.

      BR, Thanos1983.

      Seeking for Perl wisdom...on the process of learning...not there...yet!
        Yes @Thanos1983 -You are wight i am using same code ... As u suggested i will explore on "Spreadsheet::Read/sheets"...