#!/Users/kilian/perl5/perlbrew/perls/perl-5.24.1/bin/perl
use strict;
-use Text::Iconv;
+#use Text::Iconv;
use Spreadsheet::XLSX;
use Data::Dumper;
#my $converter = Text::Iconv -> new ("utf-8", "windows-1251");
-my $xlsxfile = "/Volumes/mirror/Porta Nova 2019_xx.xlsx";
+my $xlsxfile = "D:/DKS/Projekte/POT/PortaNovaData.xlsx";
my $excel = Spreadsheet::XLSX -> new ($xlsxfile);
-my $points = ();
+my $allrows = ();
my $cols = ();
my $startrow = 0;
+
foreach my $sheet (@{$excel -> {Worksheet}}) {
- if ($sheet->{Name} eq "periode0607"){
- printf("Sheet: %s\n", $sheet->{Name});
+ if ($sheet->{Name} eq "Tabelle1"){
+ # printf("Sheet: %s\n", $sheet->{Name});
$sheet -> {MaxRow} ||= $sheet -> {MinRow};
foreach my $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) {
$sheet -> {MaxCol} ||= $sheet -> {MinCol};
+ my $rowdefcell = $sheet -> {Cells} [$row] [0] ;
+ my $rowdef = $rowdefcell->{Val};
+ if (!exists($allrows->{$rowdef})){
+ $allrows->{$rowdef} = ();
+ }
foreach my $col ($sheet -> {MinCol} .. $sheet -> {MaxCol}) {
my $cell = $sheet -> {Cells} [$row] [$col];
-
+
+ my $coldefcell = $sheet -> {Cells} [0] [$col];
+ my $coldefcell2 = $sheet -> {Cells} [1] [$col];
+ my $coldef = $coldefcell -> {Val};
+ my $coldef2 = $coldefcell2 -> {Val};
if ($cell) {
- printf("( %s , %s ) => %s\n", $row, $col, $cell -> {Val});
+ if ($coldef ne ""){
+ if ($coldef2 ne ""){
+ print $cell->{Val}."\n";
+ $allrows->{$rowdef}->{$coldef}->{$coldef2} = substr($cell -> {Val},0,8);
+ }
+ }
+ #print XLSX "RX:".$rowdef.";CX1:".$coldef.";CX2:".$coldef2.";R:$row;C:$col;V:".$cell -> {Val}."\n";
+ # print "RX:".$rowdef.";CX1:".$coldef.";CX2:".$coldef2.";R:$row;C:$col;V:".$cell -> {Val}."\n";
+
+ #printf("( %s , %s ) => %s\n", $row, $col, $cell -> {Val});
# if ($cell -> {Val} eq "Nom"){
# $cols->{$col} = "name";
# $startrow = $row +1;
}
}
}
-
-foreach my $k (%{$points}){
- if (keys(%{$points->{$k}}) > 1){
- print Dumper($points->{$k});
+open(XLSX,">D:/DKS/Projekte/POT/Porta Nova 2019.xlsx.txt");
+foreach my $id (keys(%{$allrows})){
+
+ foreach my $dd (keys(%{$allrows->{$id}})){
+ print XLSX "INSERT INTO portanova.staffworkplan (id_staff,daydate,timestart1,timeend1,timestart2,timeend2) VALUES ((select id from portanova.staff where staffnumber='".$id."'),date('".$dd."'),'".$allrows->{$id}->{$dd}->{martin}."','".$allrows->{$id}->{$dd}->{matin}."','".$allrows->{$id}->{$dd}->{'apres midi'}."','".$allrows->{$id}->{$dd}->{apresmidi}."');\n";
}
-}
+
+}
+close(XLSX);
+#print Dumper($allrows);
+# foreach my $k (%{$points}){
+# if (keys(%{$points->{$k}}) > 1){
+# print Dumper($points->{$k});
+# }
+# }
#print Dumper($points);