Salut tout le monde,
j'ai besoin votre conseil:
j'ai cette message "can't call method "Worksheet" " ,
et j'ai installé : perl-ParseExcel et perl-WriteExcel , et toujours pas.
merci d'avance
LOTO
Salut tout le monde,
j'ai besoin votre conseil:
j'ai cette message "can't call method "Worksheet" " ,
et j'ai installé : perl-ParseExcel et perl-WriteExcel , et toujours pas.
merci d'avance
LOTO
Bonjour,
un bout de code serait le bienvenu![]()
En général quand tu as un message "can't call method blablabla ", cela signifie que perl ne trouve pas la methode pour l'objet que tu utilises. Donc soit
1/ la methode n'existe pas pour l'objet que tu es en train d'utiliser
2/ l'objet que tu est en train d'utiliser n'est pas celui que tu crois
Mais une fois encore, sans code il est difficile de t'aider![]()
# Link with module
use Spreadsheet:arseExcel;
# Use module CGI.pm
#use CGI 'remote_addr','url_param','param';
use CGI qw(:all);
# Use authorization module
use Auth 'finduser';
#$theipaddress=remote_addr();
$theipaddress=remote_addr();
@retour=Auth->finduser('IpAddress',$theipaddress);
$identification=$retour[2];
#Document PATH
$BaseDir="/Doc/DocumentWeb/";
# Global parameters for database
$exclusive=2;
$unlock=2;
$database1="";
$record="";
@searchkey="";
@searchtxt="";
@results="";
@index="";
$dateok=0; #1= user valide, 0= user no valide
# Define Action to do
$cgi_action=param('action');
if ((! defined $cgi_action) or ($cgi_action eq ""))
{
$cgi_action="Start";
}
else
{
$cgi_info1=param('info1');
$cgi_info2=param('info2');
# cgi_action = Page, cgi_info1 = Onglet à charger, cgi_info2=""
# cgi_action = Document,cgi_info1 = Onglet à charger, cgi_info2 = Préparation du document à charger
# cgi_action = Load,cgi_info1 = Onglet à charger, cgi_info2 = Document à charger (dans fenêtre popup)
}
# Excel file location
$FileExcel=$BaseDir."IndexWeb.xls";
$UserRight=$BaseDir."utilisateur/".$identification."/".$cgi_info1.".dat";
# Perl Script Name
$ScriptPath="/MainIndex.pl";
# Dedicated Sheet
$SheetParam="PARAMETRE";
$SheetHeader="HautPage";
my $TheBook = Spreadsheet:arseExcel::Workbook->Parse($FileExcel);
## Test si l'utilisateur est valide
if (( defined $identification) and ($identification ne ""))
{
if ( $cgi_action eq "Start" )
{
ChargeParametre();
ChargeHeader();
WriteTitle();
WriteHeader();
WriteFirstPage();
WriteFooter();
}
if ( $cgi_action eq "Page" )
{
ChargeParametre();
ChargeHeader();
ChargeSheet($cgi_info1);
if ( -e $UserRight )
{
WriteTitle();
WriteHeader();
if ( $Sheet[0][2] eq "0" ) { WriteSheet(); }
if ( $Sheet[0][2] eq "1" ) { WriteSheetMenu(); }
WriteFooter();
}
else
{
WriteNoaccess();
}
}
if ( $cgi_action eq "Document" )
{
ChargeParametre();
ChargeHeader();
ChargeSheet($cgi_info1);
if ( -e $UserRight )
{
LoadFichier();
WriteTitle();
WriteHeader();
if ( $Sheet[0][2] eq "0" ) { WriteSheet(); }
if ( $Sheet[0][2] eq "1" ) { WriteSheetMenu(); }
WriteFooter();
}
else
{
WriteNoaccess();
}
}
if (( $cgi_action ne "Start" ) && ( $cgi_action ne "Page" ) && ( $cgi_action ne "Document" ))
{
WriteNoDemande();
}
}
else
{
#ChargeParametre();
ChargeHeader();
WriteNoaccess();
}
#---------------------------------------
# Function
#---------------------------------------
sub ChargeParametre()
{
# Procedure pour charger la feuille "PARAMETRE" du fichier excel
# dans la variable $Param[lig][col]
# (0,0) = Nombre de ligne
# (0,1) = Nombre de colonne
$TheSheet=$TheBook->Worksheet($SheetParam);
undef @Param;
my $TheCellVal="0";
my $TheRow=0;
my $TheCol=0;
while ( $TheCellVal ne "" )
{
$TheCell=$TheSheet->Cell($TheRow+1,$TheCol);
$TheCellVal=$TheCell->{Val};
if ( $TheCellVal ne "" )
{
$Param[$TheRow+1][$TheCol+1]=$TheCellVal;
$TheCell=$TheSheet->Cell($TheRow+1,$TheCol + 1);
$Param[$TheRow+1][$TheCol + 2]=$TheCell->{Val};
$TheCell=$TheSheet->Cell($TheRow+1,$TheCol + 2);
$Param[$TheRow+1][$TheCol + 3]=$TheCell->{Val};
}
$TheRow = $TheRow + 1;
}
$Param[0][0]=$#Param;
$Param[0][1]=3;
}
sub ChargeHeader()
{
# Procedure pour charger la feuille "HautPage" du fichier excel
# dans la variable $Header[lig][col]
# (0,0) = Nombre de ligne
# (0,1) = Nombre de colonne
$TheSheet=$TheBook->Worksheet($SheetHeader);
undef @Header;
my $TheCellVal="0";
my $TheRow=0;
my $TheCol=0;
while ( $TheCellVal ne "" )
{
$TheCell=$TheSheet->Cell($TheRow,$TheCol);
$TheCellVal=$TheCell->{Val};
if ( $TheCellVal ne "" )
{
$Header[$TheRow+1][$TheCol+1]=$TheCellVal;
$TheCell=$TheSheet->Cell($TheRow,$TheCol + 1);
$Header[$TheRow+1][$TheCol + 2]=$TheCell->{Val};
$TheCell=$TheSheet->Cell($TheRow,$TheCol + 2);
$Header[$TheRow+1][$TheCol + 3]=$TheCell->{Val};
}
$TheRow = $TheRow + 1;
}
$Header[0][0]=$#Header;
$Header[0][1]=3;
}
sub ChargeSheet($)
{
# Procedure pour charger la feuille, transmises en parametre, du fichier excel
# dans la variable $Sheet[lig][col]
# (0,0) = Nombre de ligne
# (0,1) = Nombre de colonne
# (0,2) = 0 si tableau simple ou 1 si tableau avec menu famille
$SheetName=$_[0];
$TheSheet=$TheBook->Worksheet($SheetName);
undef @Sheet;
# find number of column
my $TheCellVal="0";
my $TheRow=1;
my $TheCol=1;
while ( $TheCellVal ne "" )
{
$TheCell=$TheSheet->Cell($TheRow,$TheCol);
$TheCellVal=$TheCell->{Val};
$TheCol = $TheCol + 1;
}
$Sheet[0][1]=$TheCol - 1;
my $TheCellVal="0";
my $TheRow=2;
my $TheCol=0;
while ( $TheCellVal ne "" )
{
$TheCell=$TheSheet->Cell($TheRow,$TheCol+1);
$TheCellVal=$TheCell->{Val};
if ( $TheCellVal ne "" )
{
$Sheet[$TheRow-1][$TheCol+2]=$TheCellVal;
$TheCell=$TheSheet->Cell($TheRow,$TheCol);
$Sheet[$TheRow-1][$TheCol+1]=$TheCell->{Val};
for $CurCol ( 2 .. $Sheet[0][1] )
{
$TheCell=$TheSheet->Cell($TheRow,$CurCol);
$Sheet[$TheRow-1][$CurCol+1]=$TheCell->{Val};
}
}
$TheRow = $TheRow + 1;
}
$Sheet[0][0]=$#Sheet;
$Sheet[0][2]=0;
for $CurRow ( 3 .. $Sheet[0][0] )
{
$TheCell=$TheSheet->Cell($CurRow,0);
if ( $TheCell->{Val} ne "" ) { $Sheet[0][2]=1; }
}
}
sub WriteTitle()
{
# Procedure pour transmettre le code HTML de l'entete (correspondant au contenu de la variable Header)
print("Content-Type: text/html\n\n");
print("<html>\n");
print "<head>\n";
print "<title>$Header[1][2]</title>\n";
print "</head>\n";
print("<script language=javascript>\n");
print("function WriteAction(val1,val2,val3)\n");
print("{\n");
print("document.info.action.value=val1\n");
print("document.info.info1.value=val2\n");
print("document.info.info2.value=val3\n");
print("document.info.submit()\n");
print("}\n");
print("</script>\n");
print("<body lang=FR link=blue vlink=purple >\n");
}
Avec les balises 'code' c'est plus sympa aussi!!
sinon au moment ou tu crée ton workbook. tu devrais tester si l'objet que tu recupères est bien un Spreadsheet:arseExcel::Workbook comme ceci
ça permettra de savoir si ton problème vient déjà de l'objet $TheBook, cela ne m'etonnerai pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 my $TheBook = Spreadsheet::ParseExcel::Workbook->Parse($FileExcel); if($TheBook->isa("Spreadsheet::ParseExcel::Workbook")) { print "TheBook est bien un Spreadsheet:arseExcel::Workbook\n"; } else { print "TheBook n'est pas un Spreadsheet:arseExcel::Workbook\n"; }![]()
Partager