diff --git a/COPYRIGHT b/COPYRIGHT
index 78b9bee6d18..c0d8389369c 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -19,9 +19,9 @@ FPDF_TPL 1.2 Apache Software License 2.0 Yes
GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package)
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
odtPHP 1.0.1 GPL-2+ b Yes Library to build/edit ODT files
-PHPExcel 1.7.6 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
+PHPExcel 1.7.8 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
-TCPDF 6.0.021 LGPL-3+ Yes PDF generation
+TCPDF 6.0.093 LGPL-3+ Yes PDF generation
JS libraries:
jQuery 1.8.2 MIT License Yes JS library
diff --git a/ChangeLog b/ChangeLog
index 864f0930fe2..977ac4123ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -49,6 +49,7 @@ For users:
- New: [ task #1204 ] add a External reference to contract
- New: [ task #1218 ] Can drag and drop an event from calendar to change its day.
- New: Optimize size of image static resources.
+- Upgrade phpexcel lib to 1.7.8
- Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action
- Fix: [ bug #1470, #1472, #1473] User trigger problem
- Fix: [ bug #1489, #1491 ] Intervention trigger problem
@@ -251,6 +252,8 @@ Fix: Missing include files.lib.php in some pages that use dol_delete_recursive
Fix: [ bug #1558 ] Product/service edit page title shows new Ref instead of old ref.
Fix: [ bug #1553 ] Saving User displays setup removes menu.
Fix: [ bug #1544 ] Can remove date from invoice
+Fix: list event view lost type event filter
+Fix: Add code save on create event
***** ChangeLog for 3.5.4 compared to 3.5.3 *****
Fix: Hide title of event when agenda module disabled.
diff --git a/build/debian/README.howto b/build/debian/README.howto
index fea942a573f..5c0f9d7d0a4 100644
--- a/build/debian/README.howto
+++ b/build/debian/README.howto
@@ -155,20 +155,16 @@ from origin/upstream and origin/pristine.
> debian/get-orig-source.sh
If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0" to solve this.
-* Edit tgz file to remove
-- includes/sRGB.icc
-And rename file into
-tcpdf_x.y.z+dfsg.tar.xz
-(x.y.z = version, w start from 1 and is increased for each new import)
+* Some files are removed from archive by the get-orig-source.sh
* Staying into git root directory, run
-> git-import-orig -vv ../tcpdf_x.y.z+dfsg.tar.xz
+> git-import-orig -vv ../tcpdf_x.y.z+dfsg.orig.tar.xz
Note: If there was errors solved manually, you may need to make a git commit
* Add an entry into debian/changelog
-> dch -v x.y.z+dsfg-1 "My comment" will add entry.
-For example: dch -v x.y.z+dsfg-1 "New upstream release." for a new version
+> dch -v x.y.z+dfsg-1 "My comment" will add entry.
+For example: dch -v x.y.z+dfsg-1 "New upstream release." for a new version
Then modify changelog to replace "version" or "unstable" with "UNRELEASED".
Warning: Date must have format reported by "date -R"
@@ -238,17 +234,18 @@ from origin/upstream and origin/pristine.
If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0" to solve this.
* Edit tgz file to remove
-- ckeditor
-- phpexcel
-- tcpdf
+- htdocs/includes/ckeditor
+- htdocs/includes/jquery/plugins/datatables/extras/TableTools/swf
+- htdocs/includes/phpexcel
+- htdocs/includes/tcpdf
And rename file into
-dolibarr-x.y.z+dsfgw.tgz
-(x.y.z = version, w start from 1 and is increased for each new import)
+dolibarr-x.y.z+dfsgw.tgz
+(x.y.z = version, w start from 1 and is increased for each new git-import-orig already done)
* Staying into git root directory, run
-> git-import-orig -vv ../dolibarr-x.y.z+dsfgw.tgz
+> git-import-orig -vv ../dolibarr-x.y.z+dfsgw.tgz
and enter version when requested with format
-x.y.z+dsfgw
+x.y.z+dfsgw
(x.y.z = version, w start from 1 and is increased for each new import)
Note: If there was errors solved manually after get-orig-sources.sh, you may need to make a git commit
diff --git a/build/debian/get-orig-source.sh b/build/debian/get-orig-source.sh
index 57f87ab1999..821a639a470 100755
--- a/build/debian/get-orig-source.sh
+++ b/build/debian/get-orig-source.sh
@@ -1,23 +1,46 @@
#!/bin/sh
-# Scan for new official sources and download file
-# run with debian/get-orig-source.sh [x.y.z]
tmpdir=$(mktemp -d)
-echo "tmpdir = $tmpdir"
+
+# Download source file
if [ -n "$1" ]; then
uscan_opts="--download-version=$1"
fi
-uscan --noconf --force-download --no-symlink --verbose --destdir=$tmpdir $uscan_opts
+#uscan --noconf --force-download --no-symlink --destdir=$tmpdir $uscan_opts
cd $tmpdir
-tgzfile=$(echo *.tgz)
-version=$(echo "$tgzfile" | perl -pi -e 's/^dolibarr-//; s/\.tgz$//; s/_/./g; s/\+nmu1//; ')
+# Other method to download (comment uscan if you use this)
+wget http://sourceforge.net/projects/tcpdf/files/tcpdf_6_0_093.zip
+
+# Rename file to add +dfsg
+zipfile=$(echo *.zip)
+version=$(echo "$zipfile" | perl -pi -e 's/^tcpdf_//; s/\.zip$//; s/_/./g; s/$/+dfsg/;')
+
+# Extract the zip file
+unzip -q $zipfile
+srcdir=$(find . -maxdepth 1 -mindepth 1 -type d | sed -e 's/\.\///')
+
+if [ ! -d "$srcdir" ]; then
+ echo "ERROR: Failed to identify the extracted directory in $tmpdir (got $srcdir)" >&2
+ rm -rf $tmpdir
+ exit 1
+fi
+
+# Cleanup unwanted files
+rm -rf $srcdir/fonts/free*
+
+# Repack as tar.xz
+tar Jcf tcpdf_${version}.orig.tar.xz $srcdir
cd - >/dev/null
-mv $tmpdir/dolibarr-${version}.tgz ../
-echo "File ../dolibarr-${version}.tgz is ready for git-import"
+if [ -e ../tcpdf_${version}.orig.tar.xz ]; then
+ echo "Not overwriting ../tcpdf_${version}.orig.tar.xz";
+else
+ echo "Created ../tcpdf_${version}.orig.tar.xz"
+ mv $tmpdir/tcpdf_${version}.orig.tar.xz ../
+fi
rm -rf $tmpdir
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index f9c4a96dcaa..f7de102d96d 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -74,7 +74,7 @@ class Categorie extends CommonObject
function fetch($id,$label='')
{
global $conf;
-
+
// Check parameters
if (empty($id) && empty($label)) return -1;
@@ -1151,11 +1151,11 @@ class Categorie extends CommonObject
$cats = array();
$typeid=-1; $table='';;
- if ($type == '0' || $type == 'product') { $typeid=0; $table='product'; $type='product'; }
+ if ($type == '0' || $type == 'product') { $typeid=0; $table='product'; $type='product'; }
else if ($type == '1' || $type == 'supplier') { $typeid=1; $table='societe'; $type='fournisseur'; }
else if ($type == '2' || $type == 'customer') { $typeid=2; $table='societe'; $type='societe'; }
else if ($type == '3' || $type == 'member') { $typeid=3; $table='member'; $type='member'; }
- else if ($type == '4' || $type == 'contact') { $typeid=4; $table='socpeople'; $type='contact'; }
+ else if ($type == '4' || $type == 'contact') { $typeid=4; $table='socpeople'; $type='contact'; }
$sql = "SELECT ct.fk_categorie, c.label";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct, ".MAIN_DB_PREFIX."categorie as c";
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 18bef50369d..7b9705c9429 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -140,6 +140,7 @@ class ActionComm extends CommonObject
if ($result > 0)
{
$this->type_id=$cactioncomm->id;
+ $this->code=$cactioncomm->code;
}
else if ($result == 0)
{
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index 6a11985aa6a..4015b202d62 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -393,17 +393,17 @@ if ($action == 'mupdate')
$object->fetch($id);
$shour = dol_print_date($object->datep,"%H");
$smin = dol_print_date($object->datep, "%M");
-
+
$newdate=GETPOST('newdate','alpha');
if (empty($newdate) || strpos($newdate,'dayevent_') != 0 )
{
- header("Location: ".$backtopage);
+ header("Location: ".$backtopage);
exit;
}
$datep=dol_mktime($shour, $smin, 0, substr($newdate,13,2), substr($newdate,15,2), substr($newdate,9,4));
if ($datep!=$object->datep)
- {
+ {
if (!empty($object->datef))
{
$object->datef+=$datep-$object->datep;
@@ -414,19 +414,21 @@ if ($action == 'mupdate')
{
setEventMessage($object->error,'errors');
setEventMessage($object->errors,'errors');
- }
+ }
}
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
- else
+ else
{
$action='';
}
-
+
}
+
+
/*
* View
*/
@@ -514,7 +516,7 @@ if ($action == 'create')
print '
global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").' ';
// Full day
- print ''.$langs->trans("EventOnFullDay").' ';
+ print ''.$langs->trans("EventOnFullDay").' ';
// Date start
$datep=$object->datep;
@@ -935,7 +937,7 @@ if ($id > 0)
else print dol_print_date($object->datep,'day');
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
print '';
- print ''."\n";
+ print ' '."\n";
print ''."\n";
+ print ''."\n";
print ' ';
print '';
@@ -982,7 +993,7 @@ if ($id > 0)
print ''.$langs->trans("Location").' '.$object->location.' ';
// Assigned to
- print ''.$langs->trans("ActionAffectedTo").' ';
+ print ' '.$langs->trans("ActionAffectedTo").' ';
if ($object->usertodo->id > 0) print $object->usertodo->getNomUrl(1);
print ' ';
diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php
index e2391e08d89..a9f5438f1b8 100644
--- a/htdocs/comm/action/listactions.php
+++ b/htdocs/comm/action/listactions.php
@@ -63,15 +63,15 @@ $limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortorder)
{
- $sortorder="ASC";
- if ($status == 'todo') $sortorder="ASC";
- if ($status == 'done') $sortorder="DESC";
+ $sortorder="DESC";
+ if ($status == 'todo') $sortorder="DESC";
+ //if ($status == 'done') $sortorder="DESC";
}
if (! $sortfield)
{
- $sortfield="a.percent";
+ $sortfield="a.datep";
if ($status == 'todo') $sortfield="a.datep";
- if ($status == 'done') $sortfield="a.datep2";
+ //if ($status == 'done') $sortfield="a.datep2";
}
// Security check
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 70194a5e21e..a1fde80a842 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -399,7 +399,8 @@ if ($resql)
$event->datep=$db->jdate($obj->datep); // datep and datef are GMT date
$event->datef=$db->jdate($obj->datep2);
$event->type_code=$obj->code;
- $event->libelle=$obj->label;
+ $event->libelle=$obj->label; // deprecated
+ $event->label=$obj->label;
$event->percentage=$obj->percent;
$event->author->id=$obj->fk_user_author; // user id of creator
$event->usertodo->id=$obj->fk_user_action; // user id of owner
@@ -579,7 +580,6 @@ foreach ($eventarray as $daykey => $notused)
}*/
if ($filtert > 0)
{
- var_dump($filtert);
$tmpuser = new User($db);
$tmpuser->fetch($filtert);
$usernames[] = $tmpuser;
@@ -645,8 +645,33 @@ echo "\n";
print '';
@@ -760,23 +785,33 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$color = ''; //init
if (empty($event->fulldayevent))
{
- $a = dol_mktime((int) $h,0,0,$month,$day,$year);
- $b = dol_mktime((int) $h,30,0,$month,$day,$year);
- $c = dol_mktime((int) $h+1,0,0,$month,$day,$year);
+ $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,false);
+ $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,false);
+ $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,false);
- if ($event->date_start_in_calendar < $b && $event->date_end_in_calendar > $a)
+ $dateendtouse=$event->date_end_in_calendar;
+ if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++;
+
+ if ($event->date_start_in_calendar < $b && $dateendtouse > $a)
{
- $cases1[$h][$event->id]++;
+ $busy=$event->transparency;
+ $cases1[$h][$event->id]['busy']=$busy;
+ $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour').' - '.dol_print_date($event->date_end_in_calendar,'dayhour').' - '.$event->label;
}
- if ($event->date_start_in_calendar < $c && $event->date_end_in_calendar > $b)
+ if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
{
- $cases2[$h][$event->id]++;
+ $busy=$event->transparency;
+ $cases2[$h][$event->id]['busy']=$busy;
+ $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour').' - '.dol_print_date($event->date_end_in_calendar,'dayhour').' - '.$event->label;
}
}
else
{
- $cases1[$h][$event->id]=1;
- $cases2[$h][$event->id]=1;
+ $busy=$event->transparency;
+ $cases1[$h][$event->id]['busy']=$busy;
+ $cases2[$h][$event->id]['busy']=$busy;
+ $cases1[$h][$event->id]['string']=$event->label;
+ $cases2[$h][$event->id]['string']=$event->label;
break;
}
}
@@ -792,32 +827,24 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$style1='';$style2='';
$string1=' ';$string2=' ';
$title1='';$title2='';
- if (isset($cases1[$h]))
+ if (isset($cases1[$h]) && $cases1[$h] != '')
{
- if ($cases1[$h] != '')
+ $title1=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
+ $string1=' ';
+ $style1='peruser_notbusy';
+ foreach($cases1[$h] as $id => $ev)
{
- $title = (int) $cases1[$h];
- $title .= 'h';
- if ((int) $cases1[$h] != $cases1[$h])
- $title .= '30';
- else
- $title .= '00';
- $string1=' ';
- $style1='peruser_busy';
- $url='';
+ if ($ev['busy']) $style1='peruser_busy';
}
}
- if (isset($cases2[$h]))
+ if (isset($cases2[$h]) && $cases2[$h] != '')
{
- if ($cases2[$h] != '')
+ $title2=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
+ $string2=' ';
+ $style2='peruser_notbusy';
+ foreach($cases2[$h] as $id => $ev)
{
- $title = (int) $cases2[$h];
- $title .= 'h';
- if ((int) $cases2[$h] != $cases2[$h]) $title .= '30';
- else $title .= '00';
- $string2=' ';
- $style2='peruser_busy';
- $url=' ';
+ if ($ev['busy']) $style2='peruser_busy';
}
}
@@ -827,20 +854,22 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
if (count($cases1[$h]) == 1) // 1 seul evenement
{
$ids=array_keys($cases1[$h]);
- $id=$ids[0];
- $title1='zzz';
+ $output = array_slice($cases1[$h], 0, 1);
+ if ($output[0]['string']) $title1.=' - '.$output[0]['string'];
}
- if (count($cases2[$h]) == 1) // 1 seul evenement
+ if (count($cases2[$h]) == 1) // 1 seul evenement
{
$ids=array_keys($cases2[$h]);
- $id=$ids[0];
- $title2='bbb';
+ $output = array_slice($cases2[$h], 0, 1);
+ if ($output[0]['string']) $title2.=' - '.$output[0]['string'];
}
- print ' ';
- print '';
+ $ids1=join(',',array_keys($cases1[$h]));
+ $ids2=join(',',array_keys($cases2[$h]));
//var_dump($cases1[$h]);
+ print '';
+ print '';
print $string1;
- print ' ';
+ print ' ';
print $string2;
print ' ';
print '
';
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 50af9c5ec10..2e9db8bc077 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -2220,7 +2220,7 @@ if ($action == 'create')
// Payment mode
print ' ' . $langs->trans('PaymentMode') . ' ';
- $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id');
+ $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT');
print ' ';
// Bank Account
@@ -3181,10 +3181,13 @@ if ($action == 'create')
print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . ' ';
print '
';
print '';
- if ($action == 'editmode') {
- $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
- } else {
- $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->mode_reglement_id, 'none');
+ if ($action == 'editmode')
+ {
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT');
+ }
+ else
+ {
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT');
}
print ' ';
diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php
index 4cac0678f4e..88fa6ebad27 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/impayees.php
@@ -529,7 +529,7 @@ if ($resql)
print '';
print '';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","",$param,"",$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
@@ -555,9 +555,9 @@ if ($resql)
// Ref
print '';
print ' ';
- print '';
- print ' ';
- print ' ';
+ print '';
+ print ' ';
+ print ' ';
print ' ';
print ' ';
print ' ';
@@ -635,10 +635,10 @@ if ($resql)
print "\n";
- // Customer ref
- print '';
- print $objp->ref_client;
- print ' ';
+ // Customer ref
+ print '';
+ print $objp->ref_client;
+ print ' ';
print ''.dol_print_date($db->jdate($objp->df),'day').' '."\n";
print ''.dol_print_date($db->jdate($objp->datelimite),'day').' '."\n";
@@ -651,12 +651,12 @@ if ($resql)
$thirdparty->code_client=$objp->code_client;
print $thirdparty->getNomUrl(1,'customer');
print '';
-
+
// Payment mode
print '';
$form->form_modes_reglement($_SERVER['PHP_SELF'], $objp->fk_mode_reglement, 'none');
print ' ';
-
+
print ''.price($objp->total_ht).' ';
print ''.price($objp->total_tva);
@@ -710,7 +710,7 @@ if ($resql)
}
print ' ';
- print ''.$langs->trans("Total").' ';
+ print ''.$langs->trans("Total").' ';
print ''.price($total_ht).' ';
print ''.price($total_tva).' ';
print ''.price($total_ttc).' ';
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 6c0c7c87558..e8095954a37 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1216,10 +1216,11 @@ class BonPrelevement extends CommonObject
/**
- * Generate a withdrawal file. Generation Formats:
- * European countries: SEPA
- * Others: Warning message
- * File is generated with name this->filename
+ * Generate a withdrawal file.
+ * Generation Formats:
+ * - Europe: SEPA (France: CFONB no more supported, Spain: AEB19 if external module EsAEB is enabled)
+ * - Others countries: Warning message
+ * File is generated with name this->filename
*
* @return int 0 if OK, <0 if KO
*/
@@ -1340,7 +1341,7 @@ class BonPrelevement extends CommonObject
fputs($this->file, ' '.$CrLf);
fputs($this->file, ' '.$CrLf);
fputs($this->file, ''.$CrLf);
-
+
$sql = "SELECT pl.amount";
$sql.= " FROM";
$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
@@ -1349,14 +1350,14 @@ class BonPrelevement extends CommonObject
$sql.= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql.= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql.= " AND pf.fk_facture = f.rowid";
-
+
//Lines
$i = 0;
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
-
+
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
@@ -1504,7 +1505,7 @@ class BonPrelevement extends CommonObject
* @param string $row_bic rib.bic AS bic,
* @param string $row_datec soc.datec,
* @param string $row_drum soc.rowid AS drum
- * @return void
+ * @return string Return string with SEPA part DrctDbtTxInf
*/
function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum)
{
@@ -1528,15 +1529,15 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
- $XML_DEBITOR .=' '.$row_iban.' '.$CrLf;
+ $XML_DEBITOR .=' '.$row_bic.' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
- $XML_DEBITOR .=' '.strtoupper($row_nom).' '.$CrLf;
+ $XML_DEBITOR .=' '.strtoupper(dol_string_unaccent($row_nom)).' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$row_country_code.' '.$CrLf;
$XML_DEBITOR .=' '.strtr($row_adr, array(CHR(13) => ", ", CHR(10) => "")).' '.$CrLf;
- $XML_DEBITOR .=' '.$row_zip.' '.$row_town.' '.$CrLf;
+ $XML_DEBITOR .=' '.dol_string_unaccent($row_zip.' '.$row_town).' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
@@ -1619,7 +1620,8 @@ class BonPrelevement extends CommonObject
}
/**
- * Write sender of request (me)
+ * Write sender of request (me).
+ * Note: The tag PmtInf is opened here but closed into caller
*
* @param string $configuration conf
* @param date $ladate Date
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 358c2a90304..d70e9c32c0b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -803,7 +803,11 @@ class Form
// Construct $out and $outarray
$out.= ''."\n";
- if ($showempty) $out.= ' '."\n";
+
+ $textifempty=' ';
+ if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=' ';
+ if ($showempty) $out.= ''.$textifempty.' '."\n";
+
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
@@ -2343,8 +2347,8 @@ class Form
dol_syslog(get_class($this)."::select_type_paiements ".$selected.", ".$htmlname.", ".$filtertype.", ".$format,LOG_DEBUG);
$filterarray=array();
- if ($filtertype == 'CRDT') $filterarray=array(0,2);
- elseif ($filtertype == 'DBIT') $filterarray=array(1,2);
+ if ($filtertype == 'CRDT') $filterarray=array(0,2,3);
+ elseif ($filtertype == 'DBIT') $filterarray=array(1,2,3);
elseif ($filtertype != '' && $filtertype != '-1') $filterarray=explode(',',$filtertype);
$this->load_cache_types_paiements();
@@ -3192,12 +3196,13 @@ class Form
/**
* Affiche formulaire de selection des modes de reglement
*
- * @param string $page Page
- * @param int $selected Id mode pre-selectionne
- * @param string $htmlname Name of select html field
+ * @param string $page Page
+ * @param int $selected Id mode pre-selectionne
+ * @param string $htmlname Name of select html field
+ * @param string $filtertype To filter on field type in llx_c_paiement (array('code'=>xx,'label'=>zz))
* @return void
*/
- function form_modes_reglement($page, $selected='', $htmlname='mode_reglement_id')
+ function form_modes_reglement($page, $selected='', $htmlname='mode_reglement_id', $filtertype='')
{
global $langs;
if ($htmlname != "none")
@@ -3207,7 +3212,7 @@ class Form
print ' ';
print '';
@@ -3934,7 +3939,7 @@ class Form
* @param int $show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param int $value_as_key 1 to use value as key
- * @param string $option Valeur de l'option en fonction du type choisi
+ * @param string $moreparam Add more parameters onto the select tag
* @param int $translate Translate and encode value
* @param int $maxlen Length maximum for labels
* @param int $disabled Html select box is disabled
@@ -3942,17 +3947,19 @@ class Form
* @param string $morecss Add more class to css styles
* @return string HTML select string
*/
- static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='')
+ static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='')
{
- global $langs;
+ global $conf, $langs;
if ($value_as_key) $array=array_combine($array, $array);
- $out='';
+ $out='';
if ($show_empty)
{
- $out.=' '."\n"; // Do not use here. It will show it when list is not ajaxed
+ $textforempty=' ';
+ if (! empty($conf->use_javascript_ajax)) $textforempty=' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
+ $out.=''.$textforempty.' '."\n";
}
if (is_array($array))
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 762ebf4e605..2fae2b68952 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -525,14 +525,14 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
$tmpmonth = $prev_month;
$tmpyear = $prev_year;
- //Get first day of next week
+ //Get first day of next week
$tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0);
$tmptime-=24*60*60*7;
$tmparray=dol_getdate($tmptime,true);
$prev_day = $tmparray['mday'];
//Check prev day of week is in same month than first day or not
- if ($prev_day>$tmpday)
+ if ($prev_day > $tmpday)
{
$prev_month = $month-1;
$prev_year = $year;
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 0f6aec27eda..2e2bf34a75d 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -390,38 +390,43 @@ function dol_string_unaccent($str)
{
if (utf8_check($str))
{
+ // See http://www.utf8-chartable.de/
$string = rawurlencode($str);
$replacements = array(
- '%C3%80' => 'A','%C3%81' => 'A',
- '%C3%88' => 'E','%C3%89' => 'E',
- '%C3%8C' => 'I','%C3%8D' => 'I',
- '%C3%92' => 'O','%C3%93' => 'O',
- '%C3%99' => 'U','%C3%9A' => 'U',
- '%C3%A0' => 'a','%C3%A1' => 'a','%C3%A2' => 'a',
+ '%C3%80' => 'A','%C3%81' => 'A','%C3%82' => 'A','%C3%83' => 'A','%C3%84' => 'A','%C3%85' => 'A',
+ '%C3%88' => 'E','%C3%89' => 'E','%C3%8A' => 'E','%C3%8B' => 'E',
+ '%C3%8C' => 'I','%C3%8D' => 'I','%C3%8E' => 'I','%C3%8F' => 'I',
+ '%C3%92' => 'O','%C3%93' => 'O','%C3%94' => 'O','%C3%95' => 'O','%C3%96' => 'O',
+ '%C3%99' => 'U','%C3%9A' => 'U','%C3%9B' => 'U','%C3%9C' => 'U',
+ '%C3%A0' => 'a','%C3%A1' => 'a','%C3%A2' => 'a','%C3%A3' => 'a','%C3%A4' => 'a','%C3%A5' => 'a',
+ '%C3%A7' => 'c',
'%C3%A8' => 'e','%C3%A9' => 'e','%C3%AA' => 'e','%C3%AB' => 'e',
- '%C3%AC' => 'i','%C3%AD' => 'i','%C3%AE' => 'i',
- '%C3%B2' => 'o','%C3%B3' => 'o',
- '%C3%B9' => 'u','%C3%BA' => 'u'
+ '%C3%AC' => 'i','%C3%AD' => 'i','%C3%AE' => 'i','%C3%AF' => 'i',
+ '%C3%B1' => 'n',
+ '%C3%B2' => 'o','%C3%B3' => 'o','%C3%B4' => 'o','%C3%B5' => 'o','%C3%B6' => 'o',
+ '%C3%B9' => 'u','%C3%BA' => 'u','%C3%BB' => 'u','%C3%BC' => 'u',
+ '%C3%BF' => 'y'
);
$string=strtr($string, $replacements);
return rawurldecode($string);
}
else
{
+ // See http://www.ascii-code.com/
$string = strtr(
$str,
- "\xC0\xC1\xC2\xC3\xC5\xC7
+ "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
\xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
- \xE0\xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB
+ \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
- \xF9\xFA\xFB\xFD\xFF",
- "AAAAAC
+ \xF9\xFA\xFB\xFC\xFD\xFF",
+ "AAAAAAC
EEEEIIIIDN
OOOOOUUUY
- aaaaaceeee
+ aaaaaaceeee
iiiidnooooo
- uuuyy"
+ uuuuyy"
);
$string = strtr($string, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th"));
return $string;
diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php
index 46ab465f42e..bab287ff3b6 100644
--- a/htdocs/core/modules/export/export_excel.modules.php
+++ b/htdocs/core/modules/export/export_excel.modules.php
@@ -66,7 +66,7 @@ class ExportExcel extends ModeleExports
// If driver use an external library, put its name here
$this->label_lib='PhpExcel';
- $this->version_lib='1.7.2';
+ $this->version_lib='1.7.8';
$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages)
diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php
index 9d704ce8fbe..bf70c30ab1c 100644
--- a/htdocs/core/modules/export/export_excel2007.modules.php
+++ b/htdocs/core/modules/export/export_excel2007.modules.php
@@ -66,7 +66,7 @@ class ExportExcel2007 extends ExportExcel
// If driver use an external library, put its name here
$this->label_lib='PhpExcel';
- $this->version_lib='1.7.2';
+ $this->version_lib='1.7.8';
$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages)
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index d0dbc36e803..9d20c2b9722 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -1328,14 +1328,24 @@ if ($action == 'create')
// Payment term
print ''.$langs->trans('PaymentConditionsShort').' ';
- $form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
+ $form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id, 'cond_reglement_id');
print ' ';
// Payment mode
print ''.$langs->trans('PaymentMode').' ';
- $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
+ $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id, 'mode_reglement_id', 'DBIT');
print ' ';
+ // Project
+ if (! empty($conf->projet->enabled)) {
+ $formproject = new FormProjets($db);
+
+ $langs->load('projects');
+ print '' . $langs->trans('Project') . ' ';
+ $formproject->select_projects($soc->id, $projectid, 'projectid');
+ print ' ';
+ }
+
// Bank Account
print ''.$langs->trans('BankAccount').' ';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
@@ -1784,11 +1794,11 @@ else
print ' ';
if ($action == 'editmode')
{
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT');
}
else
{
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', 'DBIT');
}
print ' ';
diff --git a/htdocs/includes/phpexcel/PHPExcel.php b/htdocs/includes/phpexcel/PHPExcel.php
index cdb4ab95012..f0b39e7961a 100644
--- a/htdocs/includes/phpexcel/PHPExcel.php
+++ b/htdocs/includes/phpexcel/PHPExcel.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -38,7 +38,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel
{
@@ -127,6 +127,11 @@ class PHPExcel
}
+ /**
+ * Disconnect all worksheets from this PHPExcel workbook object,
+ * typically so that the PHPExcel object can be unset
+ *
+ */
public function disconnectWorksheets() {
foreach($this->_workSheetCollection as $k => &$worksheet) {
$worksheet->disconnectCells();
@@ -189,15 +194,28 @@ class PHPExcel
/**
* Create sheet and add it to this workbook
*
+ * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
* @return PHPExcel_Worksheet
+ * @throws Exception
*/
- public function createSheet($iSheetIndex = null)
+ public function createSheet($iSheetIndex = NULL)
{
$newSheet = new PHPExcel_Worksheet($this);
$this->addSheet($newSheet, $iSheetIndex);
return $newSheet;
}
+ /**
+ * Chech if a sheet with a specified name already exists
+ *
+ * @param string $pSheetName Name of the worksheet to check
+ * @return boolean
+ */
+ public function sheetNameExists($pSheetName)
+ {
+ return ($this->getSheetByName($pSheetName) !== NULL);
+ }
+
/**
* Add sheet
*
@@ -206,14 +224,18 @@ class PHPExcel
* @return PHPExcel_Worksheet
* @throws Exception
*/
- public function addSheet(PHPExcel_Worksheet $pSheet = null, $iSheetIndex = null)
+ public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL)
{
- if(is_null($iSheetIndex))
- {
+ if ($this->sheetNameExists($pSheet->getTitle())) {
+ throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first.");
+ }
+
+ if($iSheetIndex === NULL) {
+ if ($this->_activeSheetIndex < 0) {
+ $this->_activeSheetIndex = 0;
+ }
$this->_workSheetCollection[] = $pSheet;
- }
- else
- {
+ } else {
// Insert the sheet at the requested index
array_splice(
$this->_workSheetCollection,
@@ -226,7 +248,6 @@ class PHPExcel
if ($this->_activeSheetIndex >= $iSheetIndex) {
++$this->_activeSheetIndex;
}
-
}
return $pSheet;
}
@@ -244,6 +265,12 @@ class PHPExcel
} else {
array_splice($this->_workSheetCollection, $pIndex, 1);
}
+ // Adjust active sheet index if necessary
+ if (($this->_activeSheetIndex >= $pIndex) &&
+ ($pIndex > count($this->_workSheetCollection) - 1)) {
+ --$this->_activeSheetIndex;
+ }
+
}
/**
@@ -379,7 +406,7 @@ class PHPExcel
public function setActiveSheetIndexByName($pValue = '')
{
if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) {
- $this->setActiveSheetIndex($worksheet->getParent()->getIndex($worksheet));
+ $this->setActiveSheetIndex($this->getIndex($worksheet));
return $worksheet;
}
@@ -396,7 +423,7 @@ class PHPExcel
$returnValue = array();
$worksheetCount = $this->getSheetCount();
for ($i = 0; $i < $worksheetCount; ++$i) {
- array_push($returnValue, $this->getSheet($i)->getTitle());
+ $returnValue[] = $this->getSheet($i)->getTitle();
}
return $returnValue;
@@ -411,7 +438,7 @@ class PHPExcel
* @return PHPExcel_Worksheet
*/
public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) {
- if (!is_null($this->getSheetByName($pSheet->getTitle()))) {
+ if ($this->sheetNameExists($pSheet->getTitle())) {
throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first.");
}
@@ -471,14 +498,14 @@ class PHPExcel
public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
$returnValue = null;
- if ($namedRange != '' && !is_null($namedRange)) {
+ if ($namedRange != '' && ($namedRange !== NULL)) {
// first look for global defined name
if (isset($this->_namedRanges[$namedRange])) {
$returnValue = $this->_namedRanges[$namedRange];
}
// then look for local defined name (has priority over global defined name if both names exist)
- if (!is_null($pSheet) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
+ if (($pSheet !== NULL) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
$returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange];
}
}
@@ -489,12 +516,12 @@ class PHPExcel
/**
* Remove named range
*
- * @param string $namedRange
- * @param PHPExcel_Worksheet|null $pSheet. Scope. Use null for global scope.
+ * @param string $namedRange
+ * @param PHPExcel_Worksheet|null $pSheet Scope: use null for global scope.
* @return PHPExcel
*/
public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
- if (is_null($pSheet)) {
+ if ($pSheet === NULL) {
if (isset($this->_namedRanges[$namedRange])) {
unset($this->_namedRanges[$namedRange]);
}
@@ -556,7 +583,7 @@ class PHPExcel
/**
* Get cellXf by index
*
- * @param int $index
+ * @param int $pIndex
* @return PHPExcel_Style
*/
public function getCellXfByIndex($pIndex = 0)
@@ -597,7 +624,7 @@ class PHPExcel
/**
* Add a cellXf to the workbook
*
- * @param PHPExcel_Style
+ * @param PHPExcel_Style $style
*/
public function addCellXf(PHPExcel_Style $style)
{
@@ -761,7 +788,7 @@ class PHPExcel
}
// make sure there is always at least one cellXf (there should be)
- if (count($this->_cellXfCollection) == 0) {
+ if (empty($this->_cellXfCollection)) {
$this->_cellXfCollection[] = new PHPExcel_Style();
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Autoloader.php b/htdocs/includes/phpexcel/PHPExcel/Autoloader.php
index 1164cf1f7cd..15193278b63 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Autoloader.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Autoloader.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,41 +20,66 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version 1.7.8, 2012-10-12
*/
PHPExcel_Autoloader::Register();
+// As we always try to run the autoloader before anything else, we can use it to do a few
+// simple checks and initialisations
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
- throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+ throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
PHPExcel_Shared_String::buildCharacterSets();
+/**
+ * PHPExcel_Autoloader
+ *
+ * @category PHPExcel
+ * @package PHPExcel
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
+ */
class PHPExcel_Autoloader
{
+ /**
+ * Register the Autoloader with SPL
+ *
+ */
public static function Register() {
+ if (function_exists('__autoload')) {
+ // Register any existing autoloader function with SPL, so we don't get any clashes
+ spl_autoload_register('__autoload');
+ }
+ // Register ourselves with SPL
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
} // function Register()
- public static function Load($pObjectName){
- if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPExcel') === False)) {
- return false;
+ /**
+ * Autoload a class identified by name
+ *
+ * @param string $pClassName Name of the object to load
+ */
+ public static function Load($pClassName){
+ if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
+ // Either already loaded, or not a PHPExcel class request
+ return FALSE;
}
- $pObjectFilePath = PHPEXCEL_ROOT.
- str_replace('_',DIRECTORY_SEPARATOR,$pObjectName).
- '.php';
+ $pClassFilePath = PHPEXCEL_ROOT .
+ str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
+ '.php';
- if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
- return false;
+ if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
+ // Can't load
+ return FALSE;
}
- require($pObjectFilePath);
+ require($pClassFilePath);
} // function Load()
}
\ No newline at end of file
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php
index 64262c0a847..9dab5581480 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/APC.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,33 +31,57 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+ /**
+ * Prefix used to uniquely identify cache data for this worksheet
+ *
+ * @access private
+ * @var string
+ */
private $_cachePrefix = null;
+ /**
+ * Cache timeout
+ *
+ * @access private
+ * @var integer
+ */
private $_cacheTime = 600;
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @access private
+ * @return void
+ * @throws Exception
+ */
private function _storeData() {
- $this->_currentObject->detach();
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
- if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
- $this->__destruct();
- throw new Exception('Failed to store cell '.$cellID.' in APC');
+ if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
+ }
+ $this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @access public
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -67,17 +91,19 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
- * @param string $pCoord Coordinate address of the cell to check
- * @return void
- * @return boolean
+ * @access public
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return void
+ * @return boolean
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
@@ -90,7 +116,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if ($success === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
- throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
}
return true;
}
@@ -101,6 +127,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
/**
* Get cell at a specific coordinate
*
+ * @access public
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
@@ -117,7 +144,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
- throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
}
} else {
// Return null if requested entry doesn't exist in cache
@@ -136,10 +163,11 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
/**
- * Delete a cell in cache identified by coordinate address
+ * Delete a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to delete
- * @throws Exception
+ * @access public
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from APC
@@ -151,9 +179,11 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
/**
- * Clone the cell collection
+ * Clone the cell collection
*
- * @return void
+ * @access public
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
@@ -179,8 +209,13 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
} // function copyCellCollection()
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
- if(!is_null($this->_currentObject)) {
+ if ($this->_currentObject !== NULL) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
@@ -195,10 +230,16 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
} // function unsetWorksheetCells()
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
- if (is_null($this->_cachePrefix)) {
+ if ($this->_cachePrefix === NULL) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
$this->_cacheTime = $cacheTime;
@@ -208,6 +249,9 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
} // function __construct()
+ /**
+ * Destroy this cell collection
+ */
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
@@ -215,4 +259,22 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
}
} // function __destruct()
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('apc_store')) {
+ return false;
+ }
+ if (apc_sma_info() === false) {
+ return false;
+ }
+
+ return true;
+ }
+
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php
index 0430be9093e..d2eea08bb97 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/CacheBase.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,41 +31,53 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_CachedObjectStorage_CacheBase {
+abstract class PHPExcel_CachedObjectStorage_CacheBase {
/**
- * Parent worksheet
+ * Parent worksheet
*
- * @var PHPExcel_Worksheet
+ * @var PHPExcel_Worksheet
*/
protected $_parent;
/**
- * The currently active Cell
+ * The currently active Cell
*
- * @var PHPExcel_Cell
+ * @var PHPExcel_Cell
*/
protected $_currentObject = null;
/**
- * Coordinate address of the currently active Cell
+ * Coordinate address of the currently active Cell
*
- * @var string
+ * @var string
*/
protected $_currentObjectID = null;
/**
- * An array of cells or cell pointers for the worksheet cells held in this cache,
+ * Flag indicating whether the currently active Cell requires saving
+ *
+ * @var boolean
+ */
+ protected $_currentCellIsDirty = true;
+
+ /**
+ * An array of cells or cell pointers for the worksheet cells held in this cache,
* and indexed by their coordinate address within the worksheet
*
- * @var array of mixed
+ * @var array of mixed
*/
protected $_cellCache = array();
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
public function __construct(PHPExcel_Worksheet $parent) {
// Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
@@ -75,11 +87,10 @@ class PHPExcel_CachedObjectStorage_CacheBase {
/**
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
- * @param string $pCoord Coordinate address of the cell to check
- * @return void
- * @return boolean
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
@@ -91,11 +102,11 @@ class PHPExcel_CachedObjectStorage_CacheBase {
/**
- * Add or Update a cell in cache
+ * Add or Update a cell in cache
*
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function updateCacheData(PHPExcel_Cell $cell) {
return $this->addCacheData($cell->getCoordinate(),$cell);
@@ -103,10 +114,10 @@ class PHPExcel_CachedObjectStorage_CacheBase {
/**
- * Delete a cell in cache identified by coordinate address
+ * Delete a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to delete
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
@@ -118,13 +129,14 @@ class PHPExcel_CachedObjectStorage_CacheBase {
$this->_cellCache[$pCoord]->detach();
unset($this->_cellCache[$pCoord]);
}
+ $this->_currentCellIsDirty = false;
} // function deleteCacheData()
/**
- * Get a list of all cell addresses currently held in cache
+ * Get a list of all cell addresses currently held in cache
*
- * @return array of string
+ * @return array of string
*/
public function getCellList() {
return array_keys($this->_cellCache);
@@ -132,13 +144,13 @@ class PHPExcel_CachedObjectStorage_CacheBase {
/**
- * Sort the list of all cell addresses currently held in cache by row and column
+ * Sort the list of all cell addresses currently held in cache by row and column
*
- * @return void
+ * @return void
*/
public function getSortedCellList() {
$sortKeys = array();
- foreach (array_keys($this->_cellCache) as $coord) {
+ foreach ($this->getCellList() as $coord) {
list($column,$row) = sscanf($coord,'%[A-Z]%d');
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
}
@@ -148,6 +160,62 @@ class PHPExcel_CachedObjectStorage_CacheBase {
} // function sortCellList()
+
+ /**
+ * Get highest worksheet column and highest row that have cell records
+ *
+ * @return array Highest column name and highest row number
+ */
+ public function getHighestRowAndColumn()
+ {
+ // Lookup highest column and highest row
+ $col = array('A' => '1A');
+ $row = array(1);
+ foreach ($this->getCellList() as $coord) {
+ list($c,$r) = sscanf($coord,'%[A-Z]%d');
+ $row[$r] = $r;
+ $col[$c] = strlen($c).$c;
+ }
+ if (!empty($row)) {
+ // Determine highest column and row
+ $highestRow = max($row);
+ $highestColumn = substr(max($col),1);
+ }
+
+ return array( 'row' => $highestRow,
+ 'column' => $highestColumn
+ );
+ }
+
+
+ /**
+ * Get highest worksheet column
+ *
+ * @return string Highest column name
+ */
+ public function getHighestColumn()
+ {
+ $colRow = $this->getHighestRowAndColumn();
+ return $colRow['column'];
+ }
+
+ /**
+ * Get highest worksheet row
+ *
+ * @return int Highest row number
+ */
+ public function getHighestRow()
+ {
+ $colRow = $this->getHighestRowAndColumn();
+ return $colRow['row'];
+ }
+
+
+ /**
+ * Generate a unique ID for cache referencing
+ *
+ * @return string Unique Reference
+ */
protected function _getUniqueID() {
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
@@ -158,15 +226,27 @@ class PHPExcel_CachedObjectStorage_CacheBase {
}
/**
- * Clone the cell collection
+ * Clone the cell collection
*
- * @return void
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_parent = $parent;
- if ((!is_null($this->_currentObject)) && (is_object($this->_currentObject))) {
+ if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
$this->_currentObject->attach($parent);
}
} // function copyCellCollection()
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ return true;
+ }
+
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php
index e3116543a1e..805dc063ace 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/DiscISAM.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,34 +31,62 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+ /**
+ * Name of the file for this cache
+ *
+ * @var string
+ */
private $_fileName = null;
+
+ /**
+ * File handle for this cache file
+ *
+ * @var resource
+ */
private $_fileHandle = null;
+ /**
+ * Directory/Folder where the cache file is located
+ *
+ * @var string
+ */
+ private $_cacheDirectory = NULL;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
private function _storeData() {
- $this->_currentObject->detach();
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
- fseek($this->_fileHandle,0,SEEK_END);
- $offset = ftell($this->_fileHandle);
- fwrite($this->_fileHandle, serialize($this->_currentObject));
- $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
- 'sz' => ftell($this->_fileHandle) - $offset
- );
+ fseek($this->_fileHandle,0,SEEK_END);
+ $offset = ftell($this->_fileHandle);
+ fwrite($this->_fileHandle, serialize($this->_currentObject));
+ $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
+ 'sz' => ftell($this->_fileHandle) - $offset
+ );
+ $this->_currentCellIsDirty = false;
+ }
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -67,6 +95,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
@@ -104,15 +133,16 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
/**
- * Clone the cell collection
+ * Clone the cell collection
*
- * @return void
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
- $newFileName = PHPExcel_Shared_File::sys_get_temp_dir().'/PHPExcel.'.$baseUnique.'.cache';
+ $newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
// Copy the existing cell cache file
copy ($this->_fileName,$newFileName);
$this->_fileName = $newFileName;
@@ -121,6 +151,11 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
} // function copyCellCollection()
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
@@ -136,16 +171,29 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
} // function unsetWorksheetCells()
- public function __construct(PHPExcel_Worksheet $parent) {
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments) {
+ $this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
+ ? $arguments['dir']
+ : PHPExcel_Shared_File::sys_get_temp_dir();
+
parent::__construct($parent);
if (is_null($this->_fileHandle)) {
$baseUnique = $this->_getUniqueID();
- $this->_fileName = PHPExcel_Shared_File::sys_get_temp_dir().'/PHPExcel.'.$baseUnique.'.cache';
+ $this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
$this->_fileHandle = fopen($this->_fileName,'a+');
}
} // function __construct()
+ /**
+ * Destroy this cell collection
+ */
public function __destruct() {
if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle);
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php
index 35215a0f645..56f621a597b 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/ICache.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,74 +31,82 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_CachedObjectStorage_ICache
{
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell);
/**
- * Add or Update a cell in cache
+ * Add or Update a cell in cache
*
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function updateCacheData(PHPExcel_Cell $cell);
/**
- * Fetch a cell from cache identified by coordinate address
+ * Fetch a cell from cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to retrieve
- * @return PHPExcel_Cell Cell that was found, or null if not found
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to retrieve
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ * @throws Exception
*/
public function getCacheData($pCoord);
/**
- * Delete a cell in cache identified by coordinate address
+ * Delete a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to delete
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
*/
public function deleteCacheData($pCoord);
/**
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
- * @param string $pCoord Coordinate address of the cell to check
- * @return void
- * @return boolean
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
*/
public function isDataSet($pCoord);
/**
- * Get a list of all cell addresses currently held in cache
+ * Get a list of all cell addresses currently held in cache
*
- * @return array of string
+ * @return array of string
*/
public function getCellList();
/**
- * Get the list of all cell addresses currently held in cache sorted by column and row
+ * Get the list of all cell addresses currently held in cache sorted by column and row
*
- * @return void
+ * @return void
*/
public function getSortedCellList();
/**
- * Clone the cell collection
+ * Clone the cell collection
*
- * @return void
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent);
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable();
+
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Igbinary.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Igbinary.php
new file mode 100644
index 00000000000..fc2f1129917
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Igbinary.php
@@ -0,0 +1,138 @@
+_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->_cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ $this->_cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('igbinary_serialize')) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php
index ce8ef9c2a32..23d6957281f 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memcache.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,38 +31,63 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+ /**
+ * Prefix used to uniquely identify cache data for this worksheet
+ *
+ * @var string
+ */
private $_cachePrefix = null;
+ /**
+ * Cache timeout
+ *
+ * @var integer
+ */
private $_cacheTime = 600;
+ /**
+ * Memcache interface
+ *
+ * @var resource
+ */
private $_memcache = null;
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
private function _storeData() {
- $this->_currentObject->detach();
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
- $obj = serialize($this->_currentObject);
- if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
- if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
- $this->__destruct();
- throw new Exception('Failed to store cell '.$cellID.' in MemCache');
+ $obj = serialize($this->_currentObject);
+ if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
+ if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
+ }
}
+ $this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -72,17 +97,18 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
- * @param string $pCoord Coordinate address of the cell to check
- * @return void
- * @return boolean
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return void
+ * @return boolean
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
@@ -95,7 +121,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
- throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
return true;
}
@@ -122,7 +148,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
- throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
} else {
// Return null if requested entry doesn't exist in cache
@@ -141,10 +167,10 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
/**
- * Delete a cell in cache identified by coordinate address
+ * Delete a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to delete
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from Memcache
@@ -156,9 +182,10 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
/**
- * Clone the cell collection
+ * Clone the cell collection
*
- * @return void
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
@@ -184,6 +211,11 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
} // function copyCellCollection()
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
@@ -200,6 +232,12 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
} // function unsetWorksheetCells()
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
@@ -221,11 +259,21 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
} // function __construct()
+ /**
+ * Memcache error handler
+ *
+ * @param string $host Memcache server
+ * @param integer $port Memcache port
+ * @throws Exception
+ */
public function failureCallback($host, $port) {
throw new Exception('memcache '.$host.':'.$port.' failed');
}
+ /**
+ * Destroy this cell collection
+ */
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
@@ -233,4 +281,18 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
}
} // function __destruct()
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('memcache_add')) {
+ return false;
+ }
+
+ return true;
+ }
+
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php
index c0d0b5da927..36f42fb6ccf 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Memory.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,17 +31,17 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
$this->_cellCache[$pCoord] = $cell;
@@ -68,6 +68,12 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
} // function getCacheData()
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
@@ -81,6 +87,11 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
}
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
foreach($this->_cellCache as $k => &$cell) {
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php
index e9ff3c4f43f..ee8e95eb2b5 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemoryGZip.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,25 +31,35 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
private function _storeData() {
- $this->_currentObject->detach();
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
- $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
+ $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
+ $this->_currentCellIsDirty = false;
+ }
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -58,6 +68,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
@@ -93,6 +104,11 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
} // function getCacheData()
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php
index 0c3f3bd9ebb..d6b09b530e8 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/MemorySerialized.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,25 +31,35 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
private function _storeData() {
- $this->_currentObject->detach();
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
- $this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
+ $this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
+ $this->_currentCellIsDirty = false;
+ }
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -58,6 +68,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
@@ -93,6 +104,11 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
} // function getCacheData()
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php
index aedb8140c99..8dbbe92e8c2 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/PHPTemp.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,35 +31,54 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+ /**
+ * Name of the file for this cache
+ *
+ * @var string
+ */
private $_fileHandle = null;
-
+ /**
+ * Memory limit to use before reverting to file cache
+ *
+ * @var integer
+ */
private $_memoryCacheSize = null;
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
private function _storeData() {
- $this->_currentObject->detach();
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
- fseek($this->_fileHandle,0,SEEK_END);
- $offset = ftell($this->_fileHandle);
- fwrite($this->_fileHandle, serialize($this->_currentObject));
- $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
- 'sz' => ftell($this->_fileHandle) - $offset
- );
+ fseek($this->_fileHandle,0,SEEK_END);
+ $offset = ftell($this->_fileHandle);
+ fwrite($this->_fileHandle, serialize($this->_currentObject));
+ $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
+ 'sz' => ftell($this->_fileHandle) - $offset
+ );
+ $this->_currentCellIsDirty = false;
+ }
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -68,6 +87,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
@@ -105,9 +125,10 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
/**
- * Clone the cell collection
+ * Clone the cell collection
*
- * @return void
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
@@ -122,6 +143,11 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
} // function copyCellCollection()
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
@@ -137,7 +163,13 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
} // function unsetWorksheetCells()
- public function __construct(PHPExcel_Worksheet $parent, $memoryCacheSize = '1MB') {
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
parent::__construct($parent);
@@ -147,6 +179,9 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
} // function __construct()
+ /**
+ * Destroy this cell collection
+ */
public function __destruct() {
if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle);
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite.php
new file mode 100644
index 00000000000..e4bf469e0fc
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite.php
@@ -0,0 +1,270 @@
+_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
+ if ($cellResultSet === false) {
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ } elseif ($cellResultSet->numRows() == 0) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+
+ $cellResult = $cellResultSet->fetchSingle();
+ $this->_currentObject = unserialize($cellResult);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Is a value set for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return true;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
+ if ($cellResultSet === false) {
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ } elseif ($cellResultSet->numRows() == 0) {
+ // Return null if requested entry doesn't exist in cache
+ return false;
+ }
+ return true;
+ } // function isDataSet()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ $this->_currentObject->detach();
+ $this->_currentObjectID = $this->_currentObject = null;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ if (!$this->_DBHandle->queryExec($query))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+
+ $this->_currentCellIsDirty = false;
+ } // function deleteCacheData()
+
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return array of string
+ */
+ public function getCellList() {
+ $query = "SELECT id FROM kvp_".$this->_TableName;
+ $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
+ if ($cellIdsResult === false)
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+
+ $cellKeys = array();
+ foreach($cellIdsResult as $row) {
+ $cellKeys[] = $row['id'];
+ }
+
+ return $cellKeys;
+ } // function getCellList()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ // Get a new id for the new table name
+ $tableName = str_replace('.','_',$this->_getUniqueID());
+ if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
+ AS SELECT * FROM kvp_'.$this->_TableName))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+
+ // Copy the existing cell cache file
+ $this->_TableName = $tableName;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+
+ // Close down the temporary cache file
+ $this->__destruct();
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
+ public function __construct(PHPExcel_Worksheet $parent) {
+ parent::__construct($parent);
+ if (is_null($this->_DBHandle)) {
+ $this->_TableName = str_replace('.','_',$this->_getUniqueID());
+ $_DBName = ':memory:';
+
+ $this->_DBHandle = new SQLiteDatabase($_DBName);
+ if ($this->_DBHandle === false)
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
+ throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ $this->_DBHandle = null;
+ } // function __destruct()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('sqlite_open')) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite3.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite3.php
new file mode 100644
index 00000000000..ead6e91f87f
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/SQLite3.php
@@ -0,0 +1,277 @@
+_currentCellIsDirty) {
+ $this->_currentObject->detach();
+
+ $query = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
+ $query->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
+ $query->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
+ $result = $query->execute();
+ if ($result === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ $this->_currentCellIsDirty = false;
+ }
+ $this->_currentObjectID = $this->_currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
+ $this->_storeData();
+ }
+
+ $this->_currentObjectID = $pCoord;
+ $this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return $this->_currentObject;
+ }
+ $this->_storeData();
+
+ $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResult = $this->_DBHandle->querySingle($query);
+ if ($cellResult === false) {
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ } elseif (is_null($cellResult)) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->_currentObjectID = $pCoord;
+
+ $this->_currentObject = unserialize($cellResult);
+ // Re-attach the parent worksheet
+ $this->_currentObject->attach($this->_parent);
+
+ // Return requested entry
+ return $this->_currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Is a value set for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ return true;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $cellResult = $this->_DBHandle->querySingle($query);
+ if ($cellResult === false) {
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ } elseif (is_null($cellResult)) {
+ // Return null if requested entry doesn't exist in cache
+ return false;
+ }
+ return true;
+ } // function isDataSet()
+
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
+ */
+ public function deleteCacheData($pCoord) {
+ if ($pCoord === $this->_currentObjectID) {
+ $this->_currentObject->detach();
+ $this->_currentObjectID = $this->_currentObject = null;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
+ $result = $this->_DBHandle->exec($query);
+ if ($result === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+
+ $this->_currentCellIsDirty = false;
+ } // function deleteCacheData()
+
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return array of string
+ */
+ public function getCellList() {
+ $query = "SELECT id FROM kvp_".$this->_TableName;
+ $cellIdsResult = $this->_DBHandle->query($query);
+ if ($cellIdsResult === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+
+ $cellKeys = array();
+ while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
+ $cellKeys[] = $row['id'];
+ }
+
+ return $cellKeys;
+ } // function getCellList()
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ // Get a new id for the new table name
+ $tableName = str_replace('.','_',$this->_getUniqueID());
+ if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
+ AS SELECT * FROM kvp_'.$this->_TableName))
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+
+ // Copy the existing cell cache file
+ $this->_TableName = $tableName;
+ } // function copyCellCollection()
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells() {
+ if(!is_null($this->_currentObject)) {
+ $this->_currentObject->detach();
+ $this->_currentObject = $this->_currentObjectID = null;
+ }
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->_parent = null;
+
+ // Close down the temporary cache file
+ $this->__destruct();
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
+ public function __construct(PHPExcel_Worksheet $parent) {
+ parent::__construct($parent);
+ if (is_null($this->_DBHandle)) {
+ $this->_TableName = str_replace('.','_',$this->_getUniqueID());
+ $_DBName = ':memory:';
+
+ $this->_DBHandle = new SQLite3($_DBName);
+ if ($this->_DBHandle === false)
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
+ throw new Exception($this->_DBHandle->lastErrorMsg());
+ }
+ } // function __construct()
+
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct() {
+ if (!is_null($this->_DBHandle)) {
+ $this->_DBHandle->close();
+ }
+ $this->_DBHandle = null;
+ } // function __destruct()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!class_exists('SQLite3',FALSE)) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php
index a223a516e3a..ba8b0458062 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorage/Wincache.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,29 +31,49 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
+ /**
+ * Prefix used to uniquely identify cache data for this worksheet
+ *
+ * @var string
+ */
private $_cachePrefix = null;
+ /**
+ * Cache timeout
+ *
+ * @var integer
+ */
private $_cacheTime = 600;
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws Exception
+ */
private function _storeData() {
- $this->_currentObject->detach();
+ if ($this->_currentCellIsDirty) {
+ $this->_currentObject->detach();
- $obj = serialize($this->_currentObject);
- if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
- if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
- $this->__destruct();
- throw new Exception('Failed to store cell '.$cellID.' in WinCache');
- }
- } else {
- if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
- $this->__destruct();
- throw new Exception('Failed to store cell '.$cellID.' in WinCache');
+ $obj = serialize($this->_currentObject);
+ if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
+ if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
+ }
+ } else {
+ if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
+ $this->__destruct();
+ throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
+ }
}
+ $this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
@@ -61,12 +81,12 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/**
- * Add or Update a cell in cache identified by coordinate address
+ * Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return void
+ * @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -76,17 +96,17 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
+ $this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
- * @param string $pCoord Coordinate address of the cell to check
- * @return void
- * @return boolean
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
@@ -99,7 +119,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord);
- throw new Exception('Cell entry '.$cellID.' no longer exists in WinCache');
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
return true;
}
@@ -128,7 +148,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($pCoord);
- throw new Exception('Cell entry '.$cellID.' no longer exists in WinCache');
+ throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
} else {
// Return null if requested entry doesn't exist in cache
@@ -147,10 +167,10 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/**
- * Delete a cell in cache identified by coordinate address
+ * Delete a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to delete
- * @throws Exception
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from Wincache
@@ -162,9 +182,10 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/**
- * Clone the cell collection
+ * Clone the cell collection
*
- * @return void
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
@@ -191,6 +212,11 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
} // function copyCellCollection()
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
@@ -207,6 +233,12 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
} // function unsetWorksheetCells()
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
@@ -220,6 +252,9 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
} // function __construct()
+ /**
+ * Destroy this cell collection
+ */
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
@@ -227,4 +262,19 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
}
} // function __destruct()
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable() {
+ if (!function_exists('wincache_ucache_add')) {
+ return false;
+ }
+
+ return true;
+ }
+
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php
index 1486ad11a94..51019f7bdc5 100644
--- a/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php
+++ b/htdocs/includes/phpexcel/PHPExcel/CachedObjectStorageFactory.php
@@ -1,33 +1,94 @@
array(
),
@@ -35,9 +96,11 @@ class PHPExcel_CachedObjectStorageFactory {
),
self::cache_in_memory_serialized => array(
),
+ self::cache_igbinary => array(
+ ),
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
),
- self::cache_to_discISAM => array(
+ self::cache_to_discISAM => array( 'dir' => NULL
),
self::cache_to_apc => array( 'cacheTime' => 600
),
@@ -46,58 +109,91 @@ class PHPExcel_CachedObjectStorageFactory {
'cacheTime' => 600
),
self::cache_to_wincache => array( 'cacheTime' => 600
- )
+ ),
+ self::cache_to_sqlite => array(
+ ),
+ self::cache_to_sqlite3 => array(
+ ),
);
+ /**
+ * Arguments for the active cache storage method
+ *
+ * @var array of mixed array
+ */
private static $_storageMethodParameters = array();
- public static function getCacheStorageMethod() {
- if (!is_null(self::$_cacheStorageMethod)) {
- return self::$_cacheStorageMethod;
- }
- return null;
+ /**
+ * Return the current cache storage method
+ *
+ * @return string|NULL
+ **/
+ public static function getCacheStorageMethod()
+ {
+ return self::$_cacheStorageMethod;
} // function getCacheStorageMethod()
- public static function getCacheStorageClass() {
- if (!is_null(self::$_cacheStorageClass)) {
- return self::$_cacheStorageClass;
- }
- return null;
+ /**
+ * Return the current cache storage class
+ *
+ * @return PHPExcel_CachedObjectStorage_ICache|NULL
+ **/
+ public static function getCacheStorageClass()
+ {
+ return self::$_cacheStorageClass;
} // function getCacheStorageClass()
- public static function getCacheStorageMethods() {
+ /**
+ * Return the list of all possible cache storage methods
+ *
+ * @return string[]
+ **/
+ public static function getAllCacheStorageMethods()
+ {
return self::$_storageMethods;
} // function getCacheStorageMethods()
- public static function initialize($method = self::cache_in_memory, $arguments = array()) {
+ /**
+ * Return the list of all available cache storage methods
+ *
+ * @return string[]
+ **/
+ public static function getCacheStorageMethods()
+ {
+ $activeMethods = array();
+ foreach(self::$_storageMethods as $storageMethod) {
+ $cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
+ if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
+ $activeMethods[] = $storageMethod;
+ }
+ }
+ return $activeMethods;
+ } // function getCacheStorageMethods()
+
+
+ /**
+ * Identify the cache storage method to use
+ *
+ * @param string $method Name of the method to use for cell cacheing
+ * @param array of mixed $arguments Additional arguments to pass to the cell caching class
+ * when instantiating
+ * @return boolean
+ **/
+ public static function initialize($method = self::cache_in_memory, $arguments = array())
+ {
if (!in_array($method,self::$_storageMethods)) {
- return false;
+ return FALSE;
}
- switch($method) {
- case self::cache_to_apc :
- if (!function_exists('apc_store')) {
- return false;
- }
- if (apc_sma_info() === false) {
- return false;
- }
- break;
- case self::cache_to_memcache :
- if (!function_exists('memcache_add')) {
- return false;
- }
- break;
- case self::cache_to_wincache :
- if (!function_exists('wincache_ucache_add')) {
- return false;
- }
- break;
+ $cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
+ if (!call_user_func(array( $cacheStorageClass,
+ 'cacheMethodIsAvailable'))) {
+ return FALSE;
}
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
@@ -107,25 +203,37 @@ class PHPExcel_CachedObjectStorageFactory {
}
}
- if (is_null(self::$_cacheStorageMethod)) {
- self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
+ if (self::$_cacheStorageMethod === NULL) {
+ self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
self::$_cacheStorageMethod = $method;
}
- return true;
+ return TRUE;
} // function initialize()
- public static function getInstance(PHPExcel_Worksheet $parent) {
- if (is_null(self::$_cacheStorageMethod)) {
- self::initialize();
+ /**
+ * Initialise the cache storage
+ *
+ * @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
+ * @return PHPExcel_CachedObjectStorage_ICache
+ **/
+ public static function getInstance(PHPExcel_Worksheet $parent)
+ {
+ $cacheMethodIsAvailable = TRUE;
+ if (self::$_cacheStorageMethod === NULL) {
+ $cacheMethodIsAvailable = self::initialize();
}
- $instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
- if (!is_null($instance)) {
- return $instance;
+ if ($cacheMethodIsAvailable) {
+ $instance = new self::$_cacheStorageClass( $parent,
+ self::$_storageMethodParameters[self::$_cacheStorageMethod]
+ );
+ if ($instance !== NULL) {
+ return $instance;
+ }
}
- return false;
+ return FALSE;
} // function getInstance()
}
\ No newline at end of file
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation.php b/htdocs/includes/phpexcel/PHPExcel/Calculation.php
index 0833129cfbb..65d4f3d1027 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -57,12 +57,12 @@ if (!defined('CALCULATION_REGEXP_CELLREF')) {
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation {
- /** Constants */
- /** Regular Expressions */
+ /** Constants */
+ /** Regular Expressions */
// Numeric operand
const CALCULATION_REGEXP_NUMBER = '[-+]?\d*\.?\d+(e[-+]?\d+)?';
// String operand
@@ -79,7 +79,7 @@ class PHPExcel_Calculation {
const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?';
- /** constants */
+ /** constants */
const RETURN_ARRAY_AS_ERROR = 'error';
const RETURN_ARRAY_AS_VALUE = 'value';
const RETURN_ARRAY_AS_ARRAY = 'array';
@@ -88,47 +88,47 @@ class PHPExcel_Calculation {
/**
- * Instance of this class
+ * Instance of this class
*
- * @access private
- * @var PHPExcel_Calculation
+ * @access private
+ * @var PHPExcel_Calculation
*/
private static $_instance;
/**
- * Calculation cache
+ * Calculation cache
*
- * @access private
- * @var array
+ * @access private
+ * @var array
*/
private static $_calculationCache = array ();
/**
- * Calculation cache enabled
+ * Calculation cache enabled
*
- * @access private
- * @var boolean
+ * @access private
+ * @var boolean
*/
private static $_calculationCacheEnabled = true;
/**
- * Calculation cache expiration time
+ * Calculation cache expiration time
*
- * @access private
- * @var float
+ * @access private
+ * @var float
*/
private static $_calculationCacheExpirationTime = 15;
/**
- * List of operators that can be used within formulae
- * The true/false value indicates whether it is a binary operator or a unary operator
+ * List of operators that can be used within formulae
+ * The true/false value indicates whether it is a binary operator or a unary operator
*
- * @access private
- * @var array
+ * @access private
+ * @var array
*/
private static $_operators = array('+' => true, '-' => true, '*' => true, '/' => true,
'^' => true, '&' => true, '%' => false, '~' => false,
@@ -138,10 +138,10 @@ class PHPExcel_Calculation {
/**
- * List of binary operators (those that expect two operands)
+ * List of binary operators (those that expect two operands)
*
- * @access private
- * @var array
+ * @access private
+ * @var array
*/
private static $_binaryOperators = array('+' => true, '-' => true, '*' => true, '/' => true,
'^' => true, '&' => true, '>' => true, '<' => true,
@@ -150,63 +150,63 @@ class PHPExcel_Calculation {
);
/**
- * Flag to determine how formula errors should be handled
+ * Flag to determine how formula errors should be handled
* If true, then a user error will be triggered
* If false, then an exception will be thrown
*
- * @access public
- * @var boolean
+ * @access public
+ * @var boolean
*
*/
public $suppressFormulaErrors = false;
/**
- * Error message for any error that was raised/thrown by the calculation engine
+ * Error message for any error that was raised/thrown by the calculation engine
*
- * @access public
- * @var string
+ * @access public
+ * @var string
*
*/
public $formulaError = null;
/**
- * Flag to determine whether a debug log should be generated by the calculation engine
+ * Flag to determine whether a debug log should be generated by the calculation engine
* If true, then a debug log will be generated
* If false, then a debug log will not be generated
*
- * @access public
- * @var boolean
+ * @access public
+ * @var boolean
*
*/
public $writeDebugLog = false;
/**
- * Flag to determine whether a debug log should be echoed by the calculation engine
+ * Flag to determine whether a debug log should be echoed by the calculation engine
* If true, then a debug log will be echoed
* If false, then a debug log will not be echoed
- * A debug log can only be echoed if it is generated
+ * A debug log can only be echoed if it is generated
*
- * @access public
- * @var boolean
+ * @access public
+ * @var boolean
*
*/
public $echoDebugLog = false;
/**
- * An array of the nested cell references accessed by the calculation engine, used for the debug log
+ * An array of the nested cell references accessed by the calculation engine, used for the debug log
*
- * @access private
- * @var array of string
+ * @access private
+ * @var array of string
*
*/
private $debugLogStack = array();
/**
- * The debug log generated by the calculation engine
+ * The debug log generated by the calculation engine
*
- * @access public
- * @var array of string
+ * @access public
+ * @var array of string
*
*/
public $debugLog = array();
@@ -543,7 +543,7 @@ class PHPExcel_Calculation {
'argumentCount' => '1'
),
'DAVERAGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Database::DAVERAGE',
'argumentCount' => '3'
),
'DAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
@@ -1698,17 +1698,19 @@ class PHPExcel_Calculation {
public function __destruct() {
- ini_set('precision',$this->_savedPrecision);
+ if ($this->_savedPrecision != ini_get('precision')) {
+ ini_set('precision',$this->_savedPrecision);
+ }
}
/**
- * Get an instance of this class
+ * Get an instance of this class
*
- * @access public
- * @return PHPExcel_Calculation
+ * @access public
+ * @return PHPExcel_Calculation
*/
public static function getInstance() {
- if (!isset(self::$_instance) || is_null(self::$_instance)) {
+ if (!isset(self::$_instance) || (self::$_instance === NULL)) {
self::$_instance = new PHPExcel_Calculation();
}
@@ -1717,24 +1719,24 @@ class PHPExcel_Calculation {
/**
- * Flush the calculation cache for any existing instance of this class
+ * Flush the calculation cache for any existing instance of this class
* but only if a PHPExcel_Calculation instance exists
*
- * @access public
- * @return null
+ * @access public
+ * @return null
*/
public static function flushInstance() {
- if (isset(self::$_instance) && !is_null(self::$_instance)) {
+ if (isset(self::$_instance) && (self::$_instance !== NULL)) {
self::$_instance->clearCalculationCache();
}
} // function flushInstance()
/**
- * __clone implementation. Cloning should not be allowed in a Singleton!
+ * __clone implementation. Cloning should not be allowed in a Singleton!
*
- * @access public
- * @throws Exception
+ * @access public
+ * @throws Exception
*/
public final function __clone() {
throw new Exception ('Cloning a Singleton is not allowed!');
@@ -1742,31 +1744,31 @@ class PHPExcel_Calculation {
/**
- * Return the locale-specific translation of TRUE
+ * Return the locale-specific translation of TRUE
*
- * @access public
- * @return string locale-specific translation of TRUE
+ * @access public
+ * @return string locale-specific translation of TRUE
*/
public static function getTRUE() {
return self::$_localeBoolean['TRUE'];
}
/**
- * Return the locale-specific translation of FALSE
+ * Return the locale-specific translation of FALSE
*
- * @access public
- * @return string locale-specific translation of FALSE
+ * @access public
+ * @return string locale-specific translation of FALSE
*/
public static function getFALSE() {
return self::$_localeBoolean['FALSE'];
}
/**
- * Set the Array Return Type (Array or Value of first element in the array)
+ * Set the Array Return Type (Array or Value of first element in the array)
*
- * @access public
- * @param string $returnType Array return type
- * @return boolean Success or failure
+ * @access public
+ * @param string $returnType Array return type
+ * @return boolean Success or failure
*/
public static function setArrayReturnType($returnType) {
if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||
@@ -1780,10 +1782,10 @@ class PHPExcel_Calculation {
/**
- * Return the Array Return Type (Array or Value of first element in the array)
+ * Return the Array Return Type (Array or Value of first element in the array)
*
- * @access public
- * @return string $returnType Array return type
+ * @access public
+ * @return string $returnType Array return type
*/
public static function getArrayReturnType() {
return self::$returnArrayAsType;
@@ -1791,10 +1793,10 @@ class PHPExcel_Calculation {
/**
- * Is calculation caching enabled?
+ * Is calculation caching enabled?
*
- * @access public
- * @return boolean
+ * @access public
+ * @return boolean
*/
public function getCalculationCacheEnabled() {
return self::$_calculationCacheEnabled;
@@ -1802,10 +1804,10 @@ class PHPExcel_Calculation {
/**
- * Enable/disable calculation cache
+ * Enable/disable calculation cache
*
- * @access public
- * @param boolean $pValue
+ * @access public
+ * @param boolean $pValue
*/
public function setCalculationCacheEnabled($pValue = true) {
self::$_calculationCacheEnabled = $pValue;
@@ -1814,7 +1816,7 @@ class PHPExcel_Calculation {
/**
- * Enable calculation cache
+ * Enable calculation cache
*/
public function enableCalculationCache() {
$this->setCalculationCacheEnabled(true);
@@ -1822,7 +1824,7 @@ class PHPExcel_Calculation {
/**
- * Disable calculation cache
+ * Disable calculation cache
*/
public function disableCalculationCache() {
$this->setCalculationCacheEnabled(false);
@@ -1830,7 +1832,7 @@ class PHPExcel_Calculation {
/**
- * Clear calculation cache
+ * Clear calculation cache
*/
public function clearCalculationCache() {
self::$_calculationCache = array();
@@ -1838,9 +1840,9 @@ class PHPExcel_Calculation {
/**
- * Get calculation cache expiration time
+ * Get calculation cache expiration time
*
- * @return float
+ * @return float
*/
public function getCalculationCacheExpirationTime() {
return self::$_calculationCacheExpirationTime;
@@ -1848,9 +1850,9 @@ class PHPExcel_Calculation {
/**
- * Set calculation cache expiration time
+ * Set calculation cache expiration time
*
- * @param float $pValue
+ * @param float $pValue
*/
public function setCalculationCacheExpirationTime($pValue = 15) {
self::$_calculationCacheExpirationTime = $pValue;
@@ -1860,9 +1862,9 @@ class PHPExcel_Calculation {
/**
- * Get the currently defined locale code
+ * Get the currently defined locale code
*
- * @return string
+ * @return string
*/
public function getLocale() {
return self::$_localeLanguage;
@@ -1870,9 +1872,9 @@ class PHPExcel_Calculation {
/**
- * Set the locale code
+ * Set the locale code
*
- * @return boolean
+ * @return boolean
*/
public function setLocale($locale='en_us') {
// Identify our locale and language
@@ -1890,10 +1892,10 @@ class PHPExcel_Calculation {
// Default is English, if user isn't requesting english, then read the necessary data from the locale files
if ($locale != 'en_us') {
// Search for a file with a list of function names for locale
- $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.str_replace('_','/',$locale).'/functions';
+ $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'functions';
if (!file_exists($functionNamesFile)) {
// If there isn't a locale specific function file, look for a language specific function file
- $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.$language.'/functions';
+ $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions';
if (!file_exists($functionNamesFile)) {
return false;
}
@@ -1915,9 +1917,9 @@ class PHPExcel_Calculation {
if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; }
if (isset(self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; }
- $configFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.str_replace('_','/',$locale).'/config';
+ $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'config';
if (!file_exists($configFile)) {
- $configFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.$language.'/config';
+ $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config';
}
if (file_exists($configFile)) {
$localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
@@ -1998,7 +2000,7 @@ class PHPExcel_Calculation {
private static $functionReplaceToLocale = null;
public function _translateFormulaToLocale($formula) {
- if (is_null(self::$functionReplaceFromExcel)) {
+ if (self::$functionReplaceFromExcel === NULL) {
self::$functionReplaceFromExcel = array();
foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
@@ -2009,7 +2011,7 @@ class PHPExcel_Calculation {
}
- if (is_null(self::$functionReplaceToLocale)) {
+ if (self::$functionReplaceToLocale === NULL) {
self::$functionReplaceToLocale = array();
foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
@@ -2027,7 +2029,7 @@ class PHPExcel_Calculation {
private static $functionReplaceToExcel = null;
public function _translateFormulaToEnglish($formula) {
- if (is_null(self::$functionReplaceFromLocale)) {
+ if (self::$functionReplaceFromLocale === NULL) {
self::$functionReplaceFromLocale = array();
foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
@@ -2037,7 +2039,7 @@ class PHPExcel_Calculation {
}
}
- if (is_null(self::$functionReplaceToExcel)) {
+ if (self::$functionReplaceToExcel === NULL) {
self::$functionReplaceToExcel = array();
foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
@@ -2067,10 +2069,10 @@ class PHPExcel_Calculation {
/**
- * Wrap string values in quotes
+ * Wrap string values in quotes
*
- * @param mixed $value
- * @return mixed
+ * @param mixed $value
+ * @return mixed
*/
public static function _wrapResult($value) {
if (is_string($value)) {
@@ -2091,10 +2093,10 @@ class PHPExcel_Calculation {
/**
- * Remove quotes used as a wrapper to identify string values
+ * Remove quotes used as a wrapper to identify string values
*
- * @param mixed $value
- * @return mixed
+ * @param mixed $value
+ * @return mixed
*/
public static function _unwrapResult($value) {
if (is_string($value)) {
@@ -2112,13 +2114,13 @@ class PHPExcel_Calculation {
/**
- * Calculate cell value (using formula from a cell ID)
- * Retained for backward compatibility
+ * Calculate cell value (using formula from a cell ID)
+ * Retained for backward compatibility
*
- * @access public
- * @param PHPExcel_Cell $pCell Cell to calculate
- * @return mixed
- * @throws Exception
+ * @access public
+ * @param PHPExcel_Cell $pCell Cell to calculate
+ * @return mixed
+ * @throws Exception
*/
public function calculate(PHPExcel_Cell $pCell = null) {
try {
@@ -2130,13 +2132,13 @@ class PHPExcel_Calculation {
/**
- * Calculate the value of a cell formula
+ * Calculate the value of a cell formula
*
- * @access public
- * @param PHPExcel_Cell $pCell Cell to calculate
- * @param Boolean $resetLog Flag indicating whether the debug log should be reset or not
- * @return mixed
- * @throws Exception
+ * @access public
+ * @param PHPExcel_Cell $pCell Cell to calculate
+ * @param Boolean $resetLog Flag indicating whether the debug log should be reset or not
+ * @return mixed
+ * @throws Exception
*/
public function calculateCellValue(PHPExcel_Cell $pCell = null, $resetLog = true) {
if ($resetLog) {
@@ -2150,8 +2152,8 @@ class PHPExcel_Calculation {
}
// Read the formula from the cell
- if (is_null($pCell)) {
- return null;
+ if ($pCell === NULL) {
+ return NULL;
}
if ($resetLog) {
@@ -2186,7 +2188,7 @@ class PHPExcel_Calculation {
$result = array_shift($testResult);
}
- if (is_null($result)) {
+ if ($result === NULL) {
return 0;
} elseif((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
return PHPExcel_Calculation_Functions::NaN();
@@ -2196,11 +2198,11 @@ class PHPExcel_Calculation {
/**
- * Validate and parse a formula string
+ * Validate and parse a formula string
*
- * @param string $formula Formula to parse
- * @return array
- * @throws Exception
+ * @param string $formula Formula to parse
+ * @return array
+ * @throws Exception
*/
public function parseFormula($formula) {
// Basic validation that this is indeed a formula
@@ -2216,11 +2218,11 @@ class PHPExcel_Calculation {
/**
- * Calculate the value of a formula
+ * Calculate the value of a formula
*
- * @param string $formula Formula to parse
- * @return mixed
- * @throws Exception
+ * @param string $formula Formula to parse
+ * @return mixed
+ * @throws Exception
*/
public function calculateFormula($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
// Initialise the logging settings
@@ -2246,13 +2248,13 @@ class PHPExcel_Calculation {
/**
- * Parse a cell formula and calculate its value
+ * Parse a cell formula and calculate its value
*
- * @param string $formula The formula to parse and calculate
- * @param string $cellID The ID (e.g. A3) of the cell that we are calculating
- * @param PHPExcel_Cell $pCell Cell to calculate
- * @return mixed
- * @throws Exception
+ * @param string $formula The formula to parse and calculate
+ * @param string $cellID The ID (e.g. A3) of the cell that we are calculating
+ * @param PHPExcel_Cell $pCell Cell to calculate
+ * @return mixed
+ * @throws Exception
*/
public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
// echo ''.$cellID.' ';
@@ -2266,14 +2268,14 @@ class PHPExcel_Calculation {
if (!isset($formula{0})) return self::_wrapResult($formula);
$wsTitle = "\x00Wrk";
- if (!is_null($pCell)) {
+ if ($pCell !== NULL) {
$pCellParent = $pCell->getParent();
- if (!is_null($pCellParent)) {
+ if ($pCellParent !== NULL) {
$wsTitle = $pCellParent->getTitle();
}
}
// Is calculation cacheing enabled?
- if (!is_null($cellID)) {
+ if ($cellID !== NULL) {
if (self::$_calculationCacheEnabled) {
// Is the value present in calculation cache?
// echo 'Testing cache value ';
@@ -2326,7 +2328,7 @@ class PHPExcel_Calculation {
array_pop($this->debugLogStack);
// Save to calculation cache
- if (!is_null($cellID)) {
+ if ($cellID !== NULL) {
if (self::$_calculationCacheEnabled) {
self::$_calculationCache[$wsTitle][$cellID]['time'] = microtime(true);
self::$_calculationCache[$wsTitle][$cellID]['data'] = $cellValue;
@@ -2339,11 +2341,11 @@ class PHPExcel_Calculation {
/**
- * Ensure that paired matrix operands are both matrices and of the same size
+ * Ensure that paired matrix operands are both matrices and of the same size
*
- * @param mixed &$operand1 First matrix operand
- * @param mixed &$operand2 Second matrix operand
- * @param integer $resize Flag indicating whether the matrices should be resized to match
+ * @param mixed &$operand1 First matrix operand
+ * @param mixed &$operand2 Second matrix operand
+ * @param integer $resize Flag indicating whether the matrices should be resized to match
* and (if so), whether the smaller dimension should grow or the
* larger should shrink.
* 0 = no resize
@@ -2381,10 +2383,10 @@ class PHPExcel_Calculation {
/**
- * Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0
+ * Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0
*
- * @param mixed &$matrix matrix operand
- * @return array An array comprising the number of rows, and number of columns
+ * @param mixed &$matrix matrix operand
+ * @return array An array comprising the number of rows, and number of columns
*/
public static function _getMatrixDimensions(&$matrix) {
$matrixRows = count($matrix);
@@ -2403,10 +2405,10 @@ class PHPExcel_Calculation {
/**
- * Ensure that paired matrix operands are both matrices of the same size
+ * Ensure that paired matrix operands are both matrices of the same size
*
- * @param mixed &$matrix1 First matrix operand
- * @param mixed &$matrix2 Second matrix operand
+ * @param mixed &$matrix1 First matrix operand
+ * @param mixed &$matrix2 Second matrix operand
*/
private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
@@ -2442,10 +2444,10 @@ class PHPExcel_Calculation {
/**
- * Ensure that paired matrix operands are both matrices of the same size
+ * Ensure that paired matrix operands are both matrices of the same size
*
- * @param mixed &$matrix1 First matrix operand
- * @param mixed &$matrix2 Second matrix operand
+ * @param mixed &$matrix1 First matrix operand
+ * @param mixed &$matrix2 Second matrix operand
*/
private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
@@ -2485,10 +2487,10 @@ class PHPExcel_Calculation {
/**
- * Format details of an operand for display in the log (based on operand type)
+ * Format details of an operand for display in the log (based on operand type)
*
- * @param mixed $value First matrix operand
- * @return mixed
+ * @param mixed $value First matrix operand
+ * @return mixed
*/
private function _showValue($value) {
if ($this->writeDebugLog) {
@@ -2502,26 +2504,28 @@ class PHPExcel_Calculation {
$pad = $rpad = ', ';
foreach($value as $row) {
if (is_array($row)) {
- $returnMatrix[] = implode($pad,$row);
+ $returnMatrix[] = implode($pad,array_map(array($this,'_showValue'),$row));
$rpad = '; ';
} else {
- $returnMatrix[] = $row;
+ $returnMatrix[] = $this->_showValue($row);
}
}
return '{ '.implode($rpad,$returnMatrix).' }';
+ } elseif(is_string($value) && (trim($value,'"') == $value)) {
+ return '"'.$value.'"';
} elseif(is_bool($value)) {
return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
}
}
- return $value;
+ return PHPExcel_Calculation_Functions::flattenSingleValue($value);
} // function _showValue()
/**
- * Format type and details of an operand for display in the log (based on operand type)
+ * Format type and details of an operand for display in the log (based on operand type)
*
- * @param mixed $value First matrix operand
- * @return mixed
+ * @param mixed $value First matrix operand
+ * @return mixed
*/
private function _showTypeDetails($value) {
if ($this->writeDebugLog) {
@@ -2530,8 +2534,8 @@ class PHPExcel_Calculation {
$value = array_pop($testArray);
}
- if (is_null($value)) {
- return 'a null value';
+ if ($value === NULL) {
+ return 'a NULL value';
} elseif (is_float($value)) {
$typeString = 'a floating point number';
} elseif(is_int($value)) {
@@ -2613,12 +2617,12 @@ class PHPExcel_Calculation {
// Convert infix to postfix notation
private function _parseFormula($formula, PHPExcel_Cell $pCell = null) {
if (($formula = self::_convertMatrixReferences(trim($formula))) === false) {
- return false;
+ return FALSE;
}
// If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet),
// so we store the parent worksheet so that we can re-attach it when necessary
- $pCellParent = (!is_null($pCell)) ? $pCell->getParent() : null;
+ $pCellParent = ($pCell !== NULL) ? $pCell->getParent() : NULL;
// Binary Operators
// These operators always work on two values
@@ -2659,7 +2663,7 @@ class PHPExcel_Calculation {
// Start with initialisation
$index = 0;
- $stack = new PHPExcel_Token_Stack;
+ $stack = new PHPExcel_Calculation_Token_Stack;
$output = array();
$expectingOperator = false; // We use this test in syntax-checking the expression to determine when a
// - is a negation or + is a positive operator rather than an operation
@@ -2711,7 +2715,7 @@ class PHPExcel_Calculation {
// echo 'Element is a Closing bracket ';
$expectingOperand = false;
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
- if (is_null($o2)) return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"');
+ if ($o2 === NULL) return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"');
else $output[] = $o2;
}
$d = $stack->last(2);
@@ -2790,7 +2794,7 @@ class PHPExcel_Calculation {
} elseif ($opCharacter == ',') { // Is this the separator for function arguments?
// echo 'Element is a Function argument separator ';
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
- if (is_null($o2)) return $this->_raiseFormulaError("Formula Error: Unexpected ,");
+ if ($o2 === NULL) return $this->_raiseFormulaError("Formula Error: Unexpected ,");
else $output[] = $o2; // pop the argument expression stuff and push onto the output
}
// If we've a comma when we're expecting an operand, then what we actually have is a null operand;
@@ -2828,10 +2832,10 @@ class PHPExcel_Calculation {
$stack->push('Function', strtoupper($val));
$ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
if ($ax) {
- $stack->push('Operand Count for Function '.self::_localeFunc(strtoupper($val)).')', 0);
+ $stack->push('Operand Count for Function '.strtoupper($val).')', 0);
$expectingOperator = true;
} else {
- $stack->push('Operand Count for Function '.self::_localeFunc(strtoupper($val)).')', 1);
+ $stack->push('Operand Count for Function '.strtoupper($val).')', 1);
$expectingOperator = false;
}
$stack->push('Brace', '(');
@@ -2881,13 +2885,13 @@ class PHPExcel_Calculation {
if ((is_integer($startRowColRef)) && (ctype_digit($val)) &&
($startRowColRef <= 1048576) && ($val <= 1048576)) {
// Row range
- $endRowColRef = (!is_null($pCellParent)) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
+ $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
$output[count($output)-1]['value'] = $rangeWS1.'A'.$startRowColRef;
$val = $rangeWS2.$endRowColRef.$val;
} elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
// Column range
- $endRowColRef = (!is_null($pCellParent)) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
+ $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
$output[count($output)-1]['value'] = $rangeWS1.strtoupper($startRowColRef).'1';
$val = $rangeWS2.$val.$endRowColRef;
}
@@ -2925,7 +2929,7 @@ class PHPExcel_Calculation {
++$index;
} elseif ($opCharacter == ')') { // miscellaneous error checking
if ($expectingOperand) {
- $output[] = array('type' => 'Null Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
+ $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
$expectingOperand = false;
$expectingOperator = true;
} else {
@@ -2972,22 +2976,38 @@ class PHPExcel_Calculation {
}
}
- while (!is_null($op = $stack->pop())) { // pop everything off the stack and push onto output
- if ($opCharacter['value'] == '(') return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced
+ while (($op = $stack->pop()) !== NULL) { // pop everything off the stack and push onto output
+ if ((is_array($opCharacter) && $opCharacter['value'] == '(') || ($opCharacter === '('))
+ return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced
$output[] = $op;
}
return $output;
} // function _parseFormula()
+ private static function _dataTestReference(&$operandData)
+ {
+ $operand = $operandData['value'];
+ if (($operandData['reference'] === NULL) && (is_array($operand))) {
+ $rKeys = array_keys($operand);
+ $rowKey = array_shift($rKeys);
+ $cKeys = array_keys(array_keys($operand[$rowKey]));
+ $colKey = array_shift($cKeys);
+ if (ctype_upper($colKey)) {
+ $operandData['reference'] = $colKey.$rowKey;
+ }
+ }
+ return $operand;
+ }
+
// evaluate postfix notation
private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) {
if ($tokens == false) return false;
// If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet),
// so we store the parent worksheet so that we can re-attach it when necessary
- $pCellParent = (!is_null($pCell)) ? $pCell->getParent() : null;
- $stack = new PHPExcel_Token_Stack;
+ $pCellParent = ($pCell !== NULL) ? $pCell->getParent() : null;
+ $stack = new PHPExcel_Calculation_Token_Stack;
// Loop through each token in turn
foreach ($tokens as $tokenData) {
@@ -2999,16 +3019,19 @@ class PHPExcel_Calculation {
if (isset(self::$_binaryOperators[$token])) {
// echo 'Token is a binary operator ';
// We must have two operands, error if we don't
- if (is_null($operand2Data = $stack->pop())) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
- if (is_null($operand1Data = $stack->pop())) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ if (($operand2Data = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ if (($operand1Data = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+
+ $operand1 = self::_dataTestReference($operand1Data);
+ $operand2 = self::_dataTestReference($operand2Data);
+
// Log what we're doing
- $operand1 = $operand1Data['value'];
- $operand2 = $operand2Data['value'];
if ($token == ':') {
$this->_writeDebug('Evaluating Range '.$this->_showValue($operand1Data['reference']).$token.$this->_showValue($operand2Data['reference']));
} else {
$this->_writeDebug('Evaluating '.$this->_showValue($operand1).' '.$token.' '.$this->_showValue($operand2));
}
+
// Process the operation in the appropriate manner
switch ($token) {
// Comparison (Boolean) Operators
@@ -3026,7 +3049,7 @@ class PHPExcel_Calculation {
if (strpos($operand1Data['reference'],'!') !== false) {
list($sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']);
} else {
- $sheet1 = (!is_null($pCellParent)) ? $pCellParent->getTitle() : '';
+ $sheet1 = ($pCellParent !== NULL) ? $pCellParent->getTitle() : '';
}
if (strpos($operand2Data['reference'],'!') !== false) {
list($sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']);
@@ -3034,7 +3057,7 @@ class PHPExcel_Calculation {
$sheet2 = $sheet1;
}
if ($sheet1 == $sheet2) {
- if (is_null($operand1Data['reference'])) {
+ if ($operand1Data['reference'] === NULL) {
if ((trim($operand1Data['value']) != '') && (is_numeric($operand1Data['value']))) {
$operand1Data['reference'] = $pCell->getColumn().$operand1Data['value'];
} elseif (trim($operand1Data['reference']) == '') {
@@ -3043,7 +3066,7 @@ class PHPExcel_Calculation {
$operand1Data['reference'] = $operand1Data['value'].$pCell->getRow();
}
}
- if (is_null($operand2Data['reference'])) {
+ if ($operand2Data['reference'] === NULL) {
if ((trim($operand2Data['value']) != '') && (is_numeric($operand2Data['value']))) {
$operand2Data['reference'] = $pCell->getColumn().$operand2Data['value'];
} elseif (trim($operand2Data['reference']) == '') {
@@ -3061,7 +3084,7 @@ class PHPExcel_Calculation {
$oRow[] = $oCR[1];
}
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
- if (!is_null($pCellParent)) {
+ if ($pCellParent !== NULL) {
$cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($sheet1), false);
} else {
return $this->_raiseFormulaError('Unable to access Cell Reference');
@@ -3135,7 +3158,7 @@ class PHPExcel_Calculation {
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
} elseif (($token === '~') || ($token === '%')) {
// echo 'Token is a unary operator ';
- if (is_null($arg = $stack->pop())) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ if (($arg = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
$arg = $arg['value'];
if ($token === '~') {
// echo 'Token is a negation operator ';
@@ -3167,16 +3190,21 @@ class PHPExcel_Calculation {
// echo 'Element '.$token.' is a Cell reference ';
if (isset($matches[8])) {
// echo 'Reference is a Range of cells ';
- if (is_null($pCell)) {
+ if ($pCell === NULL) {
// We can't access the range, so return a REF error
$cellValue = PHPExcel_Calculation_Functions::REF();
} else {
$cellRef = $matches[6].$matches[7].':'.$matches[9].$matches[10];
if ($matches[2] > '') {
$matches[2] = trim($matches[2],"\"'");
+ if ((strpos($matches[2],'[') !== false) || (strpos($matches[2],']') !== false)) {
+ // It's a Reference to an external workbook (not currently supported)
+ return $this->_raiseFormulaError('Unable to access External Workbook');
+ }
+ $matches[2] = trim($matches[2],"\"'");
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].' ';
$this->_writeDebug('Evaluating Cell Range '.$cellRef.' in worksheet '.$matches[2]);
- if (!is_null($pCellParent)) {
+ if ($pCellParent !== NULL) {
$cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false);
} else {
return $this->_raiseFormulaError('Unable to access Cell Reference');
@@ -3186,7 +3214,7 @@ class PHPExcel_Calculation {
} else {
// echo '$cellRef='.$cellRef.' in current worksheet ';
$this->_writeDebug('Evaluating Cell Range '.$cellRef.' in current worksheet');
- if (!is_null($pCellParent)) {
+ if ($pCellParent !== NULL) {
$cellValue = $this->extractCellRange($cellRef, $pCellParent, false);
} else {
return $this->_raiseFormulaError('Unable to access Cell Reference');
@@ -3196,16 +3224,20 @@ class PHPExcel_Calculation {
}
} else {
// echo 'Reference is a single Cell ';
- if (is_null($pCell)) {
+ if ($pCell === NULL) {
// We can't access the cell, so return a REF error
$cellValue = PHPExcel_Calculation_Functions::REF();
} else {
$cellRef = $matches[6].$matches[7];
if ($matches[2] > '') {
$matches[2] = trim($matches[2],"\"'");
+ if ((strpos($matches[2],'[') !== false) || (strpos($matches[2],']') !== false)) {
+ // It's a Reference to an external workbook (not currently supported)
+ return $this->_raiseFormulaError('Unable to access External Workbook');
+ }
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].' ';
$this->_writeDebug('Evaluating Cell '.$cellRef.' in worksheet '.$matches[2]);
- if (!is_null($pCellParent)) {
+ if ($pCellParent !== NULL) {
if ($pCellParent->getParent()->getSheetByName($matches[2])->cellExists($cellRef)) {
$cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false);
$pCell->attach($pCellParent);
@@ -3260,7 +3292,7 @@ class PHPExcel_Calculation {
if (($passByReference) &&
(isset(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
- if (is_null($arg['reference'])) {
+ if ($arg['reference'] === NULL) {
$args[] = $cellID;
if ($functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($cellID); }
} else {
@@ -3337,7 +3369,7 @@ class PHPExcel_Calculation {
// echo 'Token is a PHPExcel constant: '.$excelConstant.' ';
$stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]);
$this->_writeDebug('Evaluating Constant '.$excelConstant.' as '.$this->_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
- } elseif ((is_numeric($token)) || (is_null($token)) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
+ } elseif ((is_numeric($token)) || ($token === NULL) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
// echo 'Token is a number, boolean, string, null or an Excel error ';
$stack->push('Value',$token);
// if the token is a named range, push the named range name onto the stack
@@ -3400,14 +3432,14 @@ class PHPExcel_Calculation {
$result = array();
if ((is_array($operand1)) && (!is_array($operand2))) {
foreach($operand1 as $x => $operandData) {
- $this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2));
+ $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2));
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack);
$r = $stack->pop();
$result[$x] = $r['value'];
}
} elseif ((!is_array($operand1)) && (is_array($operand2))) {
foreach($operand2 as $x => $operandData) {
- $this->_writeDebug('Evaluating '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData));
+ $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData));
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack);
$r = $stack->pop();
$result[$x] = $r['value'];
@@ -3415,14 +3447,14 @@ class PHPExcel_Calculation {
} else {
if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
foreach($operand1 as $x => $operandData) {
- $this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x]));
+ $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x]));
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,true);
$r = $stack->pop();
$result[$x] = $r['value'];
}
}
// Log the result details
- $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result));
+ $this->_writeDebug('Comparison Evaluation Result is '.$this->_showTypeDetails($result));
// And push the result onto the stack
$stack->push('Array',$result);
return true;
@@ -3562,6 +3594,7 @@ class PHPExcel_Calculation {
// trigger an error, but nicely, if need be
protected function _raiseFormulaError($errorMessage) {
$this->formulaError = $errorMessage;
+ $this->debugLogStack = array();
if (!$this->suppressFormulaErrors) throw new Exception($errorMessage);
trigger_error($errorMessage, E_USER_ERROR);
} // function _raiseFormulaError()
@@ -3580,7 +3613,7 @@ class PHPExcel_Calculation {
$returnValue = array ();
// echo 'extractCellRange('.$pRange.') ';
- if (!is_null($pSheet)) {
+ if ($pSheet !== NULL) {
// echo 'Passed sheet name is '.$pSheet->getTitle().' ';
// echo 'Range reference is '.$pRange.' ';
if (strpos ($pRange, '!') !== false) {
@@ -3636,7 +3669,7 @@ class PHPExcel_Calculation {
$returnValue = array ();
// echo 'extractNamedRange('.$pRange.') ';
- if (!is_null($pSheet)) {
+ if ($pSheet !== NULL) {
// echo 'Current sheet name is '.$pSheet->getTitle().' ';
// echo 'Range reference is '.$pRange.' ';
if (strpos ($pRange, '!') !== false) {
@@ -3650,7 +3683,7 @@ class PHPExcel_Calculation {
// Named range?
$namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
- if (!is_null($namedRange)) {
+ if ($namedRange !== NULL) {
$pSheet = $namedRange->getWorksheet();
// echo 'Named Range '.$pRange.' (';
$pRange = $namedRange->getRange();
@@ -3776,52 +3809,3 @@ class PHPExcel_Calculation {
} // class PHPExcel_Calculation
-
-
-
-// for internal use
-class PHPExcel_Token_Stack {
-
- private $_stack = array();
- private $_count = 0;
-
-
- public function count() {
- return $this->_count;
- } // function count()
-
-
- public function push($type,$value,$reference=null) {
- $this->_stack[$this->_count++] = array('type' => $type,
- 'value' => $value,
- 'reference' => $reference
- );
- if ($type == 'Function') {
- $localeFunction = PHPExcel_Calculation::_localeFunc($value);
- if ($localeFunction != $value) {
- $this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
- }
- }
- } // function push()
-
-
- public function pop() {
- if ($this->_count > 0) {
- return $this->_stack[--$this->_count];
- }
- return null;
- } // function pop()
-
-
- public function last($n=1) {
- if ($this->_count-$n < 0) {
- return null;
- }
- return $this->_stack[$this->_count-$n];
- } // function last()
-
-
- function __construct() {
- }
-
-} // class PHPExcel_Token_Stack
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php
index 8696d225b3a..4a6c8f72c9a 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Database.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,11 +41,29 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Database {
+ /**
+ * __fieldExtract
+ *
+ * Extracts the column ID to use for the data field.
+ *
+ * @access private
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param mixed $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @return string|NULL
+ *
+ */
private static function __fieldExtract($database,$field) {
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
$fieldNames = array_map('strtoupper',array_shift($database));
@@ -55,9 +73,28 @@ class PHPExcel_Calculation_Database {
return $keys[$field-1];
}
$key = array_search($field,$fieldNames);
- return ($key) ? $key : null;
+ return ($key) ? $key : NULL;
}
+ /**
+ * __filter
+ *
+ * Parses the selection criteria, extracts the database rows that match those criteria, and
+ * returns that subset of rows.
+ *
+ * @access private
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return array of mixed
+ *
+ */
private static function __filter($database,$criteria) {
$fieldNames = array_shift($database);
$criteriaNames = array_shift($criteria);
@@ -82,6 +119,7 @@ class PHPExcel_Calculation_Database {
$testConditionsCount++;
}
}
+
if ($testConditionsCount > 1) {
$testConditionSet = 'AND('.implode(',',$testConditions).')';
} elseif($testConditionsCount == 1) {
@@ -113,7 +151,30 @@ class PHPExcel_Calculation_Database {
/**
- * DAVERAGE
+ * DAVERAGE
+ *
+ * Averages the values in a column of a list or database that match conditions you specify.
+ *
+ * Excel Function:
+ * DAVERAGE(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DAVERAGE($database,$field,$criteria) {
@@ -121,7 +182,6 @@ class PHPExcel_Calculation_Database {
if (is_null($field)) {
return NULL;
}
-
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
@@ -134,8 +194,39 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::AVERAGE($colData);
} // function DAVERAGE()
+
/**
- * DCOUNT
+ * DCOUNT
+ *
+ * Counts the cells that contain numbers in a column of a list or database that match conditions
+ * that you specify.
+ *
+ * Excel Function:
+ * DCOUNT(database,[field],criteria)
+ *
+ * Excel Function:
+ * DAVERAGE(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return integer
+ *
+ * @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
+ * database that match the criteria.
*
*/
public static function DCOUNT($database,$field,$criteria) {
@@ -156,8 +247,35 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::COUNT($colData);
} // function DCOUNT()
+
/**
- * DCOUNTA
+ * DCOUNTA
+ *
+ * Counts the nonblank cells in a column of a list or database that match conditions that you specify.
+ *
+ * Excel Function:
+ * DCOUNTA(database,[field],criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return integer
+ *
+ * @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the
+ * database that match the criteria.
*
*/
public static function DCOUNTA($database,$field,$criteria) {
@@ -178,8 +296,33 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::COUNTA($colData);
} // function DCOUNTA()
+
/**
- * DGET
+ * DGET
+ *
+ * Extracts a single value from a column of a list or database that matches conditions that you
+ * specify.
+ *
+ * Excel Function:
+ * DGET(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return mixed
*
*/
public static function DGET($database,$field,$criteria) {
@@ -204,8 +347,33 @@ class PHPExcel_Calculation_Database {
return $colData[0];
} // function DGET()
+
/**
- * DMAX
+ * DMAX
+ *
+ * Returns the largest number in a column of a list or database that matches conditions you that
+ * specify.
+ *
+ * Excel Function:
+ * DMAX(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DMAX($database,$field,$criteria) {
@@ -226,8 +394,33 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::MAX($colData);
} // function DMAX()
+
/**
- * DMIN
+ * DMIN
+ *
+ * Returns the smallest number in a column of a list or database that matches conditions you that
+ * specify.
+ *
+ * Excel Function:
+ * DMIN(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DMIN($database,$field,$criteria) {
@@ -248,8 +441,32 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::MIN($colData);
} // function DMIN()
+
/**
- * DPRODUCT
+ * DPRODUCT
+ *
+ * Multiplies the values in a column of a list or database that match conditions that you specify.
+ *
+ * Excel Function:
+ * DPRODUCT(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DPRODUCT($database,$field,$criteria) {
@@ -270,8 +487,33 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_MathTrig::PRODUCT($colData);
} // function DPRODUCT()
+
/**
- * DSTDEV
+ * DSTDEV
+ *
+ * Estimates the standard deviation of a population based on a sample by using the numbers in a
+ * column of a list or database that match conditions that you specify.
+ *
+ * Excel Function:
+ * DSTDEV(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DSTDEV($database,$field,$criteria) {
@@ -292,8 +534,33 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::STDEV($colData);
} // function DSTDEV()
+
/**
- * DSTDEVP
+ * DSTDEVP
+ *
+ * Calculates the standard deviation of a population based on the entire population by using the
+ * numbers in a column of a list or database that match conditions that you specify.
+ *
+ * Excel Function:
+ * DSTDEVP(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DSTDEVP($database,$field,$criteria) {
@@ -314,8 +581,32 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::STDEVP($colData);
} // function DSTDEVP()
+
/**
- * DSUM
+ * DSUM
+ *
+ * Adds the numbers in a column of a list or database that match conditions that you specify.
+ *
+ * Excel Function:
+ * DSUM(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DSUM($database,$field,$criteria) {
@@ -336,8 +627,33 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_MathTrig::SUM($colData);
} // function DSUM()
+
/**
- * DVAR
+ * DVAR
+ *
+ * Estimates the variance of a population based on a sample by using the numbers in a column
+ * of a list or database that match conditions that you specify.
+ *
+ * Excel Function:
+ * DVAR(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DVAR($database,$field,$criteria) {
@@ -358,8 +674,33 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::VARFunc($colData);
} // function DVAR()
+
/**
- * DVARP
+ * DVARP
+ *
+ * Calculates the variance of a population based on the entire population by using the numbers
+ * in a column of a list or database that match conditions that you specify.
+ *
+ * Excel Function:
+ * DVARP(database,field,criteria)
+ *
+ * @access public
+ * @category Database Functions
+ * @param mixed[] $database The range of cells that makes up the list or database.
+ * A database is a list of related data in which rows of related
+ * information are records, and columns of data are fields. The
+ * first row of the list contains labels for each column.
+ * @param string|integer $field Indicates which column is used in the function. Enter the
+ * column label enclosed between double quotation marks, such as
+ * "Age" or "Yield," or a number (without quotation marks) that
+ * represents the position of the column within the list: 1 for
+ * the first column, 2 for the second column, and so on.
+ * @param mixed[] $criteria The range of cells that contains the conditions you specify.
+ * You can use any range for the criteria argument, as long as it
+ * includes at least one column label and at least one cell below
+ * the column label in which you specify a condition for the
+ * column.
+ * @return float
*
*/
public static function DVARP($database,$field,$criteria) {
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php
index e32de01ebe0..3b5dc45aaaa 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/DateTime.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,10 +41,16 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_DateTime {
+ /**
+ * Identify if a year is a leap year or not
+ *
+ * @param integer $year The year to test
+ * @return boolean TRUE if the year is a leap year, otherwise FALSE
+ */
public static function _isLeapYear($year) {
return ((($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0));
} // function _isLeapYear()
@@ -82,7 +88,8 @@ class PHPExcel_Calculation_DateTime {
*/
public static function _getDateValue($dateValue) {
if (!is_numeric($dateValue)) {
- if ((is_string($dateValue)) && (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
+ if ((is_string($dateValue)) &&
+ (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if ((is_object($dateValue)) && ($dateValue instanceof PHPExcel_Shared_Date::$dateTimeObjectType)) {
@@ -142,6 +149,19 @@ class PHPExcel_Calculation_DateTime {
/**
* DATETIMENOW
*
+ * Returns the current date and time.
+ * The NOW function is useful when you need to display the current date and time on a worksheet or
+ * calculate a value based on the current date and time, and have that value updated each time you
+ * open the worksheet.
+ *
+ * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
+ * and time format of your regional settings. PHPExcel does not change cell formatting in this way.
+ *
+ * Excel Function:
+ * NOW()
+ *
+ * @access public
+ * @category Date/Time Functions
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
@@ -169,6 +189,19 @@ class PHPExcel_Calculation_DateTime {
/**
* DATENOW
*
+ * Returns the current date.
+ * The NOW function is useful when you need to display the current date and time on a worksheet or
+ * calculate a value based on the current date and time, and have that value updated each time you
+ * open the worksheet.
+ *
+ * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
+ * and time format of your regional settings. PHPExcel does not change cell formatting in this way.
+ *
+ * Excel Function:
+ * TODAY()
+ *
+ * @access public
+ * @category Date/Time Functions
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
@@ -182,7 +215,7 @@ class PHPExcel_Calculation_DateTime {
$retValue = (float) $excelDateTime;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
- $retValue = (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateTime) - 3600;
+ $retValue = (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateTime);
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
$retValue = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateTime);
@@ -197,16 +230,65 @@ class PHPExcel_Calculation_DateTime {
/**
* DATE
*
- * @param long $year
- * @param long $month
- * @param long $day
+ * The DATE function returns a value that represents a particular date.
+ *
+ * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
+ * format of your regional settings. PHPExcel does not change cell formatting in this way.
+ *
+ * Excel Function:
+ * DATE(year,month,day)
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param integer $year The value of the year argument can include one to four digits.
+ * Excel interprets the year argument according to the configured
+ * date system: 1900 or 1904.
+ * If year is between 0 (zero) and 1899 (inclusive), Excel adds that
+ * value to 1900 to calculate the year. For example, DATE(108,1,2)
+ * returns January 2, 2008 (1900+108).
+ * If year is between 1900 and 9999 (inclusive), Excel uses that
+ * value as the year. For example, DATE(2008,1,2) returns January 2,
+ * 2008.
+ * If year is less than 0 or is 10000 or greater, Excel returns the
+ * #NUM! error value.
+ * @param integer $month A positive or negative integer representing the month of the year
+ * from 1 to 12 (January to December).
+ * If month is greater than 12, month adds that number of months to
+ * the first month in the year specified. For example, DATE(2008,14,2)
+ * returns the serial number representing February 2, 2009.
+ * If month is less than 1, month subtracts the magnitude of that
+ * number of months, plus 1, from the first month in the year
+ * specified. For example, DATE(2008,-3,2) returns the serial number
+ * representing September 2, 2007.
+ * @param integer $day A positive or negative integer representing the day of the month
+ * from 1 to 31.
+ * If day is greater than the number of days in the month specified,
+ * day adds that number of days to the first day in the month. For
+ * example, DATE(2008,1,35) returns the serial number representing
+ * February 4, 2008.
+ * If day is less than 1, day subtracts the magnitude that number of
+ * days, plus one, from the first day of the month specified. For
+ * example, DATE(2008,1,-15) returns the serial number representing
+ * December 16, 2007.
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATE($year = 0, $month = 1, $day = 1) {
- $year = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($year);
- $month = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($month);
- $day = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($day);
+ $year = PHPExcel_Calculation_Functions::flattenSingleValue($year);
+ $month = PHPExcel_Calculation_Functions::flattenSingleValue($month);
+ $day = PHPExcel_Calculation_Functions::flattenSingleValue($day);
+
+ $year = ($year !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($year) : 0;
+ $month = ($month !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($month) : 0;
+ $day = ($day !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($day) : 0;
+ if ((!is_numeric($year)) ||
+ (!is_numeric($month)) ||
+ (!is_numeric($day))) {
+ return PHPExcel_Calculation_Functions::VALUE();
+ }
+ $year = (integer) $year;
+ $month = (integer) $month;
+ $day = (integer) $day;
$baseYear = PHPExcel_Shared_Date::getExcelCalendar();
// Validate parameters
@@ -242,13 +324,10 @@ class PHPExcel_Calculation_DateTime {
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue;
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue);
- break;
}
} // function DATE()
@@ -256,9 +335,27 @@ class PHPExcel_Calculation_DateTime {
/**
* TIME
*
- * @param long $hour
- * @param long $minute
- * @param long $second
+ * The TIME function returns a value that represents a particular time.
+ *
+ * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time
+ * format of your regional settings. PHPExcel does not change cell formatting in this way.
+ *
+ * Excel Function:
+ * TIME(hour,minute,second)
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param integer $hour A number from 0 (zero) to 32767 representing the hour.
+ * Any value greater than 23 will be divided by 24 and the remainder
+ * will be treated as the hour value. For example, TIME(27,0,0) =
+ * TIME(3,0,0) = .125 or 3:00 AM.
+ * @param integer $minute A number from 0 to 32767 representing the minute.
+ * Any value greater than 59 will be converted to hours and minutes.
+ * For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM.
+ * @param integer $second A number from 0 to 32767 representing the second.
+ * Any value greater than 59 will be converted to hours, minutes,
+ * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148
+ * or 12:33:20 AM
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
@@ -310,10 +407,8 @@ class PHPExcel_Calculation_DateTime {
$date = 1;
}
return (float) PHPExcel_Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
- return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour-1, $minute, $second)); // -2147468400; // -2147472000 + 3600
- break;
+ return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
$dayAdjust = 0;
if ($hour < 0) {
@@ -329,7 +424,6 @@ class PHPExcel_Calculation_DateTime {
$phpDateObject->modify($dayAdjust.' days');
}
return $phpDateObject;
- break;
}
} // function TIME()
@@ -337,7 +431,26 @@ class PHPExcel_Calculation_DateTime {
/**
* DATEVALUE
*
- * @param string $dateValue
+ * Returns a value that represents a particular date.
+ * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp
+ * value.
+ *
+ * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
+ * format of your regional settings. PHPExcel does not change cell formatting in this way.
+ *
+ * Excel Function:
+ * DATEVALUE(dateValue)
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param string $dateValue Text that represents a date in a Microsoft Excel date format.
+ * For example, "1/30/2008" or "30-Jan-2008" are text strings within
+ * quotation marks that represent dates. Using the default date
+ * system in Excel for Windows, date_text must represent a date from
+ * January 1, 1900, to December 31, 9999. Using the default date
+ * system in Excel for the Macintosh, date_text must represent a date
+ * from January 1, 1904, to December 31, 9999. DATEVALUE returns the
+ * #VALUE! error value if date_text is out of this range.
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
@@ -402,6 +515,8 @@ class PHPExcel_Calculation_DateTime {
if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
// Execute function
if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); }
+ if ($PHPDateArray['year'] < 1900)
+ return PHPExcel_Calculation_Functions::VALUE();
if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); }
if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); }
$excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']));
@@ -409,13 +524,10 @@ class PHPExcel_Calculation_DateTime {
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue;
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return new DateTime($PHPDateArray['year'].'-'.$PHPDateArray['month'].'-'.$PHPDateArray['day'].' 00:00:00');
- break;
}
}
return PHPExcel_Calculation_Functions::VALUE();
@@ -425,7 +537,22 @@ class PHPExcel_Calculation_DateTime {
/**
* TIMEVALUE
*
- * @param string $timeValue
+ * Returns a value that represents a particular time.
+ * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp
+ * value.
+ *
+ * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time
+ * format of your regional settings. PHPExcel does not change cell formatting in this way.
+ *
+ * Excel Function:
+ * TIMEVALUE(timeValue)
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param string $timeValue A text string that represents a time in any one of the Microsoft
+ * Excel time formats; for example, "6:45 PM" and "18:45" text strings
+ * within quotation marks that represent time.
+ * Date information in time_text is ignored.
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
@@ -444,13 +571,10 @@ class PHPExcel_Calculation_DateTime {
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue;
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;;
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']);
- break;
}
}
return PHPExcel_Calculation_Functions::VALUE();
@@ -460,10 +584,12 @@ class PHPExcel_Calculation_DateTime {
/**
* DATEDIF
*
- * @param long $startDate Excel date serial value or a standard date string
- * @param long $endDate Excel date serial value or a standard date string
+ * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object
+ * or a standard date string
+ * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object
+ * or a standard date string
* @param string $unit
- * @return long Interval between the dates
+ * @return integer Interval between the dates
*/
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
@@ -547,6 +673,8 @@ class PHPExcel_Calculation_DateTime {
if ($retVal < 0) { $retVal += 365; }
}
break;
+ default:
+ $retVal = PHPExcel_Calculation_Functions::NaN();
}
return $retVal;
} // function DATEDIF()
@@ -555,10 +683,31 @@ class PHPExcel_Calculation_DateTime {
/**
* DAYS360
*
- * @param long $startDate Excel date serial value or a standard date string
- * @param long $endDate Excel date serial value or a standard date string
- * @param boolean $method US or European Method
- * @return long PHP date/time serial
+ * Returns the number of days between two dates based on a 360-day year (twelve 30-day months),
+ * which is used in some accounting calculations. Use this function to help compute payments if
+ * your accounting system is based on twelve 30-day months.
+ *
+ * Excel Function:
+ * DAYS360(startDate,endDate[,method])
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param boolean $method US or European Method
+ * FALSE or omitted: U.S. (NASD) method. If the starting date is
+ * the last day of a month, it becomes equal to the 30th of the
+ * same month. If the ending date is the last day of a month and
+ * the starting date is earlier than the 30th of a month, the
+ * ending date becomes equal to the 1st of the next month;
+ * otherwise the ending date becomes equal to the 30th of the
+ * same month.
+ * TRUE: European method. Starting dates and ending dates that
+ * occur on the 31st of a month become equal to the 30th of the
+ * same month.
+ * @return integer Number of days between start date and end date
*/
public static function DAYS360($startDate = 0, $endDate = 0, $method = false) {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
@@ -587,21 +736,29 @@ class PHPExcel_Calculation_DateTime {
/**
- * YEARFRAC
+ * YEARFRAC
*
- * Calculates the fraction of the year represented by the number of whole days between two dates (the start_date and the
- * end_date). Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or obligations
- * to assign to a specific term.
+ * Calculates the fraction of the year represented by the number of whole days between two dates
+ * (the start_date and the end_date).
+ * Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or
+ * obligations to assign to a specific term.
*
- * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string
- * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string
- * @param integer $method Method used for the calculation
+ * Excel Function:
+ * YEARFRAC(startDate,endDate[,method])
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param integer $method Method used for the calculation
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float fraction of the year
+ * @return float fraction of the year
*/
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
@@ -619,7 +776,6 @@ class PHPExcel_Calculation_DateTime {
switch($method) {
case 0 :
return self::DAYS360($startDate,$endDate) / 360;
- break;
case 1 :
$days = self::DATEDIF($startDate,$endDate);
$startYear = self::YEAR($startDate);
@@ -664,16 +820,12 @@ class PHPExcel_Calculation_DateTime {
$leapDays /= $years;
}
return $days / (365 + $leapDays);
- break;
case 2 :
return self::DATEDIF($startDate,$endDate) / 360;
- break;
case 3 :
return self::DATEDIF($startDate,$endDate) / 365;
- break;
case 4 :
return self::DAYS360($startDate,$endDate,True) / 360;
- break;
}
}
return PHPExcel_Calculation_Functions::VALUE();
@@ -683,10 +835,25 @@ class PHPExcel_Calculation_DateTime {
/**
* NETWORKDAYS
*
- * @param mixed Start date
- * @param mixed End date
- * @param array of mixed Optional Date Series
- * @return long Interval between the dates
+ * Returns the number of whole working days between start_date and end_date. Working days
+ * exclude weekends and any dates identified in holidays.
+ * Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days
+ * worked during a specific term.
+ *
+ * Excel Function:
+ * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]])
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param mixed $holidays,... Optional series of Excel date serial value (float), PHP date
+ * timestamp (integer), PHP DateTime object, or a standard date
+ * strings that will be excluded from the working calendar, such
+ * as state and federal holidays and floating holidays.
+ * @return integer Interval between the dates
*/
public static function NETWORKDAYS($startDate,$endDate) {
// Retrieve the mandatory start and end date that are referenced in the function definition
@@ -748,15 +915,32 @@ class PHPExcel_Calculation_DateTime {
/**
* WORKDAY
*
- * @param mixed Start date
- * @param mixed number of days for adjustment
- * @param array of mixed Optional Date Series
- * @return long Interval between the dates
+ * Returns the date that is the indicated number of working days before or after a date (the
+ * starting date). Working days exclude weekends and any dates identified as holidays.
+ * Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected
+ * delivery times, or the number of days of work performed.
+ *
+ * Excel Function:
+ * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]])
+ *
+ * @access public
+ * @category Date/Time Functions
+ * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param integer $endDays The number of nonweekend and nonholiday days before or after
+ * startDate. A positive value for days yields a future date; a
+ * negative value yields a past date.
+ * @param mixed $holidays,... Optional series of Excel date serial value (float), PHP date
+ * timestamp (integer), PHP DateTime object, or a standard date
+ * strings that will be excluded from the working calendar, such
+ * as state and federal holidays and floating holidays.
+ * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
+ * depending on the value of the ReturnDateType flag
*/
public static function WORKDAY($startDate,$endDays) {
// Retrieve the mandatory start date and days that are referenced in the function definition
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
- $endDays = (int) PHPExcel_Calculation_Functions::flattenSingleValue($endDays);
+ $endDays = PHPExcel_Calculation_Functions::flattenSingleValue($endDays);
// Flush the mandatory start date and days that are referenced in the function definition, and get the optional days
$dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
array_shift($dateArgs);
@@ -766,6 +950,7 @@ class PHPExcel_Calculation_DateTime {
return PHPExcel_Calculation_Functions::VALUE();
}
$startDate = (float) floor($startDate);
+ $endDays = (int) floor($endDays);
// If endDays is 0, we always return startDate
if ($endDays == 0) { return $startDate; }
@@ -789,10 +974,10 @@ class PHPExcel_Calculation_DateTime {
}
// Test any extra holiday parameters
- if (count($dateArgs) > 0) {
+ if (!empty($dateArgs)) {
$holidayCountedArray = $holidayDates = array();
foreach ($dateArgs as $holidayDate) {
- if ((!is_null($holidayDate)) && (trim($holidayDate) > '')) {
+ if (($holidayDate !== NULL) && (trim($holidayDate) > '')) {
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
@@ -834,13 +1019,10 @@ class PHPExcel_Calculation_DateTime {
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $endDate;
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($endDate);
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
- break;
}
} // function WORKDAY()
@@ -848,8 +1030,15 @@ class PHPExcel_Calculation_DateTime {
/**
* DAYOFMONTH
*
- * @param long $dateValue Excel date serial value or a standard date string
- * @return int Day
+ * Returns the day of the month, for a specified date. The day is given as an integer
+ * ranging from 1 to 31.
+ *
+ * Excel Function:
+ * DAY(dateValue)
+ *
+ * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @return int Day of the month
*/
public static function DAYOFMONTH($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
@@ -872,12 +1061,30 @@ class PHPExcel_Calculation_DateTime {
/**
* DAYOFWEEK
*
- * @param long $dateValue Excel date serial value or a standard date string
- * @return int Day
+ * Returns the day of the week for a specified date. The day is given as an integer
+ * ranging from 0 to 7 (dependent on the requested style).
+ *
+ * Excel Function:
+ * WEEKDAY(dateValue[,style])
+ *
+ * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param int $style A number that determines the type of return value
+ * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday).
+ * 2 Numbers 1 (Monday) through 7 (Sunday).
+ * 3 Numbers 0 (Monday) through 6 (Sunday).
+ * @return int Day of the week value
*/
public static function DAYOFWEEK($dateValue = 1, $style = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
- $style = floor(PHPExcel_Calculation_Functions::flattenSingleValue($style));
+ $style = PHPExcel_Calculation_Functions::flattenSingleValue($style);
+
+ if (!is_numeric($style)) {
+ return PHPExcel_Calculation_Functions::VALUE();
+ } elseif (($style < 1) || ($style > 3)) {
+ return PHPExcel_Calculation_Functions::NaN();
+ }
+ $style = floor($style);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
@@ -899,7 +1106,6 @@ class PHPExcel_Calculation_DateTime {
$firstDay = 0;
--$DoW;
break;
- default:
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL) {
// Test for Excel's 1900 leap year, and introduce the error as required
@@ -918,19 +1124,33 @@ class PHPExcel_Calculation_DateTime {
/**
* WEEKOFYEAR
*
- * @param long $dateValue Excel date serial value or a standard date string
+ * Returns the week of the year for a specified date.
+ * The WEEKNUM function considers the week containing January 1 to be the first week of the year.
+ * However, there is a European standard that defines the first week as the one with the majority
+ * of days (four or more) falling in the new year. This means that for years in which there are
+ * three days or less in the first week of January, the WEEKNUM function returns week numbers
+ * that are incorrect according to the European standard.
+ *
+ * Excel Function:
+ * WEEKNUM(dateValue[,style])
+ *
+ * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
* @param boolean $method Week begins on Sunday or Monday
+ * 1 or omitted Week begins on Sunday.
+ * 2 Week begins on Monday.
* @return int Week Number
*/
public static function WEEKOFYEAR($dateValue = 1, $method = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
- $method = floor(PHPExcel_Calculation_Functions::flattenSingleValue($method));
+ $method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
if (!is_numeric($method)) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif (($method < 1) || ($method > 2)) {
return PHPExcel_Calculation_Functions::NaN();
}
+ $method = floor($method);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
@@ -955,8 +1175,15 @@ class PHPExcel_Calculation_DateTime {
/**
* MONTHOFYEAR
*
- * @param long $dateValue Excel date serial value or a standard date string
- * @return int Month
+ * Returns the month of a date represented by a serial number.
+ * The month is given as an integer, ranging from 1 (January) to 12 (December).
+ *
+ * Excel Function:
+ * MONTH(dateValue)
+ *
+ * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @return int Month of the year
*/
public static function MONTHOFYEAR($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
@@ -977,7 +1204,14 @@ class PHPExcel_Calculation_DateTime {
/**
* YEAR
*
- * @param long $dateValue Excel date serial value or a standard date string
+ * Returns the year corresponding to a date.
+ * The year is returned as an integer in the range 1900-9999.
+ *
+ * Excel Function:
+ * YEAR(dateValue)
+ *
+ * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
* @return int Year
*/
public static function YEAR($dateValue = 1) {
@@ -999,7 +1233,14 @@ class PHPExcel_Calculation_DateTime {
/**
* HOUROFDAY
*
- * @param mixed $timeValue Excel time serial value or a standard time string
+ * Returns the hour of a time value.
+ * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
+ *
+ * Excel Function:
+ * HOUR(timeValue)
+ *
+ * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard time string
* @return int Hour
*/
public static function HOUROFDAY($timeValue = 0) {
@@ -1032,7 +1273,14 @@ class PHPExcel_Calculation_DateTime {
/**
* MINUTEOFHOUR
*
- * @param long $timeValue Excel time serial value or a standard time string
+ * Returns the minutes of a time value.
+ * The minute is given as an integer, ranging from 0 to 59.
+ *
+ * Excel Function:
+ * MINUTE(timeValue)
+ *
+ * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard time string
* @return int Minute
*/
public static function MINUTEOFHOUR($timeValue = 0) {
@@ -1065,7 +1313,14 @@ class PHPExcel_Calculation_DateTime {
/**
* SECONDOFMINUTE
*
- * @param long $timeValue Excel time serial value or a standard time string
+ * Returns the seconds of a time value.
+ * The second is given as an integer in the range 0 (zero) to 59.
+ *
+ * Excel Function:
+ * SECOND(timeValue)
+ *
+ * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard time string
* @return int Second
*/
public static function SECONDOFMINUTE($timeValue = 0) {
@@ -1098,20 +1353,30 @@ class PHPExcel_Calculation_DateTime {
/**
* EDATE
*
- * Returns the serial number that represents the date that is the indicated number of months before or after a specified date
- * (the start_date). Use EDATE to calculate maturity dates or due dates that fall on the same day of the month as the date of issue.
+ * Returns the serial number that represents the date that is the indicated number of months
+ * before or after a specified date (the start_date).
+ * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month
+ * as the date of issue.
*
- * @param long $dateValue Excel date serial value or a standard date string
- * @param int $adjustmentMonths Number of months to adjust by
- * @return long Excel date serial value
+ * Excel Function:
+ * EDATE(dateValue,adjustmentMonths)
+ *
+ * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param int $adjustmentMonths The number of months before or after start_date.
+ * A positive value for months yields a future date;
+ * a negative value yields a past date.
+ * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
+ * depending on the value of the ReturnDateType flag
*/
public static function EDATE($dateValue = 1, $adjustmentMonths = 0) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
- $adjustmentMonths = floor(PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths));
+ $adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths);
if (!is_numeric($adjustmentMonths)) {
return PHPExcel_Calculation_Functions::VALUE();
}
+ $adjustmentMonths = floor($adjustmentMonths);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
@@ -1123,13 +1388,10 @@ class PHPExcel_Calculation_DateTime {
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return $PHPDateObject;
- break;
}
} // function EDATE()
@@ -1137,20 +1399,29 @@ class PHPExcel_Calculation_DateTime {
/**
* EOMONTH
*
- * Returns the serial number for the last day of the month that is the indicated number of months before or after start_date.
+ * Returns the date value for the last day of the month that is the indicated number of months
+ * before or after start_date.
* Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
*
- * @param long $dateValue Excel date serial value or a standard date string
- * @param int $adjustmentMonths Number of months to adjust by
- * @return long Excel date serial value
+ * Excel Function:
+ * EOMONTH(dateValue,adjustmentMonths)
+ *
+ * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
+ * PHP DateTime object, or a standard date string
+ * @param int $adjustmentMonths The number of months before or after start_date.
+ * A positive value for months yields a future date;
+ * a negative value yields a past date.
+ * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
+ * depending on the value of the ReturnDateType flag
*/
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
- $adjustmentMonths = floor(PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths));
+ $adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths);
if (!is_numeric($adjustmentMonths)) {
return PHPExcel_Calculation_Functions::VALUE();
}
+ $adjustmentMonths = floor($adjustmentMonths);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
@@ -1165,14 +1436,12 @@ class PHPExcel_Calculation_DateTime {
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
- break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return $PHPDateObject;
- break;
}
} // function EOMONTH()
} // class PHPExcel_Calculation_DateTime
+
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php
index 9adc2ecdf14..cfaffafbab5 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Engineering.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -45,10 +45,15 @@ define('EULER', 2.71828182845904523536);
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Engineering {
+ /**
+ * Details of the Units of measure that can be used in CONVERTUOM()
+ *
+ * @var mixed[]
+ */
private static $_conversionUnits = array( 'g' => array( 'Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => True ),
'sg' => array( 'Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => False ),
'lbm' => array( 'Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => False ),
@@ -114,6 +119,11 @@ class PHPExcel_Calculation_Engineering {
'lt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True )
);
+ /**
+ * Details of the Multiplier prefixes that can be used with Units of Measure in CONVERTUOM()
+ *
+ * @var mixed[]
+ */
private static $_conversionMultipliers = array( 'Y' => array( 'multiplier' => 1E24, 'name' => 'yotta' ),
'Z' => array( 'multiplier' => 1E21, 'name' => 'zetta' ),
'E' => array( 'multiplier' => 1E18, 'name' => 'exa' ),
@@ -136,6 +146,11 @@ class PHPExcel_Calculation_Engineering {
'y' => array( 'multiplier' => 1E-24, 'name' => 'yocto' )
);
+ /**
+ * Details of the Units of measure conversion factors, organised by group
+ *
+ * @var mixed[]
+ */
private static $_unitConversions = array( 'Mass' => array( 'g' => array( 'g' => 1.0,
'sg' => 6.85220500053478E-05,
'lbm' => 2.20462291469134E-03,
@@ -670,6 +685,14 @@ class PHPExcel_Calculation_Engineering {
);
+ /**
+ * _parseComplex
+ *
+ * Parses a complex number into its real and imaginary parts, and an I or J suffix
+ *
+ * @param string $complexNumber The complex number
+ * @return string[] Indexed on "real", "imaginary" and "suffix"
+ */
public static function _parseComplex($complexNumber) {
$workString = (string) $complexNumber;
@@ -717,6 +740,14 @@ class PHPExcel_Calculation_Engineering {
} // function _parseComplex()
+ /**
+ * _cleanComplex
+ *
+ * Cleans the leading characters in a complex number string
+ *
+ * @param string $complexNumber The complex number to clean
+ * @return string The "cleaned" complex number
+ */
private static function _cleanComplex($complexNumber) {
if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1);
if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1);
@@ -740,88 +771,108 @@ class PHPExcel_Calculation_Engineering {
/**
- * BESSELI
+ * BESSELI
*
- * Returns the modified Bessel function, which is equivalent to the Bessel function evaluated for purely imaginary arguments
+ * Returns the modified Bessel function In(x), which is equivalent to the Bessel function evaluated
+ * for purely imaginary arguments
+ *
+ * Excel Function:
+ * BESSELI(x,ord)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param float $x The value at which to evaluate the function.
+ * If x is nonnumeric, BESSELI returns the #VALUE! error value.
+ * @param integer $ord The order of the Bessel function.
+ * If ord is not an integer, it is truncated.
+ * If $ord is nonnumeric, BESSELI returns the #VALUE! error value.
+ * If $ord < 0, BESSELI returns the #NUM! error value.
+ * @return float
*
- * @param float $x
- * @param float $n
- * @return int
*/
- public static function BESSELI($x, $n) {
+ public static function BESSELI($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
- $n = (is_null($n)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($n);
+ $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
- if ((is_numeric($x)) && (is_numeric($n))) {
- $n = floor($n);
- if ($n < 0) {
+ if ((is_numeric($x)) && (is_numeric($ord))) {
+ $ord = floor($ord);
+ if ($ord < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
- $f_2_PI = 2 * M_PI;
if (abs($x) <= 30) {
- $fTerm = pow($x / 2, $n) / PHPExcel_Calculation_MathTrig::FACT($n);
- $nK = 1;
- $fResult = $fTerm;
+ $fResult = $fTerm = pow($x / 2, $ord) / PHPExcel_Calculation_MathTrig::FACT($ord);
+ $ordK = 1;
$fSqrX = ($x * $x) / 4;
do {
$fTerm *= $fSqrX;
- $fTerm /= ($nK * ($nK + $n));
+ $fTerm /= ($ordK * ($ordK + $ord));
$fResult += $fTerm;
- } while ((abs($fTerm) > 1e-10) && (++$nK < 100));
+ } while ((abs($fTerm) > 1e-12) && (++$ordK < 100));
} else {
+ $f_2_PI = 2 * M_PI;
+
$fXAbs = abs($x);
$fResult = exp($fXAbs) / sqrt($f_2_PI * $fXAbs);
- if (($n && 1) && ($x < 0)) {
+ if (($ord & 1) && ($x < 0)) {
$fResult = -$fResult;
}
}
- return $fResult;
+ return (is_nan($fResult)) ? PHPExcel_Calculation_Functions::NaN() : $fResult;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELI()
/**
- * BESSELJ
+ * BESSELJ
*
- * Returns the Bessel function
+ * Returns the Bessel function
+ *
+ * Excel Function:
+ * BESSELJ(x,ord)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param float $x The value at which to evaluate the function.
+ * If x is nonnumeric, BESSELJ returns the #VALUE! error value.
+ * @param integer $ord The order of the Bessel function. If n is not an integer, it is truncated.
+ * If $ord is nonnumeric, BESSELJ returns the #VALUE! error value.
+ * If $ord < 0, BESSELJ returns the #NUM! error value.
+ * @return float
*
- * @param float $x
- * @param float $n
- * @return int
*/
- public static function BESSELJ($x, $n) {
+ public static function BESSELJ($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
- $n = (is_null($n)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($n);
+ $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
- if ((is_numeric($x)) && (is_numeric($n))) {
- $n = floor($n);
- if ($n < 0) {
+ if ((is_numeric($x)) && (is_numeric($ord))) {
+ $ord = floor($ord);
+ if ($ord < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
- $f_PI_DIV_2 = M_PI / 2;
- $f_PI_DIV_4 = M_PI / 4;
$fResult = 0;
if (abs($x) <= 30) {
- $fTerm = pow($x / 2, $n) / PHPExcel_Calculation_MathTrig::FACT($n);
- $nK = 1;
- $fResult = $fTerm;
+ $fResult = $fTerm = pow($x / 2, $ord) / PHPExcel_Calculation_MathTrig::FACT($ord);
+ $ordK = 1;
$fSqrX = ($x * $x) / -4;
do {
$fTerm *= $fSqrX;
- $fTerm /= ($nK * ($nK + $n));
+ $fTerm /= ($ordK * ($ordK + $ord));
$fResult += $fTerm;
- } while ((abs($fTerm) > 1e-10) && (++$nK < 100));
+ } while ((abs($fTerm) > 1e-12) && (++$ordK < 100));
} else {
+ $f_PI_DIV_2 = M_PI / 2;
+ $f_PI_DIV_4 = M_PI / 4;
+
$fXAbs = abs($x);
- $fResult = sqrt(M_2DIVPI / $fXAbs) * cos($fXAbs - $n * $f_PI_DIV_2 - $f_PI_DIV_4);
- if (($n && 1) && ($x < 0)) {
+ $fResult = sqrt(M_2DIVPI / $fXAbs) * cos($fXAbs - $ord * $f_PI_DIV_2 - $f_PI_DIV_4);
+ if (($ord & 1) && ($x < 0)) {
$fResult = -$fResult;
}
}
- return $fResult;
+ return (is_nan($fResult)) ? PHPExcel_Calculation_Functions::NaN() : $fResult;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELJ()
@@ -862,13 +913,23 @@ class PHPExcel_Calculation_Engineering {
/**
- * BESSELK
+ * BESSELK
*
- * Returns the modified Bessel function, which is equivalent to the Bessel functions evaluated for purely imaginary arguments.
+ * Returns the modified Bessel function Kn(x), which is equivalent to the Bessel functions evaluated
+ * for purely imaginary arguments.
+ *
+ * Excel Function:
+ * BESSELK(x,ord)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param float $x The value at which to evaluate the function.
+ * If x is nonnumeric, BESSELK returns the #VALUE! error value.
+ * @param integer $ord The order of the Bessel function. If n is not an integer, it is truncated.
+ * If $ord is nonnumeric, BESSELK returns the #VALUE! error value.
+ * If $ord < 0, BESSELK returns the #NUM! error value.
+ * @return float
*
- * @param float $x
- * @param float $ord
- * @return float
*/
public static function BESSELK($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
@@ -893,7 +954,7 @@ class PHPExcel_Calculation_Engineering {
$fBk = $fBkp;
}
}
- return $fBk;
+ return (is_nan($fBk)) ? PHPExcel_Calculation_Functions::NaN() : $fBk;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELK()
@@ -904,14 +965,14 @@ class PHPExcel_Calculation_Engineering {
$y = ($fNum * $fNum);
$f1 = -2957821389.0 + $y * (7062834065.0 + $y * (-512359803.6 + $y * (10879881.29 + $y * (-86327.92757 + $y * 228.4622733))));
$f2 = 40076544269.0 + $y * (745249964.8 + $y * (7189466.438 + $y * (47447.26470 + $y * (226.1030244 + $y))));
- $fRet = $f1 / $f2 + M_2DIVPI * self::BESSELJ($fNum, 0) * log($fNum);
+ $fRet = $f1 / $f2 + 0.636619772 * self::BESSELJ($fNum, 0) * log($fNum);
} else {
$z = 8.0 / $fNum;
$y = ($z * $z);
$xx = $fNum - 0.785398164;
$f1 = 1 + $y * (-0.1098628627e-2 + $y * (0.2734510407e-4 + $y * (-0.2073370639e-5 + $y * 0.2093887211e-6)));
$f2 = -0.1562499995e-1 + $y * (0.1430488765e-3 + $y * (-0.6911147651e-5 + $y * (0.7621095161e-6 + $y * (-0.934945152e-7))));
- $fRet = sqrt(M_2DIVPI / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
+ $fRet = sqrt(0.636619772 / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
}
return $fRet;
} // function _Bessely0()
@@ -924,29 +985,31 @@ class PHPExcel_Calculation_Engineering {
(-0.4237922726e7 + $y * 0.8511937935e4)))));
$f2 = 0.2499580570e14 + $y * (0.4244419664e12 + $y * (0.3733650367e10 + $y * (0.2245904002e8 + $y *
(0.1020426050e6 + $y * (0.3549632885e3 + $y)))));
- $fRet = $f1 / $f2 + M_2DIVPI * ( self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum);
+ $fRet = $f1 / $f2 + 0.636619772 * ( self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum);
} else {
- $z = 8.0 / $fNum;
- $y = ($z * $z);
- $xx = $fNum - 2.356194491;
- $f1 = 1 + $y * (0.183105e-2 + $y * (-0.3516396496e-4 + $y * (0.2457520174e-5 + $y * (-0.240337019e6))));
- $f2 = 0.04687499995 + $y * (-0.2002690873e-3 + $y * (0.8449199096e-5 + $y * (-0.88228987e-6 + $y * 0.105787412e-6)));
- $fRet = sqrt(M_2DIVPI / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
- #i12430# ...but this seems to work much better.
-// $fRet = sqrt(M_2DIVPI / $fNum) * sin($fNum - 2.356194491);
+ $fRet = sqrt(0.636619772 / $fNum) * sin($fNum - 2.356194491);
}
return $fRet;
} // function _Bessely1()
/**
- * BESSELY
+ * BESSELY
*
- * Returns the Bessel function, which is also called the Weber function or the Neumann function.
+ * Returns the Bessel function, which is also called the Weber function or the Neumann function.
*
- * @param float $x
- * @param float $n
- * @return int
+ * Excel Function:
+ * BESSELY(x,ord)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param float $x The value at which to evaluate the function.
+ * If x is nonnumeric, BESSELK returns the #VALUE! error value.
+ * @param integer $ord The order of the Bessel function. If n is not an integer, it is truncated.
+ * If $ord is nonnumeric, BESSELK returns the #VALUE! error value.
+ * If $ord < 0, BESSELK returns the #NUM! error value.
+ *
+ * @return float
*/
public static function BESSELY($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
@@ -971,7 +1034,7 @@ class PHPExcel_Calculation_Engineering {
$fBy = $fByp;
}
}
- return $fBy;
+ return (is_nan($fBy)) ? PHPExcel_Calculation_Functions::NaN() : $fBy;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELY()
@@ -980,9 +1043,19 @@ class PHPExcel_Calculation_Engineering {
/**
* BINTODEC
*
- * Return a binary value as Decimal.
+ * Return a binary value as decimal.
*
- * @param string $x
+ * Excel Function:
+ * BIN2DEC(x)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The binary number (as a string) that you want to convert. The number
+ * cannot contain more than 10 characters (10 bits). The most significant
+ * bit of number is the sign bit. The remaining 9 bits are magnitude bits.
+ * Negative numbers are represented using two's-complement notation.
+ * If number is not a valid binary number, or if number contains more than
+ * 10 characters (10 bits), BIN2DEC returns the #NUM! error value.
* @return string
*/
public static function BINTODEC($x) {
@@ -1016,13 +1089,29 @@ class PHPExcel_Calculation_Engineering {
/**
* BINTOHEX
*
- * Return a binary value as Hex.
+ * Return a binary value as hex.
*
- * @param string $x
+ * Excel Function:
+ * BIN2HEX(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The binary number (as a string) that you want to convert. The number
+ * cannot contain more than 10 characters (10 bits). The most significant
+ * bit of number is the sign bit. The remaining 9 bits are magnitude bits.
+ * Negative numbers are represented using two's-complement notation.
+ * If number is not a valid binary number, or if number contains more than
+ * 10 characters (10 bits), BIN2HEX returns the #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted, BIN2HEX uses the
+ * minimum number of characters necessary. Places is useful for padding the
+ * return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, BIN2HEX returns the #VALUE! error value.
+ * If places is negative, BIN2HEX returns the #NUM! error value.
* @return string
*/
- public static function BINTOHEX($x, $places=null) {
- $x = floor(PHPExcel_Calculation_Functions::flattenSingleValue($x));
+ public static function BINTOHEX($x, $places=NULL) {
+ $x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
@@ -1054,13 +1143,29 @@ class PHPExcel_Calculation_Engineering {
/**
* BINTOOCT
*
- * Return a binary value as Octal.
+ * Return a binary value as octal.
*
- * @param string $x
+ * Excel Function:
+ * BIN2OCT(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The binary number (as a string) that you want to convert. The number
+ * cannot contain more than 10 characters (10 bits). The most significant
+ * bit of number is the sign bit. The remaining 9 bits are magnitude bits.
+ * Negative numbers are represented using two's-complement notation.
+ * If number is not a valid binary number, or if number contains more than
+ * 10 characters (10 bits), BIN2OCT returns the #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted, BIN2OCT uses the
+ * minimum number of characters necessary. Places is useful for padding the
+ * return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, BIN2OCT returns the #VALUE! error value.
+ * If places is negative, BIN2OCT returns the #NUM! error value.
* @return string
*/
- public static function BINTOOCT($x, $places=null) {
- $x = floor(PHPExcel_Calculation_Functions::flattenSingleValue($x));
+ public static function BINTOOCT($x, $places=NULL) {
+ $x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
@@ -1092,12 +1197,32 @@ class PHPExcel_Calculation_Engineering {
/**
* DECTOBIN
*
- * Return an octal value as binary.
+ * Return a decimal value as binary.
*
- * @param string $x
+ * Excel Function:
+ * DEC2BIN(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The decimal integer you want to convert. If number is negative,
+ * valid place values are ignored and DEC2BIN returns a 10-character
+ * (10-bit) binary number in which the most significant bit is the sign
+ * bit. The remaining 9 bits are magnitude bits. Negative numbers are
+ * represented using two's-complement notation.
+ * If number < -512 or if number > 511, DEC2BIN returns the #NUM! error
+ * value.
+ * If number is nonnumeric, DEC2BIN returns the #VALUE! error value.
+ * If DEC2BIN requires more than places characters, it returns the #NUM!
+ * error value.
+ * @param integer $places The number of characters to use. If places is omitted, DEC2BIN uses
+ * the minimum number of characters necessary. Places is useful for
+ * padding the return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, DEC2BIN returns the #VALUE! error value.
+ * If places is zero or negative, DEC2BIN returns the #NUM! error value.
* @return string
*/
- public static function DECTOBIN($x, $places=null) {
+ public static function DECTOBIN($x, $places=NULL) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
@@ -1128,9 +1253,29 @@ class PHPExcel_Calculation_Engineering {
/**
* DECTOHEX
*
- * Return an octal value as binary.
+ * Return a decimal value as hex.
*
- * @param string $x
+ * Excel Function:
+ * DEC2HEX(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The decimal integer you want to convert. If number is negative,
+ * places is ignored and DEC2HEX returns a 10-character (40-bit)
+ * hexadecimal number in which the most significant bit is the sign
+ * bit. The remaining 39 bits are magnitude bits. Negative numbers
+ * are represented using two's-complement notation.
+ * If number < -549,755,813,888 or if number > 549,755,813,887,
+ * DEC2HEX returns the #NUM! error value.
+ * If number is nonnumeric, DEC2HEX returns the #VALUE! error value.
+ * If DEC2HEX requires more than places characters, it returns the
+ * #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted, DEC2HEX uses
+ * the minimum number of characters necessary. Places is useful for
+ * padding the return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, DEC2HEX returns the #VALUE! error value.
+ * If places is zero or negative, DEC2HEX returns the #NUM! error value.
* @return string
*/
public static function DECTOHEX($x, $places=null) {
@@ -1162,9 +1307,29 @@ class PHPExcel_Calculation_Engineering {
/**
* DECTOOCT
*
- * Return an octal value as binary.
+ * Return an decimal value as octal.
*
- * @param string $x
+ * Excel Function:
+ * DEC2OCT(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The decimal integer you want to convert. If number is negative,
+ * places is ignored and DEC2OCT returns a 10-character (30-bit)
+ * octal number in which the most significant bit is the sign bit.
+ * The remaining 29 bits are magnitude bits. Negative numbers are
+ * represented using two's-complement notation.
+ * If number < -536,870,912 or if number > 536,870,911, DEC2OCT
+ * returns the #NUM! error value.
+ * If number is nonnumeric, DEC2OCT returns the #VALUE! error value.
+ * If DEC2OCT requires more than places characters, it returns the
+ * #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted, DEC2OCT uses
+ * the minimum number of characters necessary. Places is useful for
+ * padding the return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, DEC2OCT returns the #VALUE! error value.
+ * If places is zero or negative, DEC2OCT returns the #NUM! error value.
* @return string
*/
public static function DECTOOCT($x, $places=null) {
@@ -1198,7 +1363,30 @@ class PHPExcel_Calculation_Engineering {
*
* Return a hex value as binary.
*
- * @param string $x
+ * Excel Function:
+ * HEX2BIN(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x the hexadecimal number you want to convert. Number cannot
+ * contain more than 10 characters. The most significant bit of
+ * number is the sign bit (40th bit from the right). The remaining
+ * 9 bits are magnitude bits. Negative numbers are represented
+ * using two's-complement notation.
+ * If number is negative, HEX2BIN ignores places and returns a
+ * 10-character binary number.
+ * If number is negative, it cannot be less than FFFFFFFE00, and
+ * if number is positive, it cannot be greater than 1FF.
+ * If number is not a valid hexadecimal number, HEX2BIN returns
+ * the #NUM! error value.
+ * If HEX2BIN requires more than places characters, it returns
+ * the #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted,
+ * HEX2BIN uses the minimum number of characters necessary. Places
+ * is useful for padding the return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, HEX2BIN returns the #VALUE! error value.
+ * If places is negative, HEX2BIN returns the #NUM! error value.
* @return string
*/
public static function HEXTOBIN($x, $places=null) {
@@ -1221,9 +1409,20 @@ class PHPExcel_Calculation_Engineering {
/**
* HEXTODEC
*
- * Return a hex value as octal.
+ * Return a hex value as decimal.
*
- * @param string $x
+ * Excel Function:
+ * HEX2DEC(x)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The hexadecimal number you want to convert. This number cannot
+ * contain more than 10 characters (40 bits). The most significant
+ * bit of number is the sign bit. The remaining 39 bits are magnitude
+ * bits. Negative numbers are represented using two's-complement
+ * notation.
+ * If number is not a valid hexadecimal number, HEX2DEC returns the
+ * #NUM! error value.
* @return string
*/
public static function HEXTODEC($x) {
@@ -1245,7 +1444,31 @@ class PHPExcel_Calculation_Engineering {
*
* Return a hex value as octal.
*
- * @param string $x
+ * Excel Function:
+ * HEX2OCT(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The hexadecimal number you want to convert. Number cannot
+ * contain more than 10 characters. The most significant bit of
+ * number is the sign bit. The remaining 39 bits are magnitude
+ * bits. Negative numbers are represented using two's-complement
+ * notation.
+ * If number is negative, HEX2OCT ignores places and returns a
+ * 10-character octal number.
+ * If number is negative, it cannot be less than FFE0000000, and
+ * if number is positive, it cannot be greater than 1FFFFFFF.
+ * If number is not a valid hexadecimal number, HEX2OCT returns
+ * the #NUM! error value.
+ * If HEX2OCT requires more than places characters, it returns
+ * the #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted, HEX2OCT
+ * uses the minimum number of characters necessary. Places is
+ * useful for padding the return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, HEX2OCT returns the #VALUE! error
+ * value.
+ * If places is negative, HEX2OCT returns the #NUM! error value.
* @return string
*/
public static function HEXTOOCT($x, $places=null) {
@@ -1270,7 +1493,33 @@ class PHPExcel_Calculation_Engineering {
*
* Return an octal value as binary.
*
- * @param string $x
+ * Excel Function:
+ * OCT2BIN(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The octal number you want to convert. Number may not
+ * contain more than 10 characters. The most significant
+ * bit of number is the sign bit. The remaining 29 bits
+ * are magnitude bits. Negative numbers are represented
+ * using two's-complement notation.
+ * If number is negative, OCT2BIN ignores places and returns
+ * a 10-character binary number.
+ * If number is negative, it cannot be less than 7777777000,
+ * and if number is positive, it cannot be greater than 777.
+ * If number is not a valid octal number, OCT2BIN returns
+ * the #NUM! error value.
+ * If OCT2BIN requires more than places characters, it
+ * returns the #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted,
+ * OCT2BIN uses the minimum number of characters necessary.
+ * Places is useful for padding the return value with
+ * leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, OCT2BIN returns the #VALUE!
+ * error value.
+ * If places is negative, OCT2BIN returns the #NUM! error
+ * value.
* @return string
*/
public static function OCTTOBIN($x, $places=null) {
@@ -1293,9 +1542,20 @@ class PHPExcel_Calculation_Engineering {
/**
* OCTTODEC
*
- * Return an octal value as binary.
+ * Return an octal value as decimal.
*
- * @param string $x
+ * Excel Function:
+ * OCT2DEC(x)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The octal number you want to convert. Number may not contain
+ * more than 10 octal characters (30 bits). The most significant
+ * bit of number is the sign bit. The remaining 29 bits are
+ * magnitude bits. Negative numbers are represented using
+ * two's-complement notation.
+ * If number is not a valid octal number, OCT2DEC returns the
+ * #NUM! error value.
* @return string
*/
public static function OCTTODEC($x) {
@@ -1317,7 +1577,28 @@ class PHPExcel_Calculation_Engineering {
*
* Return an octal value as hex.
*
- * @param string $x
+ * Excel Function:
+ * OCT2HEX(x[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $x The octal number you want to convert. Number may not contain
+ * more than 10 octal characters (30 bits). The most significant
+ * bit of number is the sign bit. The remaining 29 bits are
+ * magnitude bits. Negative numbers are represented using
+ * two's-complement notation.
+ * If number is negative, OCT2HEX ignores places and returns a
+ * 10-character hexadecimal number.
+ * If number is not a valid octal number, OCT2HEX returns the
+ * #NUM! error value.
+ * If OCT2HEX requires more than places characters, it returns
+ * the #NUM! error value.
+ * @param integer $places The number of characters to use. If places is omitted, OCT2HEX
+ * uses the minimum number of characters necessary. Places is useful
+ * for padding the return value with leading 0s (zeros).
+ * If places is not an integer, it is truncated.
+ * If places is nonnumeric, OCT2HEX returns the #VALUE! error value.
+ * If places is negative, OCT2HEX returns the #NUM! error value.
* @return string
*/
public static function OCTTOHEX($x, $places=null) {
@@ -1340,20 +1621,29 @@ class PHPExcel_Calculation_Engineering {
/**
* COMPLEX
*
- * returns a complex number of the form x + yi or x + yj.
+ * Converts real and imaginary coefficients into a complex number of the form x + yi or x + yj.
*
- * @param float $realNumber
- * @param float $imaginary
- * @param string $suffix
+ * Excel Function:
+ * COMPLEX(realNumber,imaginary[,places])
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param float $realNumber The real coefficient of the complex number.
+ * @param float $imaginary The imaginary coefficient of the complex number.
+ * @param string $suffix The suffix for the imaginary component of the complex number.
+ * If omitted, the suffix is assumed to be "i".
* @return string
*/
public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') {
- $realNumber = (is_null($realNumber)) ? 0.0 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
- $imaginary = (is_null($imaginary)) ? 0.0 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($imaginary);
+ $realNumber = (is_null($realNumber)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
+ $imaginary = (is_null($imaginary)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary);
$suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) {
+ $realNumber = (float) $realNumber;
+ $imaginary = (float) $imaginary;
+
if ($suffix == '') $suffix = 'i';
if ($realNumber == 0.0) {
if ($imaginary == 0.0) {
@@ -1384,16 +1674,19 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the imaginary coefficient of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
- * @return real
+ * Excel Function:
+ * IMAGINARY(complexNumber)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $complexNumber The complex number for which you want the imaginary
+ * coefficient.
+ * @return float
*/
public static function IMAGINARY($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
return $parsedComplex['imaginary'];
} // function IMAGINARY()
@@ -1403,16 +1696,18 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the real coefficient of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
- * @return real
+ * Excel Function:
+ * IMREAL(complexNumber)
+ *
+ * @access public
+ * @category Engineering Functions
+ * @param string $complexNumber The complex number for which you want the real coefficient.
+ * @return float
*/
public static function IMREAL($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
return $parsedComplex['real'];
} // function IMREAL()
@@ -1422,16 +1717,17 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
- * @return real
+ * Excel Function:
+ * IMABS(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the absolute value.
+ * @return float
*/
public static function IMABS($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
+
return sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
} // function IMABS()
@@ -1439,18 +1735,19 @@ class PHPExcel_Calculation_Engineering {
/**
* IMARGUMENT
*
- * Returns the argument theta of a complex number, i.e. the angle in radians from the real axis to the representation of the number in polar coordinates.
+ * Returns the argument theta of a complex number, i.e. the angle in radians from the real
+ * axis to the representation of the number in polar coordinates.
*
- * @param string $complexNumber
- * @return string
+ * Excel Function:
+ * IMARGUMENT(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the argument theta.
+ * @return float
*/
public static function IMARGUMENT($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if ($parsedComplex['real'] == 0.0) {
if ($parsedComplex['imaginary'] == 0.0) {
@@ -1475,7 +1772,10 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the complex conjugate of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
+ * Excel Function:
+ * IMCONJUGATE(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the conjugate.
* @return string
*/
public static function IMCONJUGATE($complexNumber) {
@@ -1483,14 +1783,14 @@ class PHPExcel_Calculation_Engineering {
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
-
if ($parsedComplex['imaginary'] == 0.0) {
return $parsedComplex['real'];
} else {
- return self::_cleanComplex(self::COMPLEX($parsedComplex['real'], 0 - $parsedComplex['imaginary'], $parsedComplex['suffix']));
+ return self::_cleanComplex( self::COMPLEX( $parsedComplex['real'],
+ 0 - $parsedComplex['imaginary'],
+ $parsedComplex['suffix']
+ )
+ );
}
} // function IMCONJUGATE()
@@ -1500,16 +1800,16 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the cosine of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
- * @return string
+ * Excel Function:
+ * IMCOS(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the cosine.
+ * @return string|float
*/
public static function IMCOS($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if ($parsedComplex['imaginary'] == 0.0) {
return cos($parsedComplex['real']);
@@ -1524,16 +1824,16 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the sine of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
- * @return string
+ * Excel Function:
+ * IMSIN(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the sine.
+ * @return string|float
*/
public static function IMSIN($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if ($parsedComplex['imaginary'] == 0.0) {
return sin($parsedComplex['real']);
@@ -1548,16 +1848,16 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the square root of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
+ * Excel Function:
+ * IMSQRT(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the square root.
* @return string
*/
public static function IMSQRT($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
$theta = self::IMARGUMENT($complexNumber);
$d1 = cos($theta / 2);
@@ -1577,16 +1877,16 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the natural logarithm of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
+ * Excel Function:
+ * IMLN(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the natural logarithm.
* @return string
*/
public static function IMLN($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
@@ -1608,16 +1908,16 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
+ * Excel Function:
+ * IMLOG10(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the common logarithm.
* @return string
*/
public static function IMLOG10($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
@@ -1634,16 +1934,16 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
+ * Excel Function:
+ * IMLOG2(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the base-2 logarithm.
* @return string
*/
public static function IMLOG2($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
@@ -1660,16 +1960,16 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the exponential of a complex number in x + yi or x + yj text format.
*
- * @param string $complexNumber
+ * Excel Function:
+ * IMEXP(complexNumber)
+ *
+ * @param string $complexNumber The complex number for which you want the exponential.
* @return string
*/
public static function IMEXP($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return '1';
@@ -1692,7 +1992,11 @@ class PHPExcel_Calculation_Engineering {
*
* Returns a complex number in x + yi or x + yj text format raised to a power.
*
- * @param string $complexNumber
+ * Excel Function:
+ * IMPOWER(complexNumber,realNumber)
+ *
+ * @param string $complexNumber The complex number you want to raise to a power.
+ * @param float $realNumber The power to which you want to raise the complex number.
* @return string
*/
public static function IMPOWER($complexNumber,$realNumber) {
@@ -1704,9 +2008,6 @@ class PHPExcel_Calculation_Engineering {
}
$parsedComplex = self::_parseComplex($complexNumber);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
$r = sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
$rPower = pow($r,$realNumber);
@@ -1726,23 +2027,19 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the quotient of two complex numbers in x + yi or x + yj text format.
*
- * @param string $complexDividend
- * @param string $complexDivisor
- * @return real
+ * Excel Function:
+ * IMDIV(complexDividend,complexDivisor)
+ *
+ * @param string $complexDividend The complex numerator or dividend.
+ * @param string $complexDivisor The complex denominator or divisor.
+ * @return string
*/
public static function IMDIV($complexDividend,$complexDivisor) {
$complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend);
$complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor);
$parsedComplexDividend = self::_parseComplex($complexDividend);
- if (!is_array($parsedComplexDividend)) {
- return $parsedComplexDividend;
- }
-
$parsedComplexDivisor = self::_parseComplex($complexDivisor);
- if (!is_array($parsedComplexDivisor)) {
- return $parsedComplexDividend;
- }
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
@@ -1774,23 +2071,19 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the difference of two complex numbers in x + yi or x + yj text format.
*
- * @param string $complexNumber1
- * @param string $complexNumber2
- * @return real
+ * Excel Function:
+ * IMSUB(complexNumber1,complexNumber2)
+ *
+ * @param string $complexNumber1 The complex number from which to subtract complexNumber2.
+ * @param string $complexNumber2 The complex number to subtract from complexNumber1.
+ * @return string
*/
public static function IMSUB($complexNumber1,$complexNumber2) {
$complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1);
$complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2);
$parsedComplex1 = self::_parseComplex($complexNumber1);
- if (!is_array($parsedComplex1)) {
- return $parsedComplex1;
- }
-
$parsedComplex2 = self::_parseComplex($complexNumber2);
- if (!is_array($parsedComplex2)) {
- return $parsedComplex2;
- }
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
@@ -1811,8 +2104,11 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the sum of two or more complex numbers in x + yi or x + yj text format.
*
- * @param array of mixed Data Series
- * @return real
+ * Excel Function:
+ * IMSUM(complexNumber[,complexNumber[,...]])
+ *
+ * @param string $complexNumber,... Series of complex numbers to add
+ * @return string
*/
public static function IMSUM() {
// Return value
@@ -1823,9 +2119,6 @@ class PHPExcel_Calculation_Engineering {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
if ($activeSuffix == '') {
$activeSuffix = $parsedComplex['suffix'];
@@ -1847,8 +2140,11 @@ class PHPExcel_Calculation_Engineering {
*
* Returns the product of two or more complex numbers in x + yi or x + yj text format.
*
- * @param array of mixed Data Series
- * @return real
+ * Excel Function:
+ * IMPRODUCT(complexNumber[,complexNumber[,...]])
+ *
+ * @param string $complexNumber,... Series of complex numbers to multiply
+ * @return string
*/
public static function IMPRODUCT() {
// Return value
@@ -1859,9 +2155,7 @@ class PHPExcel_Calculation_Engineering {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg);
- if (!is_array($parsedComplex)) {
- return $parsedComplex;
- }
+
$workValue = $returnValue;
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
$activeSuffix = $parsedComplex['suffix'];
@@ -1878,13 +2172,19 @@ class PHPExcel_Calculation_Engineering {
/**
- * DELTA
+ * DELTA
*
- * Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise.
+ * Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise.
+ * Use this function to filter a set of values. For example, by summing several DELTA
+ * functions you calculate the count of equal pairs. This function is also known as the
+ * Kronecker Delta function.
*
- * @param float $a
- * @param float $b
- * @return int
+ * Excel Function:
+ * DELTA(a[,b])
+ *
+ * @param float $a The first number.
+ * @param float $b The second number. If omitted, b is assumed to be zero.
+ * @return int
*/
public static function DELTA($a, $b=0) {
$a = PHPExcel_Calculation_Functions::flattenSingleValue($a);
@@ -1895,13 +2195,19 @@ class PHPExcel_Calculation_Engineering {
/**
- * GESTEP
+ * GESTEP
*
- * Returns 1 if number = step; returns 0 (zero) otherwise
+ * Excel Function:
+ * GESTEP(number[,step])
*
- * @param float $number
- * @param float $step
- * @return int
+ * Returns 1 if number >= step; returns 0 (zero) otherwise
+ * Use this function to filter a set of values. For example, by summing several GESTEP
+ * functions you calculate the count of values that exceed a threshold.
+ *
+ * @param float $number The value to test against step.
+ * @param float $step The threshold value.
+ * If you omit a value for step, GESTEP uses zero.
+ * @return int
*/
public static function GESTEP($number, $step=0) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
@@ -1939,30 +2245,32 @@ class PHPExcel_Calculation_Engineering {
/**
- * ERF
+ * ERF
*
- * Returns the error function integrated between lower_limit and upper_limit
+ * Returns the error function integrated between the lower and upper bound arguments.
*
- * @param float $lower lower bound for integrating ERF
- * @param float $upper upper bound for integrating ERF.
+ * Note: In Excel 2007 or earlier, if you input a negative value for the upper or lower bound arguments,
+ * the function would return a #NUM! error. However, in Excel 2010, the function algorithm was
+ * improved, so that it can now calculate the function for both positive and negative ranges.
+ * PHPExcel follows Excel 2010 behaviour, and accepts nagative arguments.
+ *
+ * Excel Function:
+ * ERF(lower[,upper])
+ *
+ * @param float $lower lower bound for integrating ERF
+ * @param float $upper upper bound for integrating ERF.
* If omitted, ERF integrates between zero and lower_limit
- * @return int
+ * @return float
*/
- public static function ERF($lower, $upper = null) {
+ public static function ERF($lower, $upper = NULL) {
$lower = PHPExcel_Calculation_Functions::flattenSingleValue($lower);
$upper = PHPExcel_Calculation_Functions::flattenSingleValue($upper);
if (is_numeric($lower)) {
- if ($lower < 0) {
- return PHPExcel_Calculation_Functions::NaN();
- }
if (is_null($upper)) {
return self::_erfVal($lower);
}
if (is_numeric($upper)) {
- if ($upper < 0) {
- return PHPExcel_Calculation_Functions::NaN();
- }
return self::_erfVal($upper) - self::_erfVal($lower);
}
}
@@ -2003,20 +2311,25 @@ class PHPExcel_Calculation_Engineering {
/**
- * ERFC
+ * ERFC
*
- * Returns the complementary ERF function integrated between x and infinity
+ * Returns the complementary ERF function integrated between x and infinity
*
- * @param float $x The lower bound for integrating ERF
- * @return int
+ * Note: In Excel 2007 or earlier, if you input a negative value for the lower bound argument,
+ * the function would return a #NUM! error. However, in Excel 2010, the function algorithm was
+ * improved, so that it can now calculate the function for both positive and negative x values.
+ * PHPExcel follows Excel 2010 behaviour, and accepts nagative arguments.
+ *
+ * Excel Function:
+ * ERFC(x)
+ *
+ * @param float $x The lower bound for integrating ERFC
+ * @return float
*/
public static function ERFC($x) {
- $x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
+ $x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
if (is_numeric($x)) {
- if ($x < 0) {
- return PHPExcel_Calculation_Functions::NaN();
- }
return self::_erfcVal($x);
}
return PHPExcel_Calculation_Functions::VALUE();
@@ -2024,9 +2337,10 @@ class PHPExcel_Calculation_Engineering {
/**
- * getConversionGroups
+ * getConversionGroups
+ * Returns a list of the different conversion groups for UOM conversions
*
- * @return array
+ * @return array
*/
public static function getConversionGroups() {
$conversionGroups = array();
@@ -2038,9 +2352,12 @@ class PHPExcel_Calculation_Engineering {
/**
- * getConversionGroupUnits
+ * getConversionGroupUnits
+ * Returns an array of units of measure, for a specified conversion group, or for all groups
*
- * @return array
+ * @param string $group The group whose units of measure you want to retrieve
+ *
+ * @return array
*/
public static function getConversionGroupUnits($group = NULL) {
$conversionGroups = array();
@@ -2054,9 +2371,9 @@ class PHPExcel_Calculation_Engineering {
/**
- * getConversionGroupUnitDetails
+ * getConversionGroupUnitDetails
*
- * @return array
+ * @return array
*/
public static function getConversionGroupUnitDetails($group = NULL) {
$conversionGroups = array();
@@ -2072,9 +2389,10 @@ class PHPExcel_Calculation_Engineering {
/**
- * getConversionGroups
+ * getConversionMultipliers
+ * Returns an array of the Multiplier prefixes that can be used with Units of Measure in CONVERTUOM()
*
- * @return array
+ * @return array of mixed
*/
public static function getConversionMultipliers() {
return self::$_conversionMultipliers;
@@ -2082,12 +2400,20 @@ class PHPExcel_Calculation_Engineering {
/**
- * CONVERTUOM
+ * CONVERTUOM
*
- * @param float $value
- * @param string $fromUOM
- * @param string $toUOM
- * @return float
+ * Converts a number from one measurement system to another.
+ * For example, CONVERT can translate a table of distances in miles to a table of distances
+ * in kilometers.
+ *
+ * Excel Function:
+ * CONVERT(value,fromUOM,toUOM)
+ *
+ * @param float $value The value in fromUOM to convert.
+ * @param string $fromUOM The units for value.
+ * @param string $toUOM The units for the result.
+ *
+ * @return float
*/
public static function CONVERTUOM($value, $fromUOM, $toUOM) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -2097,7 +2423,7 @@ class PHPExcel_Calculation_Engineering {
if (!is_numeric($value)) {
return PHPExcel_Calculation_Functions::VALUE();
}
- $fromMultiplier = 1;
+ $fromMultiplier = 1.0;
if (isset(self::$_conversionUnits[$fromUOM])) {
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
} else {
@@ -2116,7 +2442,7 @@ class PHPExcel_Calculation_Engineering {
}
$value *= $fromMultiplier;
- $toMultiplier = 1;
+ $toMultiplier = 1.0;
if (isset(self::$_conversionUnits[$toUOM])) {
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
} else {
@@ -2137,12 +2463,14 @@ class PHPExcel_Calculation_Engineering {
return PHPExcel_Calculation_Functions::NA();
}
- if ($fromUOM == $toUOM) {
- return 1.0;
+ if (($fromUOM == $toUOM) && ($fromMultiplier == $toMultiplier)) {
+ // We've already factored $fromMultiplier into the value, so we need
+ // to reverse it again
+ return $value / $fromMultiplier;
} elseif ($unitGroup1 == 'Temperature') {
if (($fromUOM == 'F') || ($fromUOM == 'fah')) {
if (($toUOM == 'F') || ($toUOM == 'fah')) {
- return 1.0;
+ return $value;
} else {
$value = (($value - 32) / 1.8);
if (($toUOM == 'K') || ($toUOM == 'kel')) {
@@ -2152,10 +2480,10 @@ class PHPExcel_Calculation_Engineering {
}
} elseif ((($fromUOM == 'K') || ($fromUOM == 'kel')) &&
(($toUOM == 'K') || ($toUOM == 'kel'))) {
- return 1.0;
+ return $value;
} elseif ((($fromUOM == 'C') || ($fromUOM == 'cel')) &&
(($toUOM == 'C') || ($toUOM == 'cel'))) {
- return 1.0;
+ return $value;
}
if (($toUOM == 'F') || ($toUOM == 'fah')) {
if (($fromUOM == 'K') || ($fromUOM == 'kel')) {
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php
index 6c09d5a1653..31aa287a2a4 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Exception.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Exception extends Exception {
/**
@@ -48,5 +48,5 @@ class PHPExcel_Calculation_Exception extends Exception {
$e->line = $line;
$e->file = $file;
throw $e;
- }
+ }
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php
index cc0caa8a29b..8b89a8fd6f7 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/ExceptionHandler.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_ExceptionHandler {
/**
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php
index bd82ae2595e..8534258e863 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Financial.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -48,24 +48,40 @@ define('FINANCIAL_PRECISION', 1.0e-08);
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Financial {
- private static function _lastDayOfMonth($testDate) {
- $date = clone $testDate;
- $date->modify('+1 day');
- return ($date->format('d') == 1);
+ /**
+ * _lastDayOfMonth
+ *
+ * Returns a boolean TRUE/FALSE indicating if this date is the last date of the month
+ *
+ * @param DateTime $testDate The date for testing
+ * @return boolean
+ */
+ private static function _lastDayOfMonth($testDate)
+ {
+ return ($testDate->format('d') == $testDate->format('t'));
} // function _lastDayOfMonth()
- private static function _firstDayOfMonth($testDate) {
- $date = clone $testDate;
- return ($date->format('d') == 1);
- } // function _lastDayOfMonth()
+ /**
+ * _firstDayOfMonth
+ *
+ * Returns a boolean TRUE/FALSE indicating if this date is the first date of the month
+ *
+ * @param DateTime $testDate The date for testing
+ * @return boolean
+ */
+ private static function _firstDayOfMonth($testDate)
+ {
+ return ($testDate->format('d') == 1);
+ } // function _firstDayOfMonth()
- private static function _coupFirstPeriodDate($settlement, $maturity, $frequency, $next) {
+ private static function _coupFirstPeriodDate($settlement, $maturity, $frequency, $next)
+ {
$months = 12 / $frequency;
$result = PHPExcel_Shared_Date::ExcelToPHPObject($maturity);
@@ -86,7 +102,8 @@ class PHPExcel_Calculation_Financial {
} // function _coupFirstPeriodDate()
- private static function _validFrequency($frequency) {
+ private static function _validFrequency($frequency)
+ {
if (($frequency == 1) || ($frequency == 2) || ($frequency == 4)) {
return true;
}
@@ -98,7 +115,22 @@ class PHPExcel_Calculation_Financial {
} // function _validFrequency()
- private static function _daysPerYear($year,$basis) {
+ /**
+ * _daysPerYear
+ *
+ * Returns the number of days in a specified year, as defined by the "basis" value
+ *
+ * @param integer $year The year against which we're testing
+ * @param integer $basis The type of day count:
+ * 0 or omitted US (NASD) 360
+ * 1 Actual (365 or 366 in a leap year)
+ * 2 360
+ * 3 365
+ * 4 European 360
+ * @return integer
+ */
+ private static function _daysPerYear($year, $basis=0)
+ {
switch ($basis) {
case 0 :
case 2 :
@@ -109,11 +141,7 @@ class PHPExcel_Calculation_Financial {
$daysPerYear = 365;
break;
case 1 :
- if (PHPExcel_Calculation_DateTime::_isLeapYear($year)) {
- $daysPerYear = 366;
- } else {
- $daysPerYear = 365;
- }
+ $daysPerYear = (PHPExcel_Calculation_DateTime::_isLeapYear($year)) ? 366 : 365;
break;
default :
return PHPExcel_Calculation_Functions::NaN();
@@ -122,7 +150,8 @@ class PHPExcel_Calculation_Financial {
} // function _daysPerYear()
- private static function _interestAndPrincipal($rate=0, $per=0, $nper=0, $pv=0, $fv=0, $type=0) {
+ private static function _interestAndPrincipal($rate=0, $per=0, $nper=0, $pv=0, $fv=0, $type=0)
+ {
$pmt = self::PMT($rate, $nper, $pv, $fv, $type);
$capital = $pv;
for ($i = 1; $i<= $per; ++$i) {
@@ -135,34 +164,54 @@ class PHPExcel_Calculation_Financial {
/**
- * ACCRINT
+ * ACCRINT
*
- * Returns the discount rate for a security.
+ * Returns the accrued interest for a security that pays periodic interest.
*
- * @param mixed issue The security's issue date.
- * @param mixed firstinter The security's first interest date.
- * @param mixed settlement The security's settlement date.
- * @param float rate The security's annual coupon rate.
- * @param float par The security's par value.
- * @param int basis The type of day count to use.
+ * Excel Function:
+ * ACCRINT(issue,firstinterest,settlement,rate,par,frequency[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed $issue The security's issue date.
+ * @param mixed $firstinterest The security's first interest date.
+ * @param mixed $settlement The security's settlement date.
+ * The security settlement date is the date after the issue date
+ * when the security is traded to the buyer.
+ * @param float $rate The security's annual coupon rate.
+ * @param float $par The security's par value.
+ * If you omit par, ACCRINT uses $1,000.
+ * @param integer $frequency the number of coupon payments per year.
+ * Valid frequency values are:
+ * 1 Annual
+ * 2 Semi-Annual
+ * 4 Quarterly
+ * If working in Gnumeric Mode, the following frequency options are
+ * also available
+ * 6 Bimonthly
+ * 12 Monthly
+ * @param integer $basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
- public static function ACCRINT($issue, $firstinter, $settlement, $rate, $par=1000, $frequency=1, $basis=0) {
+ public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par=1000, $frequency=1, $basis=0)
+ {
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
- $firstinter = PHPExcel_Calculation_Functions::flattenSingleValue($firstinter);
+ $firstinterest = PHPExcel_Calculation_Functions::flattenSingleValue($firstinterest);
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
- $rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate);
- $par = (is_null($par)) ? 1000 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($par);
- $frequency = (is_null($frequency)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
- $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
+ $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
+ $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par);
+ $frequency = (is_null($frequency)) ? 1 : PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
+ $rate = (float) $rate;
+ $par = (float) $par;
if (($rate <= 0) || ($par <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
@@ -179,31 +228,39 @@ class PHPExcel_Calculation_Financial {
/**
- * ACCRINTM
+ * ACCRINTM
*
- * Returns the discount rate for a security.
+ * Returns the accrued interest for a security that pays interest at maturity.
*
- * @param mixed issue The security's issue date.
- * @param mixed settlement The security's settlement date.
- * @param float rate The security's annual coupon rate.
- * @param float par The security's par value.
- * @param int basis The type of day count to use.
+ * Excel Function:
+ * ACCRINTM(issue,settlement,rate[,par[,basis]])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed issue The security's issue date.
+ * @param mixed settlement The security's settlement (or maturity) date.
+ * @param float rate The security's annual coupon rate.
+ * @param float par The security's par value.
+ * If you omit par, ACCRINT uses $1,000.
+ * @param integer basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function ACCRINTM($issue, $settlement, $rate, $par=1000, $basis=0) {
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
- $rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate);
- $par = (is_null($par)) ? 1000 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($par);
- $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
+ $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
+ $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par);
+ $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
+ $rate = (float) $rate;
+ $par = (float) $par;
if (($rate <= 0) || ($par <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
@@ -218,6 +275,37 @@ class PHPExcel_Calculation_Financial {
} // function ACCRINTM()
+ /**
+ * AMORDEGRC
+ *
+ * Returns the depreciation for each accounting period.
+ * This function is provided for the French accounting system. If an asset is purchased in
+ * the middle of the accounting period, the prorated depreciation is taken into account.
+ * The function is similar to AMORLINC, except that a depreciation coefficient is applied in
+ * the calculation depending on the life of the assets.
+ * This function will return the depreciation until the last period of the life of the assets
+ * or until the cumulated value of depreciation is greater than the cost of the assets minus
+ * the salvage value.
+ *
+ * Excel Function:
+ * AMORDEGRC(cost,purchased,firstPeriod,salvage,period,rate[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float cost The cost of the asset.
+ * @param mixed purchased Date of the purchase of the asset.
+ * @param mixed firstPeriod Date of the end of the first period.
+ * @param mixed salvage The salvage value at the end of the life of the asset.
+ * @param float period The period.
+ * @param float rate Rate of depreciation.
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return float
+ */
public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) {
$cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased);
@@ -227,8 +315,13 @@ class PHPExcel_Calculation_Financial {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
+ // The depreciation coefficients are:
+ // Life of assets (1/rate) Depreciation coefficient
+ // Less than 3 years 1
+ // Between 3 and 4 years 1.5
+ // Between 5 and 6 years 2
+ // More than 6 years 2.5
$fUsePer = 1.0 / $rate;
-
if ($fUsePer < 3.0) {
$amortiseCoeff = 1.0;
} elseif ($fUsePer < 5.0) {
@@ -251,7 +344,7 @@ class PHPExcel_Calculation_Financial {
if ($fRest < 0.0) {
switch ($period - $n) {
case 0 :
- case 1 : return round($cost * 0.5,0);
+ case 1 : return round($cost * 0.5, 0);
break;
default : return 0.0;
break;
@@ -263,6 +356,32 @@ class PHPExcel_Calculation_Financial {
} // function AMORDEGRC()
+ /**
+ * AMORLINC
+ *
+ * Returns the depreciation for each accounting period.
+ * This function is provided for the French accounting system. If an asset is purchased in
+ * the middle of the accounting period, the prorated depreciation is taken into account.
+ *
+ * Excel Function:
+ * AMORLINC(cost,purchased,firstPeriod,salvage,period,rate[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float cost The cost of the asset.
+ * @param mixed purchased Date of the purchase of the asset.
+ * @param mixed firstPeriod Date of the end of the first period.
+ * @param mixed salvage The salvage value at the end of the life of the asset.
+ * @param float period The period.
+ * @param float rate Rate of depreciation.
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return float
+ */
public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) {
$cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased);
@@ -297,6 +416,38 @@ class PHPExcel_Calculation_Financial {
} // function AMORLINC()
+ /**
+ * COUPDAYBS
+ *
+ * Returns the number of days from the beginning of the coupon period to the settlement date.
+ *
+ * Excel Function:
+ * COUPDAYBS(settlement,maturity,frequency[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed settlement The security's settlement date.
+ * The security settlement date is the date after the issue
+ * date when the security is traded to the buyer.
+ * @param mixed maturity The security's maturity date.
+ * The maturity date is the date when the security expires.
+ * @param mixed frequency the number of coupon payments per year.
+ * Valid frequency values are:
+ * 1 Annual
+ * 2 Semi-Annual
+ * 4 Quarterly
+ * If working in Gnumeric Mode, the following frequency options are
+ * also available
+ * 6 Bimonthly
+ * 12 Monthly
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return float
+ */
public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
@@ -323,6 +474,38 @@ class PHPExcel_Calculation_Financial {
} // function COUPDAYBS()
+ /**
+ * COUPDAYS
+ *
+ * Returns the number of days in the coupon period that contains the settlement date.
+ *
+ * Excel Function:
+ * COUPDAYS(settlement,maturity,frequency[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed settlement The security's settlement date.
+ * The security settlement date is the date after the issue
+ * date when the security is traded to the buyer.
+ * @param mixed maturity The security's maturity date.
+ * The maturity date is the date when the security expires.
+ * @param mixed frequency the number of coupon payments per year.
+ * Valid frequency values are:
+ * 1 Annual
+ * 2 Semi-Annual
+ * 4 Quarterly
+ * If working in Gnumeric Mode, the following frequency options are
+ * also available
+ * 6 Bimonthly
+ * 12 Monthly
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return float
+ */
public static function COUPDAYS($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
@@ -361,6 +544,38 @@ class PHPExcel_Calculation_Financial {
} // function COUPDAYS()
+ /**
+ * COUPDAYSNC
+ *
+ * Returns the number of days from the settlement date to the next coupon date.
+ *
+ * Excel Function:
+ * COUPDAYSNC(settlement,maturity,frequency[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed settlement The security's settlement date.
+ * The security settlement date is the date after the issue
+ * date when the security is traded to the buyer.
+ * @param mixed maturity The security's maturity date.
+ * The maturity date is the date when the security expires.
+ * @param mixed frequency the number of coupon payments per year.
+ * Valid frequency values are:
+ * 1 Annual
+ * 2 Semi-Annual
+ * 4 Quarterly
+ * If working in Gnumeric Mode, the following frequency options are
+ * also available
+ * 6 Bimonthly
+ * 12 Monthly
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return float
+ */
public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
@@ -387,6 +602,39 @@ class PHPExcel_Calculation_Financial {
} // function COUPDAYSNC()
+ /**
+ * COUPNCD
+ *
+ * Returns the next coupon date after the settlement date.
+ *
+ * Excel Function:
+ * COUPNCD(settlement,maturity,frequency[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed settlement The security's settlement date.
+ * The security settlement date is the date after the issue
+ * date when the security is traded to the buyer.
+ * @param mixed maturity The security's maturity date.
+ * The maturity date is the date when the security expires.
+ * @param mixed frequency the number of coupon payments per year.
+ * Valid frequency values are:
+ * 1 Annual
+ * 2 Semi-Annual
+ * 4 Quarterly
+ * If working in Gnumeric Mode, the following frequency options are
+ * also available
+ * 6 Bimonthly
+ * 12 Monthly
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
+ * depending on the value of the ReturnDateType flag
+ */
public static function COUPNCD($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
@@ -410,6 +658,39 @@ class PHPExcel_Calculation_Financial {
} // function COUPNCD()
+ /**
+ * COUPNUM
+ *
+ * Returns the number of coupons payable between the settlement date and maturity date,
+ * rounded up to the nearest whole coupon.
+ *
+ * Excel Function:
+ * COUPNUM(settlement,maturity,frequency[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed settlement The security's settlement date.
+ * The security settlement date is the date after the issue
+ * date when the security is traded to the buyer.
+ * @param mixed maturity The security's maturity date.
+ * The maturity date is the date when the security expires.
+ * @param mixed frequency the number of coupon payments per year.
+ * Valid frequency values are:
+ * 1 Annual
+ * 2 Semi-Annual
+ * 4 Quarterly
+ * If working in Gnumeric Mode, the following frequency options are
+ * also available
+ * 6 Bimonthly
+ * 12 Monthly
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return integer
+ */
public static function COUPNUM($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
@@ -448,6 +729,39 @@ class PHPExcel_Calculation_Financial {
} // function COUPNUM()
+ /**
+ * COUPPCD
+ *
+ * Returns the previous coupon date before the settlement date.
+ *
+ * Excel Function:
+ * COUPPCD(settlement,maturity,frequency[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed settlement The security's settlement date.
+ * The security settlement date is the date after the issue
+ * date when the security is traded to the buyer.
+ * @param mixed maturity The security's maturity date.
+ * The maturity date is the date when the security expires.
+ * @param mixed frequency the number of coupon payments per year.
+ * Valid frequency values are:
+ * 1 Annual
+ * 2 Semi-Annual
+ * 4 Quarterly
+ * If working in Gnumeric Mode, the following frequency options are
+ * also available
+ * 6 Bimonthly
+ * 12 Monthly
+ * @param integer basis The type of day count to use.
+ * 0 or omitted US (NASD) 30/360
+ * 1 Actual/actual
+ * 2 Actual/360
+ * 3 Actual/365
+ * 4 European 30/360
+ * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
+ * depending on the value of the ReturnDateType flag
+ */
public static function COUPPCD($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
@@ -472,18 +786,25 @@ class PHPExcel_Calculation_Financial {
/**
- * CUMIPMT
+ * CUMIPMT
*
- * Returns the cumulative interest paid on a loan between start_period and end_period.
+ * Returns the cumulative interest paid on a loan between the start and end periods.
*
- * @param float $rate Interest rate per period
- * @param int $nper Number of periods
- * @param float $pv Present Value
- * @param int start The first period in the calculation.
- * Payment periods are numbered beginning with 1.
- * @param int end The last period in the calculation.
- * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
- * @return float
+ * Excel Function:
+ * CUMIPMT(rate,nper,pv,start,end[,type])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float $rate The Interest rate
+ * @param integer $nper The total number of payment periods
+ * @param float $pv Present Value
+ * @param integer $start The first period in the calculation.
+ * Payment periods are numbered beginning with 1.
+ * @param integer $end The last period in the calculation.
+ * @param integer $type A number 0 or 1 and indicates when payments are due:
+ * 0 or omitted At the end of the period.
+ * 1 At the beginning of the period.
+ * @return float
*/
public static function CUMIPMT($rate, $nper, $pv, $start, $end, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
@@ -512,18 +833,25 @@ class PHPExcel_Calculation_Financial {
/**
- * CUMPRINC
+ * CUMPRINC
*
- * Returns the cumulative principal paid on a loan between start_period and end_period.
+ * Returns the cumulative principal paid on a loan between the start and end periods.
*
- * @param float $rate Interest rate per period
- * @param int $nper Number of periods
- * @param float $pv Present Value
- * @param int start The first period in the calculation.
- * Payment periods are numbered beginning with 1.
- * @param int end The last period in the calculation.
- * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
- * @return float
+ * Excel Function:
+ * CUMPRINC(rate,nper,pv,start,end[,type])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float $rate The Interest rate
+ * @param integer $nper The total number of payment periods
+ * @param float $pv Present Value
+ * @param integer $start The first period in the calculation.
+ * Payment periods are numbered beginning with 1.
+ * @param integer $end The last period in the calculation.
+ * @param integer $type A number 0 or 1 and indicates when payments are due:
+ * 0 or omitted At the end of the period.
+ * 1 At the beginning of the period.
+ * @return float
*/
public static function CUMPRINC($rate, $nper, $pv, $start, $end, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
@@ -552,29 +880,45 @@ class PHPExcel_Calculation_Financial {
/**
- * DB
+ * DB
*
- * Returns the depreciation of an asset for a specified period using the fixed-declining balance method.
- * This form of depreciation is used if you want to get a higher depreciation value at the beginning of the depreciation
- * (as opposed to linear depreciation). The depreciation value is reduced with every depreciation period by the
- * depreciation already deducted from the initial cost.
+ * Returns the depreciation of an asset for a specified period using the
+ * fixed-declining balance method.
+ * This form of depreciation is used if you want to get a higher depreciation value
+ * at the beginning of the depreciation (as opposed to linear depreciation). The
+ * depreciation value is reduced with every depreciation period by the depreciation
+ * already deducted from the initial cost.
*
- * @param float cost Initial cost of the asset.
- * @param float salvage Value at the end of the depreciation. (Sometimes called the salvage value of the asset)
- * @param int life Number of periods over which the asset is depreciated. (Sometimes called the useful life of the asset)
- * @param int period The period for which you want to calculate the depreciation. Period must use the same units as life.
- * @param float month Number of months in the first year. If month is omitted, it defaults to 12.
- * @return float
+ * Excel Function:
+ * DB(cost,salvage,life,period[,month])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float cost Initial cost of the asset.
+ * @param float salvage Value at the end of the depreciation.
+ * (Sometimes called the salvage value of the asset)
+ * @param integer life Number of periods over which the asset is depreciated.
+ * (Sometimes called the useful life of the asset)
+ * @param integer period The period for which you want to calculate the
+ * depreciation. Period must use the same units as life.
+ * @param integer month Number of months in the first year. If month is omitted,
+ * it defaults to 12.
+ * @return float
*/
public static function DB($cost, $salvage, $life, $period, $month=12) {
- $cost = (float) PHPExcel_Calculation_Functions::flattenSingleValue($cost);
- $salvage = (float) PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
- $life = (int) PHPExcel_Calculation_Functions::flattenSingleValue($life);
- $period = (int) PHPExcel_Calculation_Functions::flattenSingleValue($period);
- $month = (int) PHPExcel_Calculation_Functions::flattenSingleValue($month);
+ $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
+ $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
+ $life = PHPExcel_Calculation_Functions::flattenSingleValue($life);
+ $period = PHPExcel_Calculation_Functions::flattenSingleValue($period);
+ $month = PHPExcel_Calculation_Functions::flattenSingleValue($month);
// Validate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($month))) {
+ $cost = (float) $cost;
+ $salvage = (float) $salvage;
+ $life = (int) $life;
+ $period = (int) $period;
+ $month = (int) $month;
if ($cost == 0) {
return 0.0;
} elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) {
@@ -606,27 +950,42 @@ class PHPExcel_Calculation_Financial {
/**
- * DDB
+ * DDB
*
- * Returns the depreciation of an asset for a specified period using the double-declining balance method or some other method you specify.
+ * Returns the depreciation of an asset for a specified period using the
+ * double-declining balance method or some other method you specify.
*
- * @param float cost Initial cost of the asset.
- * @param float salvage Value at the end of the depreciation. (Sometimes called the salvage value of the asset)
- * @param int life Number of periods over which the asset is depreciated. (Sometimes called the useful life of the asset)
- * @param int period The period for which you want to calculate the depreciation. Period must use the same units as life.
- * @param float factor The rate at which the balance declines.
- * If factor is omitted, it is assumed to be 2 (the double-declining balance method).
- * @return float
+ * Excel Function:
+ * DDB(cost,salvage,life,period[,factor])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float cost Initial cost of the asset.
+ * @param float salvage Value at the end of the depreciation.
+ * (Sometimes called the salvage value of the asset)
+ * @param integer life Number of periods over which the asset is depreciated.
+ * (Sometimes called the useful life of the asset)
+ * @param integer period The period for which you want to calculate the
+ * depreciation. Period must use the same units as life.
+ * @param float factor The rate at which the balance declines.
+ * If factor is omitted, it is assumed to be 2 (the
+ * double-declining balance method).
+ * @return float
*/
public static function DDB($cost, $salvage, $life, $period, $factor=2.0) {
- $cost = (float) PHPExcel_Calculation_Functions::flattenSingleValue($cost);
- $salvage = (float) PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
- $life = (int) PHPExcel_Calculation_Functions::flattenSingleValue($life);
- $period = (int) PHPExcel_Calculation_Functions::flattenSingleValue($period);
- $factor = (float) PHPExcel_Calculation_Functions::flattenSingleValue($factor);
+ $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
+ $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
+ $life = PHPExcel_Calculation_Functions::flattenSingleValue($life);
+ $period = PHPExcel_Calculation_Functions::flattenSingleValue($period);
+ $factor = PHPExcel_Calculation_Functions::flattenSingleValue($factor);
// Validate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($factor))) {
+ $cost = (float) $cost;
+ $salvage = (float) $salvage;
+ $life = (int) $life;
+ $period = (int) $period;
+ $factor = (float) $factor;
if (($cost <= 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($factor <= 0.0) || ($period > $life)) {
return PHPExcel_Calculation_Functions::NaN();
}
@@ -650,33 +1009,42 @@ class PHPExcel_Calculation_Financial {
/**
- * DISC
+ * DISC
*
- * Returns the discount rate for a security.
+ * Returns the discount rate for a security.
*
- * @param mixed settlement The security's settlement date.
- * The security settlement date is the date after the issue date when the security is traded to the buyer.
- * @param mixed maturity The security's maturity date.
+ * Excel Function:
+ * DISC(settlement,maturity,price,redemption[,basis])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param mixed settlement The security's settlement date.
+ * The security settlement date is the date after the issue
+ * date when the security is traded to the buyer.
+ * @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
- * @param int price The security's price per $100 face value.
- * @param int redemption the security's redemption value per $100 face value.
- * @param int basis The type of day count to use.
+ * @param integer price The security's price per $100 face value.
+ * @param integer redemption The security's redemption value per $100 face value.
+ * @param integer basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function DISC($settlement, $maturity, $price, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
- $price = (float) PHPExcel_Calculation_Functions::flattenSingleValue($price);
- $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
- $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
+ $price = PHPExcel_Calculation_Functions::flattenSingleValue($price);
+ $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
+ $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($price)) && (is_numeric($redemption)) && (is_numeric($basis))) {
+ $price = (float) $price;
+ $redemption = (float) $redemption;
+ $basis = (int) $basis;
if (($price <= 0) || ($redemption <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
@@ -695,11 +1063,17 @@ class PHPExcel_Calculation_Financial {
/**
* DOLLARDE
*
- * Converts a dollar price expressed as an integer part and a fraction part into a dollar price expressed as a decimal number.
+ * Converts a dollar price expressed as an integer part and a fraction
+ * part into a dollar price expressed as a decimal number.
* Fractional dollar numbers are sometimes used for security prices.
*
+ * Excel Function:
+ * DOLLARDE(fractional_dollar,fraction)
+ *
+ * @access public
+ * @category Financial Functions
* @param float $fractional_dollar Fractional Dollar
- * @param int $fraction Fraction
+ * @param integer $fraction Fraction
* @return float
*/
public static function DOLLARDE($fractional_dollar = Null, $fraction = 0) {
@@ -725,11 +1099,17 @@ class PHPExcel_Calculation_Financial {
/**
* DOLLARFR
*
- * Converts a dollar price expressed as a decimal number into a dollar price expressed as a fraction.
+ * Converts a dollar price expressed as a decimal number into a dollar price
+ * expressed as a fraction.
* Fractional dollar numbers are sometimes used for security prices.
*
+ * Excel Function:
+ * DOLLARFR(decimal_dollar,fraction)
+ *
+ * @access public
+ * @category Financial Functions
* @param float $decimal_dollar Decimal Dollar
- * @param int $fraction Fraction
+ * @param integer $fraction Fraction
* @return float
*/
public static function DOLLARFR($decimal_dollar = Null, $fraction = 0) {
@@ -755,10 +1135,16 @@ class PHPExcel_Calculation_Financial {
/**
* EFFECT
*
- * Returns the effective interest rate given the nominal rate and the number of compounding payments per year.
+ * Returns the effective interest rate given the nominal rate and the number of
+ * compounding payments per year.
*
+ * Excel Function:
+ * EFFECT(nominal_rate,npery)
+ *
+ * @access public
+ * @category Financial Functions
* @param float $nominal_rate Nominal interest rate
- * @param int $npery Number of compounding payments per year
+ * @param integer $npery Number of compounding payments per year
* @return float
*/
public static function EFFECT($nominal_rate = 0, $npery = 0) {
@@ -779,11 +1165,21 @@ class PHPExcel_Calculation_Financial {
*
* Returns the Future Value of a cash flow with constant payments and interest rate (annuities).
*
- * @param float $rate Interest rate per period
- * @param int $nper Number of periods
- * @param float $pmt Periodic payment (annuity)
- * @param float $pv Present Value
- * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
+ * Excel Function:
+ * FV(rate,nper,pmt[,pv[,type]])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float $rate The interest rate per period
+ * @param int $nper Total number of payment periods in an annuity
+ * @param float $pmt The payment made each period: it cannot change over the
+ * life of the annuity. Typically, pmt contains principal
+ * and interest but no other fees or taxes.
+ * @param float $pv Present Value, or the lump-sum amount that a series of
+ * future payments is worth right now.
+ * @param integer $type A number 0 or 1 and indicates when payments are due:
+ * 0 or omitted At the end of the period.
+ * 1 At the beginning of the period.
* @return float
*/
public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0) {
@@ -824,33 +1220,39 @@ class PHPExcel_Calculation_Financial {
/**
- * INTRATE
+ * INTRATE
*
- * Returns the interest rate for a fully invested security.
+ * Returns the interest rate for a fully invested security.
*
- * @param mixed settlement The security's settlement date.
+ * Excel Function:
+ * INTRATE(settlement,maturity,investment,redemption[,basis])
+ *
+ * @param mixed settlement The security's settlement date.
* The security settlement date is the date after the issue date when the security is traded to the buyer.
- * @param mixed maturity The security's maturity date.
+ * @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
- * @param int investment The amount invested in the security.
- * @param int redemption The amount to be received at maturity.
- * @param int basis The type of day count to use.
+ * @param integer investment The amount invested in the security.
+ * @param integer redemption The amount to be received at maturity.
+ * @param integer basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
- $investment = (float) PHPExcel_Calculation_Functions::flattenSingleValue($investment);
- $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
- $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
+ $investment = PHPExcel_Calculation_Functions::flattenSingleValue($investment);
+ $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
+ $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($investment)) && (is_numeric($redemption)) && (is_numeric($basis))) {
+ $investment = (float) $investment;
+ $redemption = (float) $redemption;
+ $basis = (int) $basis;
if (($investment <= 0) || ($redemption <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
@@ -867,17 +1269,17 @@ class PHPExcel_Calculation_Financial {
/**
- * IPMT
+ * IPMT
*
- * Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
+ * Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
*
- * @param float $rate Interest rate per period
- * @param int $per Period for which we want to find the interest
- * @param int $nper Number of periods
- * @param float $pv Present Value
- * @param float $fv Future Value
- * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
- * @return float
+ * @param float $rate Interest rate per period
+ * @param int $per Period for which we want to find the interest
+ * @param int $nper Number of periods
+ * @param float $pv Present Value
+ * @param float $fv Future Value
+ * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
+ * @return float
*/
public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
@@ -1040,12 +1442,12 @@ class PHPExcel_Calculation_Financial {
*
* Returns the number of periods for a cash flow with constant periodic payments (annuities), and interest rate.
*
- * @param float $rate Interest rate per period
- * @param int $pmt Periodic payment (annuity)
- * @param float $pv Present Value
- * @param float $fv Future Value
- * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
- * @return float
+ * @param float $rate Interest rate per period
+ * @param int $pmt Periodic payment (annuity)
+ * @param float $pv Present Value
+ * @param float $fv Future Value
+ * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
+ * @return float
*/
public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
@@ -1138,17 +1540,17 @@ class PHPExcel_Calculation_Financial {
/**
- * PPMT
+ * PPMT
*
- * Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
+ * Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
*
- * @param float $rate Interest rate per period
- * @param int $per Period for which we want to find the interest
- * @param int $nper Number of periods
- * @param float $pv Present Value
- * @param float $fv Future Value
- * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
- * @return float
+ * @param float $rate Interest rate per period
+ * @param int $per Period for which we want to find the interest
+ * @param int $nper Number of periods
+ * @param float $pv Present Value
+ * @param float $fv Future Value
+ * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
+ * @return float
*/
public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
@@ -1214,23 +1616,23 @@ class PHPExcel_Calculation_Financial {
/**
- * PRICEDISC
+ * PRICEDISC
*
- * Returns the price per $100 face value of a discounted security.
+ * Returns the price per $100 face value of a discounted security.
*
- * @param mixed settlement The security's settlement date.
+ * @param mixed settlement The security's settlement date.
* The security settlement date is the date after the issue date when the security is traded to the buyer.
- * @param mixed maturity The security's maturity date.
+ * @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
- * @param int discount The security's discount rate.
- * @param int redemption The security's redemption value per $100 face value.
- * @param int basis The type of day count to use.
+ * @param int discount The security's discount rate.
+ * @param int redemption The security's redemption value per $100 face value.
+ * @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
@@ -1257,24 +1659,24 @@ class PHPExcel_Calculation_Financial {
/**
- * PRICEMAT
+ * PRICEMAT
*
- * Returns the price per $100 face value of a security that pays interest at maturity.
+ * Returns the price per $100 face value of a security that pays interest at maturity.
*
- * @param mixed settlement The security's settlement date.
+ * @param mixed settlement The security's settlement date.
* The security's settlement date is the date after the issue date when the security is traded to the buyer.
- * @param mixed maturity The security's maturity date.
+ * @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
- * @param mixed issue The security's issue date.
- * @param int rate The security's interest rate at date of issue.
- * @param int yield The security's annual yield.
- * @param int basis The type of day count to use.
+ * @param mixed issue The security's issue date.
+ * @param int rate The security's interest rate at date of issue.
+ * @param int yield The security's annual yield.
+ * @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
@@ -1356,6 +1758,32 @@ class PHPExcel_Calculation_Financial {
/**
* RATE
*
+ * Returns the interest rate per period of an annuity.
+ * RATE is calculated by iteration and can have zero or more solutions.
+ * If the successive results of RATE do not converge to within 0.0000001 after 20 iterations,
+ * RATE returns the #NUM! error value.
+ *
+ * Excel Function:
+ * RATE(nper,pmt,pv[,fv[,type[,guess]]])
+ *
+ * @access public
+ * @category Financial Functions
+ * @param float nper The total number of payment periods in an annuity.
+ * @param float pmt The payment made each period and cannot change over the life
+ * of the annuity.
+ * Typically, pmt includes principal and interest but no other
+ * fees or taxes.
+ * @param float pv The present value - the total amount that a series of future
+ * payments is worth now.
+ * @param float fv The future value, or a cash balance you want to attain after
+ * the last payment is made. If fv is omitted, it is assumed
+ * to be 0 (the future value of a loan, for example, is 0).
+ * @param integer type A number 0 or 1 and indicates when payments are due:
+ * 0 or omitted At the end of the period.
+ * 1 At the beginning of the period.
+ * @param float guess Your guess for what the rate will be.
+ * If you omit guess, it is assumed to be 10 percent.
+ * @return float
**/
public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1) {
$nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
@@ -1382,6 +1810,8 @@ class PHPExcel_Calculation_Financial {
$rate = ($y1 * $x0 - $y0 * $x1) / ($y1 - $y0);
$x0 = $x1;
$x1 = $rate;
+ if (($nper * abs($pmt)) > ($pv - $fv))
+ $x1 = abs($x1);
if (abs($rate) < FINANCIAL_PRECISION) {
$y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv;
@@ -1399,23 +1829,23 @@ class PHPExcel_Calculation_Financial {
/**
- * RECEIVED
+ * RECEIVED
*
- * Returns the price per $100 face value of a discounted security.
+ * Returns the price per $100 face value of a discounted security.
*
- * @param mixed settlement The security's settlement date.
+ * @param mixed settlement The security's settlement date.
* The security settlement date is the date after the issue date when the security is traded to the buyer.
- * @param mixed maturity The security's maturity date.
+ * @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
- * @param int investment The amount invested in the security.
- * @param int discount The security's discount rate.
- * @param int basis The type of day count to use.
+ * @param int investment The amount invested in the security.
+ * @param int discount The security's discount rate.
+ * @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
@@ -1496,16 +1926,16 @@ class PHPExcel_Calculation_Financial {
/**
- * TBILLEQ
+ * TBILLEQ
*
- * Returns the bond-equivalent yield for a Treasury bill.
+ * Returns the bond-equivalent yield for a Treasury bill.
*
- * @param mixed settlement The Treasury bill's settlement date.
+ * @param mixed settlement The Treasury bill's settlement date.
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
- * @param mixed maturity The Treasury bill's maturity date.
+ * @param mixed maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
- * @param int discount The Treasury bill's discount rate.
- * @return float
+ * @param int discount The Treasury bill's discount rate.
+ * @return float
*/
public static function TBILLEQ($settlement, $maturity, $discount) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
@@ -1534,16 +1964,16 @@ class PHPExcel_Calculation_Financial {
/**
- * TBILLPRICE
+ * TBILLPRICE
*
- * Returns the yield for a Treasury bill.
+ * Returns the yield for a Treasury bill.
*
- * @param mixed settlement The Treasury bill's settlement date.
+ * @param mixed settlement The Treasury bill's settlement date.
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
- * @param mixed maturity The Treasury bill's maturity date.
+ * @param mixed maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
- * @param int discount The Treasury bill's discount rate.
- * @return float
+ * @param int discount The Treasury bill's discount rate.
+ * @return float
*/
public static function TBILLPRICE($settlement, $maturity, $discount) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
@@ -1586,16 +2016,16 @@ class PHPExcel_Calculation_Financial {
/**
- * TBILLYIELD
+ * TBILLYIELD
*
- * Returns the yield for a Treasury bill.
+ * Returns the yield for a Treasury bill.
*
- * @param mixed settlement The Treasury bill's settlement date.
+ * @param mixed settlement The Treasury bill's settlement date.
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
- * @param mixed maturity The Treasury bill's maturity date.
+ * @param mixed maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
- * @param int price The Treasury bill's price per $100 face value.
- * @return float
+ * @param int price The Treasury bill's price per $100 face value.
+ * @return float
*/
public static function TBILLYIELD($settlement, $maturity, $price) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
@@ -1672,18 +2102,18 @@ class PHPExcel_Calculation_Financial {
/**
- * XNPV
+ * XNPV
*
- * Returns the net present value for a schedule of cash flows that is not necessarily periodic.
- * To calculate the net present value for a series of cash flows that is periodic, use the NPV function.
+ * Returns the net present value for a schedule of cash flows that is not necessarily periodic.
+ * To calculate the net present value for a series of cash flows that is periodic, use the NPV function.
*
- * Excel Function:
+ * Excel Function:
* =XNPV(rate,values,dates)
*
- * @param float $rate The discount rate to apply to the cash flows.
- * @param array of float $values A series of cash flows that corresponds to a schedule of payments in dates. The first payment is optional and corresponds to a cost or payment that occurs at the beginning of the investment. If the first value is a cost or payment, it must be a negative value. All succeeding payments are discounted based on a 365-day year. The series of values must contain at least one positive value and one negative value.
- * @param array of mixed $dates A schedule of payment dates that corresponds to the cash flow payments. The first payment date indicates the beginning of the schedule of payments. All other dates must be later than this date, but they may occur in any order.
- * @return float
+ * @param float $rate The discount rate to apply to the cash flows.
+ * @param array of float $values A series of cash flows that corresponds to a schedule of payments in dates. The first payment is optional and corresponds to a cost or payment that occurs at the beginning of the investment. If the first value is a cost or payment, it must be a negative value. All succeeding payments are discounted based on a 365-day year. The series of values must contain at least one positive value and one negative value.
+ * @param array of mixed $dates A schedule of payment dates that corresponds to the cash flow payments. The first payment date indicates the beginning of the schedule of payments. All other dates must be later than this date, but they may occur in any order.
+ * @return float
*/
public static function XNPV($rate, $values, $dates) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
@@ -1705,23 +2135,23 @@ class PHPExcel_Calculation_Financial {
/**
- * YIELDDISC
+ * YIELDDISC
*
- * Returns the annual yield of a security that pays interest at maturity.
+ * Returns the annual yield of a security that pays interest at maturity.
*
- * @param mixed settlement The security's settlement date.
+ * @param mixed settlement The security's settlement date.
* The security's settlement date is the date after the issue date when the security is traded to the buyer.
- * @param mixed maturity The security's maturity date.
+ * @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
- * @param int price The security's price per $100 face value.
- * @param int redemption The security's redemption value per $100 face value.
- * @param int basis The type of day count to use.
+ * @param int price The security's price per $100 face value.
+ * @param int redemption The security's redemption value per $100 face value.
+ * @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
@@ -1753,24 +2183,24 @@ class PHPExcel_Calculation_Financial {
/**
- * YIELDMAT
+ * YIELDMAT
*
- * Returns the annual yield of a security that pays interest at maturity.
+ * Returns the annual yield of a security that pays interest at maturity.
*
- * @param mixed settlement The security's settlement date.
+ * @param mixed settlement The security's settlement date.
* The security's settlement date is the date after the issue date when the security is traded to the buyer.
- * @param mixed maturity The security's maturity date.
+ * @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
- * @param mixed issue The security's issue date.
- * @param int rate The security's interest rate at date of issue.
- * @param int price The security's price per $100 face value.
- * @param int basis The type of day count to use.
+ * @param mixed issue The security's issue date.
+ * @param int rate The security's interest rate at date of issue.
+ * @param int price The security's price per $100 face value.
+ * @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
- * @return float
+ * @return float
*/
public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php
index f8ffe579f45..7318a5b74b4 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaParser.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -54,7 +54,7 @@ PARTLY BASED ON:
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_FormulaParser {
/* Character constants */
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php
index 3045a9a8938..b8a2571aebf 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/FormulaToken.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -55,7 +55,7 @@ PARTLY BASED ON:
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_FormulaToken {
/* Token types */
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php
index 14c9294f258..88f8c3b5471 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Function.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Function {
/* Function categories */
@@ -76,9 +76,9 @@ class PHPExcel_Calculation_Function {
* @param string $pPHPExcelName PHPExcel function mapping
* @throws Exception
*/
- public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
+ public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL)
{
- if (!is_null($pCategory) && !is_null($pExcelName) && !is_null($pPHPExcelName)) {
+ if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) {
// Initialise values
$this->_category = $pCategory;
$this->_excelName = $pExcelName;
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php
index beab5a6ab5c..e0a5629559d 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Functions.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -54,7 +54,7 @@ define('PRECISION', 8.88E-016);
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Functions {
@@ -69,26 +69,26 @@ class PHPExcel_Calculation_Functions {
/**
- * Compatibility mode to use for error checking and responses
+ * Compatibility mode to use for error checking and responses
*
- * @access private
- * @var string
+ * @access private
+ * @var string
*/
protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
/**
- * Data Type to use when returning date values
+ * Data Type to use when returning date values
*
- * @access private
- * @var string
+ * @access private
+ * @var string
*/
protected static $ReturnDateType = self::RETURNDATE_EXCEL;
/**
- * List of error codes
+ * List of error codes
*
- * @access private
- * @var array
+ * @access private
+ * @var array
*/
protected static $_errorCodes = array( 'null' => '#NULL!',
'divisionbyzero' => '#DIV/0!',
@@ -102,16 +102,16 @@ class PHPExcel_Calculation_Functions {
/**
- * Set the Compatibility Mode
+ * Set the Compatibility Mode
*
- * @access public
- * @category Function Configuration
- * @param string $compatibilityMode Compatibility Mode
+ * @access public
+ * @category Function Configuration
+ * @param string $compatibilityMode Compatibility Mode
* Permitted values are:
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
- * @return boolean (Success or Failure)
+ * @return boolean (Success or Failure)
*/
public static function setCompatibilityMode($compatibilityMode) {
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
@@ -125,11 +125,11 @@ class PHPExcel_Calculation_Functions {
/**
- * Return the current Compatibility Mode
+ * Return the current Compatibility Mode
*
- * @access public
- * @category Function Configuration
- * @return string Compatibility Mode
+ * @access public
+ * @category Function Configuration
+ * @return string Compatibility Mode
* Possible Return values are:
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
@@ -141,16 +141,16 @@ class PHPExcel_Calculation_Functions {
/**
- * Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
+ * Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
*
- * @access public
- * @category Function Configuration
- * @param string $returnDateType Return Date Format
+ * @access public
+ * @category Function Configuration
+ * @param string $returnDateType Return Date Format
* Permitted values are:
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
- * @return boolean Success or failure
+ * @return boolean Success or failure
*/
public static function setReturnDateType($returnDateType) {
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
@@ -164,11 +164,11 @@ class PHPExcel_Calculation_Functions {
/**
- * Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
+ * Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
*
- * @access public
- * @category Function Configuration
- * @return string Return Date Format
+ * @access public
+ * @category Function Configuration
+ * @return string Return Date Format
* Possible Return values are:
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
@@ -180,11 +180,11 @@ class PHPExcel_Calculation_Functions {
/**
- * DUMMY
+ * DUMMY
*
- * @access public
- * @category Error Returns
- * @return string #Not Yet Implemented
+ * @access public
+ * @category Error Returns
+ * @return string #Not Yet Implemented
*/
public static function DUMMY() {
return '#Not Yet Implemented';
@@ -192,11 +192,11 @@ class PHPExcel_Calculation_Functions {
/**
- * DIV0
+ * DIV0
*
- * @access public
- * @category Error Returns
- * @return string #Not Yet Implemented
+ * @access public
+ * @category Error Returns
+ * @return string #Not Yet Implemented
*/
public static function DIV0() {
return self::$_errorCodes['divisionbyzero'];
@@ -204,17 +204,17 @@ class PHPExcel_Calculation_Functions {
/**
- * NA
+ * NA
*
- * Excel Function:
+ * Excel Function:
* =NA()
*
- * Returns the error value #N/A
+ * Returns the error value #N/A
* #N/A is the error value that means "no value is available."
*
- * @access public
- * @category Logical Functions
- * @return string #N/A!
+ * @access public
+ * @category Logical Functions
+ * @return string #N/A!
*/
public static function NA() {
return self::$_errorCodes['na'];
@@ -222,13 +222,13 @@ class PHPExcel_Calculation_Functions {
/**
- * NaN
+ * NaN
*
- * Returns the error value #NUM!
+ * Returns the error value #NUM!
*
- * @access public
- * @category Error Returns
- * @return string #NUM!
+ * @access public
+ * @category Error Returns
+ * @return string #NUM!
*/
public static function NaN() {
return self::$_errorCodes['num'];
@@ -236,13 +236,13 @@ class PHPExcel_Calculation_Functions {
/**
- * NAME
+ * NAME
*
- * Returns the error value #NAME?
+ * Returns the error value #NAME?
*
- * @access public
- * @category Error Returns
- * @return string #NAME?
+ * @access public
+ * @category Error Returns
+ * @return string #NAME?
*/
public static function NAME() {
return self::$_errorCodes['name'];
@@ -250,13 +250,13 @@ class PHPExcel_Calculation_Functions {
/**
- * REF
+ * REF
*
- * Returns the error value #REF!
+ * Returns the error value #REF!
*
- * @access public
- * @category Error Returns
- * @return string #REF!
+ * @access public
+ * @category Error Returns
+ * @return string #REF!
*/
public static function REF() {
return self::$_errorCodes['reference'];
@@ -264,13 +264,13 @@ class PHPExcel_Calculation_Functions {
/**
- * NULL
+ * NULL
*
- * Returns the error value #NULL!
+ * Returns the error value #NULL!
*
- * @access public
- * @category Error Returns
- * @return string #REF!
+ * @access public
+ * @category Error Returns
+ * @return string #REF!
*/
public static function NULL() {
return self::$_errorCodes['null'];
@@ -278,13 +278,13 @@ class PHPExcel_Calculation_Functions {
/**
- * VALUE
+ * VALUE
*
- * Returns the error value #VALUE!
+ * Returns the error value #VALUE!
*
- * @access public
- * @category Error Returns
- * @return string #VALUE!
+ * @access public
+ * @category Error Returns
+ * @return string #VALUE!
*/
public static function VALUE() {
return self::$_errorCodes['value'];
@@ -321,32 +321,32 @@ class PHPExcel_Calculation_Functions {
/**
- * ERROR_TYPE
+ * ERROR_TYPE
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
public static function ERROR_TYPE($value = '') {
$value = self::flattenSingleValue($value);
$i = 1;
foreach(self::$_errorCodes as $errorCode) {
- if ($value == $errorCode) {
+ if ($value === $errorCode) {
return $i;
}
++$i;
}
- return self::$_errorCodes['na'];
+ return self::NA();
} // function ERROR_TYPE()
/**
- * IS_BLANK
+ * IS_BLANK
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function IS_BLANK($value=null) {
+ public static function IS_BLANK($value = NULL) {
if (!is_null($value)) {
$value = self::flattenSingleValue($value);
}
@@ -356,10 +356,10 @@ class PHPExcel_Calculation_Functions {
/**
- * IS_ERR
+ * IS_ERR
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
public static function IS_ERR($value = '') {
$value = self::flattenSingleValue($value);
@@ -369,70 +369,74 @@ class PHPExcel_Calculation_Functions {
/**
- * IS_ERROR
+ * IS_ERROR
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
public static function IS_ERROR($value = '') {
$value = self::flattenSingleValue($value);
+ if (!is_string($value))
+ return false;
return in_array($value, array_values(self::$_errorCodes));
} // function IS_ERROR()
/**
- * IS_NA
+ * IS_NA
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
public static function IS_NA($value = '') {
$value = self::flattenSingleValue($value);
- return ($value === self::$_errorCodes['na']);
+ return ($value === self::NA());
} // function IS_NA()
/**
- * IS_EVEN
+ * IS_EVEN
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function IS_EVEN($value = 0) {
- $value = self::flattenSingleValue($value);
+ public static function IS_EVEN($value = NULL) {
+ $value = self::flattenSingleValue($value);
- if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
- return self::$_errorCodes['value'];
- }
+ if ($value === NULL)
+ return self::NAME();
+ if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
+ return self::VALUE();
return ($value % 2 == 0);
} // function IS_EVEN()
/**
- * IS_ODD
+ * IS_ODD
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function IS_ODD($value = null) {
- $value = self::flattenSingleValue($value);
+ public static function IS_ODD($value = NULL) {
+ $value = self::flattenSingleValue($value);
- if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
- return self::$_errorCodes['value'];
- }
+ if ($value === NULL)
+ return self::NAME();
+ if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
+ return self::VALUE();
return (abs($value) % 2 == 1);
} // function IS_ODD()
/**
- * IS_NUMBER
+ * IS_NUMBER
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function IS_NUMBER($value = 0) {
+ public static function IS_NUMBER($value = NULL) {
$value = self::flattenSingleValue($value);
if (is_string($value)) {
@@ -443,12 +447,12 @@ class PHPExcel_Calculation_Functions {
/**
- * IS_LOGICAL
+ * IS_LOGICAL
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function IS_LOGICAL($value = true) {
+ public static function IS_LOGICAL($value = NULL) {
$value = self::flattenSingleValue($value);
return is_bool($value);
@@ -456,46 +460,46 @@ class PHPExcel_Calculation_Functions {
/**
- * IS_TEXT
+ * IS_TEXT
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function IS_TEXT($value = '') {
+ public static function IS_TEXT($value = NULL) {
$value = self::flattenSingleValue($value);
- return is_string($value);
+ return (is_string($value) && !self::IS_ERROR($value));
} // function IS_TEXT()
/**
- * IS_NONTEXT
+ * IS_NONTEXT
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function IS_NONTEXT($value = '') {
+ public static function IS_NONTEXT($value = NULL) {
return !self::IS_TEXT($value);
} // function IS_NONTEXT()
/**
- * VERSION
+ * VERSION
*
- * @return string Version information
+ * @return string Version information
*/
public static function VERSION() {
- return 'PHPExcel 1.7.6, 2011-02-27';
+ return 'PHPExcel 1.7.8, 2012-10-12';
} // function VERSION()
/**
- * N
+ * N
*
- * Returns a value converted to a number
+ * Returns a value converted to a number
*
- * @param value The value you want converted
- * @return number N converts values listed in the following table
+ * @param value The value you want converted
+ * @return number N converts values listed in the following table
* If value is or refers to N returns
* A number That number
* A date The serial number of that date
@@ -504,7 +508,7 @@ class PHPExcel_Calculation_Functions {
* An error value The error value
* Anything else 0
*/
- public static function N($value) {
+ public static function N($value = NULL) {
while (is_array($value)) {
$value = array_shift($value);
}
@@ -530,12 +534,12 @@ class PHPExcel_Calculation_Functions {
/**
- * TYPE
+ * TYPE
*
- * Returns a number that identifies the type of a value
+ * Returns a number that identifies the type of a value
*
- * @param value The value you want tested
- * @return number N converts values listed in the following table
+ * @param value The value you want tested
+ * @return number N converts values listed in the following table
* If value is or refers to N returns
* A number 1
* Text 2
@@ -543,7 +547,7 @@ class PHPExcel_Calculation_Functions {
* An error value 16
* Array or Matrix 64
*/
- public static function TYPE($value) {
+ public static function TYPE($value = NULL) {
$value = self::flattenArrayIndexed($value);
if (is_array($value) && (count($value) > 1)) {
$a = array_keys($value);
@@ -555,13 +559,13 @@ class PHPExcel_Calculation_Functions {
} elseif (self::isMatrixValue($a)) {
return 64;
}
- } elseif(count($value) == 0) {
+ } elseif(empty($value)) {
// Empty Cell
return 1;
}
$value = self::flattenSingleValue($value);
- if ((is_float($value)) || (is_int($value))) {
+ if (($value === NULL) || (is_float($value)) || (is_int($value))) {
return 1;
} elseif(is_bool($value)) {
return 4;
@@ -580,10 +584,10 @@ class PHPExcel_Calculation_Functions {
/**
- * Convert a multi-dimensional array to a simple 1-dimensional array
+ * Convert a multi-dimensional array to a simple 1-dimensional array
*
- * @param array $array Array to be flattened
- * @return array Flattened array
+ * @param array $array Array to be flattened
+ * @return array Flattened array
*/
public static function flattenArray($array) {
if (!is_array($array)) {
@@ -612,10 +616,10 @@ class PHPExcel_Calculation_Functions {
/**
- * Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing
+ * Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing
*
- * @param array $array Array to be flattened
- * @return array Flattened array
+ * @param array $array Array to be flattened
+ * @return array Flattened array
*/
public static function flattenArrayIndexed($array) {
if (!is_array($array)) {
@@ -644,10 +648,10 @@ class PHPExcel_Calculation_Functions {
/**
- * Convert an array to a single scalar value by extracting the first element
+ * Convert an array to a single scalar value by extracting the first element
*
- * @param mixed $value Array or scalar value
- * @return mixed
+ * @param mixed $value Array or scalar value
+ * @return mixed
*/
public static function flattenSingleValue($value = '') {
while (is_array($value)) {
@@ -746,6 +750,12 @@ if (!function_exists('money_format')) {
}
$space = $locale["{$letter}_sep_by_space"] ? ' ' : '';
+ if (!isset($locale['mon_decimal_point']) || empty($locale['mon_decimal_point'])) {
+ $locale['mon_decimal_point'] = (!isset($locale['decimal_point']) || empty($locale['decimal_point'])) ?
+ $locale['decimal_point'] :
+ '.';
+ }
+
$number = number_format($number, $right, $locale['mon_decimal_point'], $flags['nogroup'] ? '' : $locale['mon_thousands_sep'] );
$number = explode($locale['mon_decimal_point'], $number);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php
index 427cc343afa..80f2a2650d9 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Logical.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,50 +41,50 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Logical {
/**
- * TRUE
+ * TRUE
*
- * Returns the boolean TRUE.
+ * Returns the boolean TRUE.
*
- * Excel Function:
+ * Excel Function:
* =TRUE()
*
- * @access public
- * @category Logical Functions
- * @return boolean True
+ * @access public
+ * @category Logical Functions
+ * @return boolean True
*/
public static function TRUE() {
- return true;
+ return TRUE;
} // function TRUE()
/**
- * FALSE
+ * FALSE
*
- * Returns the boolean FALSE.
+ * Returns the boolean FALSE.
*
- * Excel Function:
+ * Excel Function:
* =FALSE()
*
- * @access public
- * @category Logical Functions
- * @return boolean False
+ * @access public
+ * @category Logical Functions
+ * @return boolean False
*/
public static function FALSE() {
- return false;
+ return FALSE;
} // function FALSE()
/**
- * LOGICAL_AND
+ * LOGICAL_AND
*
- * Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
+ * Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
*
- * Excel Function:
+ * Excel Function:
* =AND(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
@@ -95,19 +95,19 @@ class PHPExcel_Calculation_Logical {
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
- * @access public
- * @category Logical Functions
- * @param mixed $arg,... Data values
- * @return boolean The logical AND of the arguments.
+ * @access public
+ * @category Logical Functions
+ * @param mixed $arg,... Data values
+ * @return boolean The logical AND of the arguments.
*/
public static function LOGICAL_AND() {
// Return value
- $returnValue = True;
+ $returnValue = TRUE;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
- $argCount = 0;
- foreach ($aArgs as $arg) {
+ $argCount = -1;
+ foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue && $arg;
@@ -116,19 +116,18 @@ class PHPExcel_Calculation_Logical {
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
- $arg = true;
+ $arg = TRUE;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
- $arg = false;
+ $arg = FALSE;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue && ($arg != 0);
}
- ++$argCount;
}
// Return
- if ($argCount == 0) {
+ if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
@@ -136,11 +135,11 @@ class PHPExcel_Calculation_Logical {
/**
- * LOGICAL_OR
+ * LOGICAL_OR
*
- * Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
+ * Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
*
- * Excel Function:
+ * Excel Function:
* =OR(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
@@ -151,19 +150,19 @@ class PHPExcel_Calculation_Logical {
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
- * @access public
- * @category Logical Functions
- * @param mixed $arg,... Data values
- * @return boolean The logical OR of the arguments.
+ * @access public
+ * @category Logical Functions
+ * @param mixed $arg,... Data values
+ * @return boolean The logical OR of the arguments.
*/
public static function LOGICAL_OR() {
// Return value
- $returnValue = False;
+ $returnValue = FALSE;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
- $argCount = 0;
- foreach ($aArgs as $arg) {
+ $argCount = -1;
+ foreach ($aArgs as $argCount => $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue || $arg;
@@ -172,19 +171,18 @@ class PHPExcel_Calculation_Logical {
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
- $arg = true;
+ $arg = TRUE;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
- $arg = false;
+ $arg = FALSE;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue || ($arg != 0);
}
- ++$argCount;
}
// Return
- if ($argCount == 0) {
+ if ($argCount < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
@@ -192,11 +190,11 @@ class PHPExcel_Calculation_Logical {
/**
- * NOT
+ * NOT
*
- * Returns the boolean inverse of the argument.
+ * Returns the boolean inverse of the argument.
*
- * Excel Function:
+ * Excel Function:
* =NOT(logical)
*
* The argument must evaluate to a logical value such as TRUE or FALSE
@@ -206,19 +204,19 @@ class PHPExcel_Calculation_Logical {
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
- * @access public
- * @category Logical Functions
- * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
- * @return boolean The boolean inverse of the argument.
+ * @access public
+ * @category Logical Functions
+ * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
+ * @return boolean The boolean inverse of the argument.
*/
- public static function NOT($logical) {
+ public static function NOT($logical=FALSE) {
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
if (is_string($logical)) {
$logical = strtoupper($logical);
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
- return false;
+ return FALSE;
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
- return true;
+ return TRUE;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
@@ -228,11 +226,11 @@ class PHPExcel_Calculation_Logical {
} // function NOT()
/**
- * STATEMENT_IF
+ * STATEMENT_IF
*
- * Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
+ * Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
*
- * Excel Function:
+ * Excel Function:
* =IF(condition[,returnIfTrue[,returnIfFalse]])
*
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
@@ -252,33 +250,33 @@ class PHPExcel_Calculation_Logical {
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
* ReturnIfFalse can be another formula.
*
- * @access public
- * @category Logical Functions
- * @param mixed $condition Condition to evaluate
- * @param mixed $returnIfTrue Value to return when condition is true
- * @param mixed $returnIfFalse Optional value to return when condition is false
- * @return mixed The value of returnIfTrue or returnIfFalse determined by condition
+ * @access public
+ * @category Logical Functions
+ * @param mixed $condition Condition to evaluate
+ * @param mixed $returnIfTrue Value to return when condition is true
+ * @param mixed $returnIfFalse Optional value to return when condition is false
+ * @return mixed The value of returnIfTrue or returnIfFalse determined by condition
*/
- public static function STATEMENT_IF($condition = true, $returnIfTrue = 0, $returnIfFalse = False) {
- $condition = (is_null($condition)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
+ public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
+ $condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
- $returnIfFalse = (is_null($returnIfFalse)) ? False : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
+ $returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
- return ($condition ? $returnIfTrue : $returnIfFalse);
+ return ($condition) ? $returnIfTrue : $returnIfFalse;
} // function STATEMENT_IF()
/**
- * IFERROR
+ * IFERROR
*
- * Excel Function:
+ * Excel Function:
* =IFERROR(testValue,errorpart)
*
- * @access public
- * @category Logical Functions
- * @param mixed $testValue Value to check, is also the value returned when no error
- * @param mixed $errorpart Value to return when testValue is an error condition
- * @return mixed The value of errorpart or testValue determined by error condition
+ * @access public
+ * @category Logical Functions
+ * @param mixed $testValue Value to check, is also the value returned when no error
+ * @param mixed $errorpart Value to return when testValue is an error condition
+ * @return mixed The value of errorpart or testValue determined by error condition
*/
public static function IFERROR($testValue = '', $errorpart = '') {
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php
index 2c3371b5c7a..c8246903f2e 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/LookupRef.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,28 +41,31 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_LookupRef {
/**
- * CELL_ADDRESS
+ * CELL_ADDRESS
*
- * Creates a cell address as text, given specified row and column numbers.
+ * Creates a cell address as text, given specified row and column numbers.
*
- * @param row Row number to use in the cell reference
- * @param column Column number to use in the cell reference
- * @param relativity Flag indicating the type of reference to return
+ * Excel Function:
+ * =ADDRESS(row, column, [relativity], [referenceStyle], [sheetText])
+ *
+ * @param row Row number to use in the cell reference
+ * @param column Column number to use in the cell reference
+ * @param relativity Flag indicating the type of reference to return
* 1 or omitted Absolute
* 2 Absolute row; relative column
* 3 Relative row; absolute column
* 4 Relative
- * @param referenceStyle A logical value that specifies the A1 or R1C1 reference style.
+ * @param referenceStyle A logical value that specifies the A1 or R1C1 reference style.
* TRUE or omitted CELL_ADDRESS returns an A1-style reference
* FALSE CELL_ADDRESS returns an R1C1-style reference
- * @param sheetText Optional Name of worksheet to use
- * @return string
+ * @param sheetText Optional Name of worksheet to use
+ * @return string
*/
public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') {
$row = PHPExcel_Calculation_Functions::flattenSingleValue($row);
@@ -93,15 +96,18 @@ class PHPExcel_Calculation_LookupRef {
/**
- * COLUMN
+ * COLUMN
*
- * Returns the column number of the given cell reference
- * If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array.
- * If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
+ * Returns the column number of the given cell reference
+ * If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array.
+ * If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
* reference of the cell in which the COLUMN function appears; otherwise this function returns 0.
*
- * @param cellAddress A reference to a range of cells for which you want the column numbers
- * @return integer or array of integer
+ * Excel Function:
+ * =COLUMN([cellAddress])
+ *
+ * @param cellAddress A reference to a range of cells for which you want the column numbers
+ * @return integer or array of integer
*/
public static function COLUMN($cellAddress=Null) {
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
@@ -133,12 +139,15 @@ class PHPExcel_Calculation_LookupRef {
/**
- * COLUMNS
+ * COLUMNS
*
- * Returns the number of columns in an array or reference.
+ * Returns the number of columns in an array or reference.
*
- * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
- * @return integer
+ * Excel Function:
+ * =COLUMNS(cellAddress)
+ *
+ * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
+ * @return integer The number of columns in cellAddress
*/
public static function COLUMNS($cellAddress=Null) {
if (is_null($cellAddress) || $cellAddress === '') {
@@ -161,15 +170,18 @@ class PHPExcel_Calculation_LookupRef {
/**
- * ROW
+ * ROW
*
- * Returns the row number of the given cell reference
- * If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array.
- * If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
+ * Returns the row number of the given cell reference
+ * If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array.
+ * If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
* reference of the cell in which the ROW function appears; otherwise this function returns 0.
*
- * @param cellAddress A reference to a range of cells for which you want the row numbers
- * @return integer or array of integer
+ * Excel Function:
+ * =ROW([cellAddress])
+ *
+ * @param cellAddress A reference to a range of cells for which you want the row numbers
+ * @return integer or array of integer
*/
public static function ROW($cellAddress=Null) {
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
@@ -202,12 +214,15 @@ class PHPExcel_Calculation_LookupRef {
/**
- * ROWS
+ * ROWS
*
- * Returns the number of rows in an array or reference.
+ * Returns the number of rows in an array or reference.
*
- * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
- * @return integer
+ * Excel Function:
+ * =ROWS(cellAddress)
+ *
+ * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
+ * @return integer The number of rows in cellAddress
*/
public static function ROWS($cellAddress=Null) {
if (is_null($cellAddress) || $cellAddress === '') {
@@ -229,16 +244,16 @@ class PHPExcel_Calculation_LookupRef {
/**
- * HYPERLINK
+ * HYPERLINK
*
- * Excel Function:
+ * Excel Function:
* =HYPERLINK(linkURL,displayName)
*
- * @access public
- * @category Logical Functions
- * @param string $linkURL Value to check, is also the value returned when no error
- * @param string $displayName Value to return when testValue is an error condition
- * @return mixed The value of errorpart or testValue determined by error condition
+ * @access public
+ * @category Logical Functions
+ * @param string $linkURL Value to check, is also the value returned when no error
+ * @param string $displayName Value to return when testValue is an error condition
+ * @return mixed The value of $displayName (or $linkURL if $displayName was blank)
*/
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) {
$args = func_get_args();
@@ -262,12 +277,21 @@ class PHPExcel_Calculation_LookupRef {
/**
- * INDIRECT
+ * INDIRECT
*
- * Returns the number of rows in an array or reference.
+ * Returns the reference specified by a text string.
+ * References are immediately evaluated to display their contents.
+ *
+ * Excel Function:
+ * =INDIRECT(cellAddress)
+ *
+ * NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010
+ *
+ * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
+ * @return mixed The cells referenced by cellAddress
+ *
+ * @todo Support for the optional a1 parameter introduced in Excel 2010
*
- * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
- * @return integer
*/
public static function INDIRECT($cellAddress=Null, PHPExcel_Cell $pCell = null) {
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
@@ -283,7 +307,19 @@ class PHPExcel_Calculation_LookupRef {
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) {
- return PHPExcel_Calculation_Functions::REF();
+
+ if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) {
+ return PHPExcel_Calculation_Functions::REF();
+ }
+
+ if (strpos($cellAddress,'!') !== false) {
+ list($sheetName,$cellAddress) = explode('!',$cellAddress);
+ $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
+ } else {
+ $pSheet = $pCell->getParent();
+ }
+
+ return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, False);
}
if (strpos($cellAddress,'!') !== false) {
@@ -298,26 +334,29 @@ class PHPExcel_Calculation_LookupRef {
/**
- * OFFSET
+ * OFFSET
*
- * Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells.
- * The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and
- * the number of columns to be returned.
+ * Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells.
+ * The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and
+ * the number of columns to be returned.
*
- * @param cellAddress The reference from which you want to base the offset. Reference must refer to a cell or
+ * Excel Function:
+ * =OFFSET(cellAddress, rows, cols, [height], [width])
+ *
+ * @param cellAddress The reference from which you want to base the offset. Reference must refer to a cell or
* range of adjacent cells; otherwise, OFFSET returns the #VALUE! error value.
- * @param rows The number of rows, up or down, that you want the upper-left cell to refer to.
+ * @param rows The number of rows, up or down, that you want the upper-left cell to refer to.
* Using 5 as the rows argument specifies that the upper-left cell in the reference is
* five rows below reference. Rows can be positive (which means below the starting reference)
* or negative (which means above the starting reference).
- * @param cols The number of columns, to the left or right, that you want the upper-left cell of the result
+ * @param cols The number of columns, to the left or right, that you want the upper-left cell of the result
* to refer to. Using 5 as the cols argument specifies that the upper-left cell in the
* reference is five columns to the right of reference. Cols can be positive (which means
* to the right of the starting reference) or negative (which means to the left of the
* starting reference).
- * @param height The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
- * @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
- * @return string A reference to a cell or range of cells
+ * @param height The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
+ * @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
+ * @return string A reference to a cell or range of cells
*/
public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) {
$rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows);
@@ -387,6 +426,24 @@ class PHPExcel_Calculation_LookupRef {
} // function OFFSET()
+ /**
+ * CHOOSE
+ *
+ * Uses lookup_value to return a value from the list of value arguments.
+ * Use CHOOSE to select one of up to 254 values based on the lookup_value.
+ *
+ * Excel Function:
+ * =CHOOSE(index_num, value1, [value2], ...)
+ *
+ * @param index_num Specifies which value argument is selected.
+ * Index_num must be a number between 1 and 254, or a formula or reference to a cell containing a number
+ * between 1 and 254.
+ * @param value1... Value1 is required, subsequent values are optional.
+ * Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on
+ * index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or
+ * text.
+ * @return mixed The selected value
+ */
public static function CHOOSE() {
$chooseArgs = func_get_args();
$chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs));
@@ -414,14 +471,17 @@ class PHPExcel_Calculation_LookupRef {
/**
- * MATCH
+ * MATCH
*
- * The MATCH function searches for a specified item in a range of cells
+ * The MATCH function searches for a specified item in a range of cells
*
- * @param lookup_value The value that you want to match in lookup_array
- * @param lookup_array The range of cells being searched
- * @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
- * @return integer The relative position of the found item
+ * Excel Function:
+ * =MATCH(lookup_value, lookup_array, [match_type])
+ *
+ * @param lookup_value The value that you want to match in lookup_array
+ * @param lookup_array The range of cells being searched
+ * @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
+ * @return integer The relative position of the found item
*/
public static function MATCH($lookup_value, $lookup_array, $match_type=1) {
$lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array);
@@ -524,15 +584,17 @@ class PHPExcel_Calculation_LookupRef {
/**
- * INDEX
+ * INDEX
*
* Uses an index to choose a value from a reference or array
- * implemented: Return the value of a specified cell or array of cells Array form
- * not implemented: Return a reference to specified cells Reference form
*
- * @param range_array a range of cells or an array constant
- * @param row_num selects the row in array from which to return a value. If row_num is omitted, column_num is required.
- * @param column_num selects the column in array from which to return a value. If column_num is omitted, row_num is required.
+ * Excel Function:
+ * =INDEX(range_array, row_num, [column_num])
+ *
+ * @param range_array A range of cells or an array constant
+ * @param row_num The row in array from which to return a value. If row_num is omitted, column_num is required.
+ * @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required.
+ * @return mixed the value of a specified cell or array of cells
*/
public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) {
@@ -635,7 +697,7 @@ class PHPExcel_Calculation_LookupRef {
}
// index_number must be less than or equal to the number of columns in lookup_array
- if ((!is_array($lookup_array)) || (count($lookup_array) < 1)) {
+ if ((!is_array($lookup_array)) || (empty($lookup_array))) {
return PHPExcel_Calculation_Functions::REF();
} else {
$f = array_keys($lookup_array);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php
index 35530274dfc..79c573b2774 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/MathTrig.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_MathTrig {
@@ -61,7 +61,7 @@ class PHPExcel_Calculation_MathTrig {
}
}
}
- if (count($factorArray) > 0) {
+ if (!empty($factorArray)) {
rsort($factorArray);
return $factorArray;
} else {
@@ -76,61 +76,79 @@ class PHPExcel_Calculation_MathTrig {
/**
- * ATAN2
+ * ATAN2
*
- * This function calculates the arc tangent of the two variables x and y. It is similar to
+ * This function calculates the arc tangent of the two variables x and y. It is similar to
* calculating the arc tangent of y x, except that the signs of both arguments are used
* to determine the quadrant of the result.
- * The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a
+ * The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a
* point with coordinates (xCoordinate, yCoordinate). The angle is given in radians between
* -pi and pi, excluding -pi.
*
- * Note that the Excel ATAN2() function accepts its arguments in the reverse order to the standard
+ * Note that the Excel ATAN2() function accepts its arguments in the reverse order to the standard
* PHP atan2() function, so we need to reverse them here before calling the PHP atan() function.
*
- * Excel Function:
+ * Excel Function:
* ATAN2(xCoordinate,yCoordinate)
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param float $xCoordinate The x-coordinate of the point.
- * @param float $yCoordinate The y-coordinate of the point.
- * @return float The inverse tangent of the specified x- and y-coordinates.
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $xCoordinate The x-coordinate of the point.
+ * @param float $yCoordinate The y-coordinate of the point.
+ * @return float The inverse tangent of the specified x- and y-coordinates.
*/
- public static function ATAN2($xCoordinate, $yCoordinate) {
- $xCoordinate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($xCoordinate);
- $yCoordinate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($yCoordinate);
+ public static function ATAN2($xCoordinate = NULL, $yCoordinate = NULL) {
+ $xCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($xCoordinate);
+ $yCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($yCoordinate);
- if (($xCoordinate == 0) && ($yCoordinate == 0)) {
- return PHPExcel_Calculation_Functions::DIV0();
+ $xCoordinate = ($xCoordinate !== NULL) ? $xCoordinate : 0.0;
+ $yCoordinate = ($yCoordinate !== NULL) ? $yCoordinate : 0.0;
+
+ if (((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) &&
+ ((is_numeric($yCoordinate))) || (is_bool($yCoordinate))) {
+ $xCoordinate = (float) $xCoordinate;
+ $yCoordinate = (float) $yCoordinate;
+
+ if (($xCoordinate == 0) && ($yCoordinate == 0)) {
+ return PHPExcel_Calculation_Functions::DIV0();
+ }
+
+ return atan2($yCoordinate, $xCoordinate);
}
-
- return atan2($yCoordinate, $xCoordinate);
- } // function REVERSE_ATAN2()
+ return PHPExcel_Calculation_Functions::VALUE();
+ } // function ATAN2()
/**
- * CEILING
+ * CEILING
*
- * Returns number rounded up, away from zero, to the nearest multiple of significance.
+ * Returns number rounded up, away from zero, to the nearest multiple of significance.
+ * For example, if you want to avoid using pennies in your prices and your product is
+ * priced at $4.42, use the formula =CEILING(4.42,0.05) to round prices up to the
+ * nearest nickel.
*
- * @param float $number Number to round
- * @param float $significance Significance
- * @return float Rounded Number
+ * Excel Function:
+ * CEILING(number[,significance])
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $number The number you want to round.
+ * @param float $significance The multiple to which you want to round.
+ * @return float Rounded Number
*/
- public static function CEILING($number,$significance=null) {
+ public static function CEILING($number, $significance = NULL) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
$significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance);
- if ((is_null($significance)) && (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
+ if ((is_null($significance)) &&
+ (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
$significance = $number/abs($number);
}
if ((is_numeric($number)) && (is_numeric($significance))) {
- if (self::SIGN($number) == self::SIGN($significance)) {
- if ($significance == 0.0) {
- return 0;
- }
+ if ($significance == 0.0) {
+ return 0.0;
+ } elseif (self::SIGN($number) == self::SIGN($significance)) {
return ceil($number / $significance) * $significance;
} else {
return PHPExcel_Calculation_Functions::NaN();
@@ -141,16 +159,21 @@ class PHPExcel_Calculation_MathTrig {
/**
- * COMBIN
+ * COMBIN
*
- * Returns the number of combinations for a given number of items. Use COMBIN to
- * determine the total possible number of groups for a given number of items.
+ * Returns the number of combinations for a given number of items. Use COMBIN to
+ * determine the total possible number of groups for a given number of items.
*
- * @param int $numObjs Number of different objects
- * @param int $numInSet Number of objects in each combination
- * @return int Number of combinations
+ * Excel Function:
+ * COMBIN(numObjs,numInSet)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param int $numObjs Number of different objects
+ * @param int $numInSet Number of objects in each combination
+ * @return int Number of combinations
*/
- public static function COMBIN($numObjs,$numInSet) {
+ public static function COMBIN($numObjs, $numInSet) {
$numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs);
$numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet);
@@ -167,19 +190,32 @@ class PHPExcel_Calculation_MathTrig {
/**
- * EVEN
+ * EVEN
*
- * Returns number rounded up to the nearest even integer.
+ * Returns number rounded up to the nearest even integer.
+ * You can use this function for processing items that come in twos. For example,
+ * a packing crate accepts rows of one or two items. The crate is full when
+ * the number of items, rounded up to the nearest two, matches the crate's
+ * capacity.
*
- * @param float $number Number to round
- * @return int Rounded Number
+ * Excel Function:
+ * EVEN(number)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $number Number to round
+ * @return int Rounded Number
*/
public static function EVEN($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
if (is_null($number)) {
return 0;
- } elseif (is_numeric($number)) {
+ } elseif (is_bool($number)) {
+ $number = (int) $number;
+ }
+
+ if (is_numeric($number)) {
$significance = 2 * self::SIGN($number);
return (int) self::CEILING($number,$significance);
}
@@ -188,12 +224,18 @@ class PHPExcel_Calculation_MathTrig {
/**
- * FACT
+ * FACT
*
- * Returns the factorial of a number.
+ * Returns the factorial of a number.
+ * The factorial of a number is equal to 1*2*3*...* number.
*
- * @param float $factVal Factorial Value
- * @return int Factorial
+ * Excel Function:
+ * FACT(factVal)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $factVal Factorial Value
+ * @return int Factorial
*/
public static function FACT($factVal) {
$factVal = PHPExcel_Calculation_Functions::flattenSingleValue($factVal);
@@ -220,17 +262,23 @@ class PHPExcel_Calculation_MathTrig {
/**
- * FACTDOUBLE
+ * FACTDOUBLE
*
- * Returns the double factorial of a number.
+ * Returns the double factorial of a number.
*
- * @param float $factVal Factorial Value
- * @return int Double Factorial
+ * Excel Function:
+ * FACTDOUBLE(factVal)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $factVal Factorial Value
+ * @return int Double Factorial
*/
public static function FACTDOUBLE($factVal) {
- $factLoop = floor(PHPExcel_Calculation_Functions::flattenSingleValue($factVal));
+ $factLoop = PHPExcel_Calculation_Functions::flattenSingleValue($factVal);
if (is_numeric($factLoop)) {
+ $factLoop = floor($factLoop);
if ($factVal < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
@@ -246,15 +294,20 @@ class PHPExcel_Calculation_MathTrig {
/**
- * FLOOR
+ * FLOOR
*
- * Rounds number down, toward zero, to the nearest multiple of significance.
+ * Rounds number down, toward zero, to the nearest multiple of significance.
*
- * @param float $number Number to round
- * @param float $significance Significance
- * @return float Rounded Number
+ * Excel Function:
+ * FLOOR(number[,significance])
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $number Number to round
+ * @param float $significance Significance
+ * @return float Rounded Number
*/
- public static function FLOOR($number,$significance=null) {
+ public static function FLOOR($number, $significance = NULL) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
$significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance);
@@ -277,26 +330,41 @@ class PHPExcel_Calculation_MathTrig {
/**
- * GCD
+ * GCD
*
- * Returns the greatest common divisor of a series of numbers
+ * Returns the greatest common divisor of a series of numbers.
+ * The greatest common divisor is the largest integer that divides both
+ * number1 and number2 without a remainder.
*
- * @param $array Values to calculate the Greatest Common Divisor
- * @return int Greatest Common Divisor
+ * Excel Function:
+ * GCD(number1[,number2[, ...]])
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @return integer Greatest Common Divisor
*/
public static function GCD() {
$returnValue = 1;
- $allPoweredFactors = array();
+ $allValuesFactors = array();
// Loop through arguments
foreach(PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $value) {
- if ($value == 0) {
- break;
+ if (!is_numeric($value)) {
+ return PHPExcel_Calculation_Functions::VALUE();
+ } elseif ($value == 0) {
+ continue;
+ } elseif($value < 0) {
+ return PHPExcel_Calculation_Functions::NaN();
}
$myFactors = self::_factors($value);
$myCountedFactors = array_count_values($myFactors);
$allValuesFactors[] = $myCountedFactors;
}
$allValuesCount = count($allValuesFactors);
+ if ($allValuesCount == 0) {
+ return 0;
+ }
+
$mergedArray = $allValuesFactors[0];
for ($i=1;$i < $allValuesCount; ++$i) {
$mergedArray = array_intersect_key($mergedArray,$allValuesFactors[$i]);
@@ -338,16 +406,26 @@ class PHPExcel_Calculation_MathTrig {
/**
- * INT
+ * INT
*
- * Casts a floating point value to an integer
+ * Casts a floating point value to an integer
*
- * @param float $number Number to cast to an integer
- * @return integer Integer value
+ * Excel Function:
+ * INT(number)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $number Number to cast to an integer
+ * @return integer Integer value
*/
public static function INT($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
+ if (is_null($number)) {
+ return 0;
+ } elseif (is_bool($number)) {
+ return (int) $number;
+ }
if (is_numeric($number)) {
return (int) floor($number);
}
@@ -356,12 +434,20 @@ class PHPExcel_Calculation_MathTrig {
/**
- * LCM
+ * LCM
*
- * Returns the lowest common multiplier of a series of numbers
+ * Returns the lowest common multiplier of a series of numbers
+ * The least common multiple is the smallest positive integer that is a multiple
+ * of all integer arguments number1, number2, and so on. Use LCM to add fractions
+ * with different denominators.
*
- * @param $array Values to calculate the Lowest Common Multiplier
- * @return int Lowest Common Multiplier
+ * Excel Function:
+ * LCM(number1[,number2[, ...]])
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @return int Lowest Common Multiplier
*/
public static function LCM() {
$returnValue = 1;
@@ -400,23 +486,27 @@ class PHPExcel_Calculation_MathTrig {
/**
- * LOG_BASE
+ * LOG_BASE
*
- * Returns the logarithm of a number to a specified base. The default base is 10.
+ * Returns the logarithm of a number to a specified base. The default base is 10.
*
- * Excel Function:
+ * Excel Function:
* LOG(number[,base])
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param float $value The positive real number for which you want the logarithm
- * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10.
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param float $value The positive real number for which you want the logarithm
+ * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10.
+ * @return float
*/
- public static function LOG_BASE($number, $base=10) {
+ public static function LOG_BASE($number = NULL, $base = 10) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
$base = (is_null($base)) ? 10 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($base);
+ if ((!is_numeric($base)) || (!is_numeric($number)))
+ return PHPExcel_Calculation_Functions::VALUE();
+ if (($base <= 0) || ($number <= 0))
+ return PHPExcel_Calculation_Functions::NaN();
return log($number, $base);
} // function LOG_BASE()
@@ -424,6 +514,13 @@ class PHPExcel_Calculation_MathTrig {
/**
* MDETERM
*
+ * Returns the matrix determinant of an array.
+ *
+ * Excel Function:
+ * MDETERM(array)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
* @param array $matrixValues A matrix of values
* @return float
*/
@@ -433,6 +530,7 @@ class PHPExcel_Calculation_MathTrig {
$row = $maxColumn = 0;
foreach($matrixValues as $matrixRow) {
+ if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$column = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
@@ -458,6 +556,13 @@ class PHPExcel_Calculation_MathTrig {
/**
* MINVERSE
*
+ * Returns the inverse matrix for the matrix stored in an array.
+ *
+ * Excel Function:
+ * MINVERSE(array)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
* @param array $matrixValues A matrix of values
* @return array
*/
@@ -467,6 +572,7 @@ class PHPExcel_Calculation_MathTrig {
$row = $maxColumn = 0;
foreach($matrixValues as $matrixRow) {
+ if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$column = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
@@ -503,6 +609,7 @@ class PHPExcel_Calculation_MathTrig {
$rowA = 0;
foreach($matrixData1 as $matrixRow) {
+ if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$columnA = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
@@ -517,6 +624,7 @@ class PHPExcel_Calculation_MathTrig {
$matrixA = new PHPExcel_Shared_JAMA_Matrix($matrixAData);
$rowB = 0;
foreach($matrixData2 as $matrixRow) {
+ if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$columnB = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
@@ -564,13 +672,13 @@ class PHPExcel_Calculation_MathTrig {
/**
- * MROUND
+ * MROUND
*
- * Rounds a number to the nearest multiple of a specified value
+ * Rounds a number to the nearest multiple of a specified value
*
- * @param float $number Number to round
- * @param int $multiple Multiple to which you want to round $number
- * @return float Rounded Number
+ * @param float $number Number to round
+ * @param int $multiple Multiple to which you want to round $number
+ * @return float Rounded Number
*/
public static function MROUND($number,$multiple) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
@@ -591,12 +699,12 @@ class PHPExcel_Calculation_MathTrig {
/**
- * MULTINOMIAL
+ * MULTINOMIAL
*
- * Returns the ratio of the factorial of a sum of values to the product of factorials.
+ * Returns the ratio of the factorial of a sum of values to the product of factorials.
*
- * @param array of mixed Data Series
- * @return float
+ * @param array of mixed Data Series
+ * @return float
*/
public static function MULTINOMIAL() {
$summer = 0;
@@ -625,19 +733,23 @@ class PHPExcel_Calculation_MathTrig {
/**
- * ODD
+ * ODD
*
- * Returns number rounded up to the nearest odd integer.
+ * Returns number rounded up to the nearest odd integer.
*
- * @param float $number Number to round
- * @return int Rounded Number
+ * @param float $number Number to round
+ * @return int Rounded Number
*/
public static function ODD($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
if (is_null($number)) {
return 1;
- } elseif (is_numeric($number)) {
+ } elseif (is_bool($number)) {
+ $number = (int) $number;
+ }
+
+ if (is_numeric($number)) {
$significance = self::SIGN($number);
if ($significance == 0) {
return 1;
@@ -655,40 +767,43 @@ class PHPExcel_Calculation_MathTrig {
/**
- * POWER
+ * POWER
*
- * Computes x raised to the power y.
+ * Computes x raised to the power y.
*
- * @param float $x
- * @param float $y
- * @return float
+ * @param float $x
+ * @param float $y
+ * @return float
*/
public static function POWER($x = 0, $y = 2) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$y = PHPExcel_Calculation_Functions::flattenSingleValue($y);
// Validate parameters
- if ($x == 0 && $y <= 0) {
+ if ($x == 0.0 && $y == 0.0) {
+ return PHPExcel_Calculation_Functions::NaN();
+ } elseif ($x == 0.0 && $y < 0.0) {
return PHPExcel_Calculation_Functions::DIV0();
}
// Return
- return pow($x, $y);
+ $result = pow($x, $y);
+ return (!is_nan($result) && !is_infinite($result)) ? $result : PHPExcel_Calculation_Functions::NaN();
} // function POWER()
/**
- * PRODUCT
+ * PRODUCT
*
- * PRODUCT returns the product of all the values and cells referenced in the argument list.
+ * PRODUCT returns the product of all the values and cells referenced in the argument list.
*
- * Excel Function:
+ * Excel Function:
* PRODUCT(value1[,value2[, ...]])
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function PRODUCT() {
// Return value
@@ -715,18 +830,18 @@ class PHPExcel_Calculation_MathTrig {
/**
- * QUOTIENT
+ * QUOTIENT
*
- * QUOTIENT function returns the integer portion of a division. Numerator is the divided number
+ * QUOTIENT function returns the integer portion of a division. Numerator is the divided number
* and denominator is the divisor.
*
- * Excel Function:
+ * Excel Function:
* QUOTIENT(value1[,value2[, ...]])
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function QUOTIENT() {
// Return value
@@ -773,11 +888,12 @@ class PHPExcel_Calculation_MathTrig {
public static function ROMAN($aValue, $style=0) {
- $aValue = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($aValue);
+ $aValue = PHPExcel_Calculation_Functions::flattenSingleValue($aValue);
$style = (is_null($style)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($style);
if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
return PHPExcel_Calculation_Functions::VALUE();
}
+ $aValue = (integer) $aValue;
if ($aValue == 0) {
return '';
}
@@ -801,20 +917,20 @@ class PHPExcel_Calculation_MathTrig {
/**
- * ROUNDUP
+ * ROUNDUP
*
- * Rounds a number up to a specified number of decimal places
+ * Rounds a number up to a specified number of decimal places
*
- * @param float $number Number to round
- * @param int $digits Number of digits to which you want to round $number
- * @return float Rounded Number
+ * @param float $number Number to round
+ * @param int $digits Number of digits to which you want to round $number
+ * @return float Rounded Number
*/
public static function ROUNDUP($number,$digits) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits);
if ((is_numeric($number)) && (is_numeric($digits))) {
- $significance = pow(10,$digits);
+ $significance = pow(10,(int) $digits);
if ($number < 0.0) {
return floor($number * $significance) / $significance;
} else {
@@ -826,20 +942,20 @@ class PHPExcel_Calculation_MathTrig {
/**
- * ROUNDDOWN
+ * ROUNDDOWN
*
- * Rounds a number down to a specified number of decimal places
+ * Rounds a number down to a specified number of decimal places
*
- * @param float $number Number to round
- * @param int $digits Number of digits to which you want to round $number
- * @return float Rounded Number
+ * @param float $number Number to round
+ * @param int $digits Number of digits to which you want to round $number
+ * @return float Rounded Number
*/
public static function ROUNDDOWN($number,$digits) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits);
if ((is_numeric($number)) && (is_numeric($digits))) {
- $significance = pow(10,$digits);
+ $significance = pow(10,(int) $digits);
if ($number < 0.0) {
return ceil($number * $significance) / $significance;
} else {
@@ -851,15 +967,15 @@ class PHPExcel_Calculation_MathTrig {
/**
- * SERIESSUM
+ * SERIESSUM
*
- * Returns the sum of a power series
+ * Returns the sum of a power series
*
- * @param float $x Input value to the power series
- * @param float $n Initial power to which you want to raise $x
- * @param float $m Step by which to increase $n for each term in the series
- * @param array of mixed Data Series
- * @return float
+ * @param float $x Input value to the power series
+ * @param float $n Initial power to which you want to raise $x
+ * @param float $m Step by which to increase $n for each term in the series
+ * @param array of mixed Data Series
+ * @return float
*/
public static function SERIESSUM() {
// Return value
@@ -891,17 +1007,19 @@ class PHPExcel_Calculation_MathTrig {
/**
- * SIGN
+ * SIGN
*
- * Determines the sign of a number. Returns 1 if the number is positive, zero (0)
- * if the number is 0, and -1 if the number is negative.
+ * Determines the sign of a number. Returns 1 if the number is positive, zero (0)
+ * if the number is 0, and -1 if the number is negative.
*
- * @param float $number Number to round
- * @return int sign value
+ * @param float $number Number to round
+ * @return int sign value
*/
public static function SIGN($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
+ if (is_bool($number))
+ return (int) $number;
if (is_numeric($number)) {
if ($number == 0.0) {
return 0;
@@ -913,12 +1031,12 @@ class PHPExcel_Calculation_MathTrig {
/**
- * SQRTPI
+ * SQRTPI
*
- * Returns the square root of (number * pi).
+ * Returns the square root of (number * pi).
*
- * @param float $number Number
- * @return float Square Root of Number * Pi
+ * @param float $number Number
+ * @return float Square Root of Number * Pi
*/
public static function SQRTPI($number) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
@@ -934,14 +1052,14 @@ class PHPExcel_Calculation_MathTrig {
/**
- * SUBTOTAL
+ * SUBTOTAL
*
- * Returns a subtotal in a list or database.
+ * Returns a subtotal in a list or database.
*
- * @param int the number 1 to 11 that specifies which function to
+ * @param int the number 1 to 11 that specifies which function to
* use in calculating subtotals within a list.
- * @param array of mixed Data Series
- * @return float
+ * @param array of mixed Data Series
+ * @return float
*/
public static function SUBTOTAL() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@@ -991,17 +1109,17 @@ class PHPExcel_Calculation_MathTrig {
/**
- * SUM
+ * SUM
*
- * SUM computes the sum of all the values and cells referenced in the argument list.
+ * SUM computes the sum of all the values and cells referenced in the argument list.
*
- * Excel Function:
+ * Excel Function:
* SUM(value1[,value2[, ...]])
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function SUM() {
// Return value
@@ -1021,18 +1139,18 @@ class PHPExcel_Calculation_MathTrig {
/**
- * SUMIF
+ * SUMIF
*
- * Counts the number of cells that contain numbers within the list of arguments
+ * Counts the number of cells that contain numbers within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* SUMIF(value1[,value2[, ...]],condition)
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @param string $condition The criteria that defines which cells will be summed.
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be summed.
+ * @return float
*/
public static function SUMIF($aArgs,$condition,$sumArgs = array()) {
// Return value
@@ -1040,7 +1158,7 @@ class PHPExcel_Calculation_MathTrig {
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
- if (count($sumArgs) == 0) {
+ if (empty($sumArgs)) {
$sumArgs = $aArgs;
}
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
@@ -1062,7 +1180,12 @@ class PHPExcel_Calculation_MathTrig {
/**
* SUMPRODUCT
*
- * @param mixed $value Value to check
+ * Excel Function:
+ * SUMPRODUCT(value1[,value2[, ...]])
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
* @return float
*/
public static function SUMPRODUCT() {
@@ -1071,6 +1194,12 @@ class PHPExcel_Calculation_MathTrig {
$wrkArray = PHPExcel_Calculation_Functions::flattenArray(array_shift($arrayList));
$wrkCellCount = count($wrkArray);
+ for ($i=0; $i< $wrkCellCount; ++$i) {
+ if ((!is_numeric($wrkArray[$i])) || (is_string($wrkArray[$i]))) {
+ $wrkArray[$i] = 0;
+ }
+ }
+
foreach($arrayList as $matrixData) {
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData);
$count = count($array2);
@@ -1079,10 +1208,10 @@ class PHPExcel_Calculation_MathTrig {
}
foreach ($array2 as $i => $val) {
- if (((is_numeric($wrkArray[$i])) && (!is_string($wrkArray[$i]))) &&
- ((is_numeric($val)) && (!is_string($val)))) {
- $wrkArray[$i] *= $val;
+ if ((!is_numeric($val)) || (is_string($val))) {
+ $val = 0;
}
+ $wrkArray[$i] *= $val;
}
}
@@ -1091,17 +1220,17 @@ class PHPExcel_Calculation_MathTrig {
/**
- * SUMSQ
+ * SUMSQ
*
- * SUMSQ returns the sum of the squares of the arguments
+ * SUMSQ returns the sum of the squares of the arguments
*
- * Excel Function:
+ * Excel Function:
* SUMSQ(value1[,value2[, ...]])
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function SUMSQ() {
// Return value
@@ -1208,34 +1337,30 @@ class PHPExcel_Calculation_MathTrig {
/**
- * TRUNC
+ * TRUNC
*
- * Truncates value to the number of fractional digits by number_digits.
+ * Truncates value to the number of fractional digits by number_digits.
*
- * @param float $value
- * @param int $number_digits
- * @return float Truncated value
+ * @param float $value
+ * @param int $digits
+ * @return float Truncated value
*/
- public static function TRUNC($value = 0, $number_digits = 0) {
- $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
- $number_digits = PHPExcel_Calculation_Functions::flattenSingleValue($number_digits);
+ public static function TRUNC($value = 0, $digits = 0) {
+ $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
+ $digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits);
// Validate parameters
- if ($number_digits < 0) {
+ if ((!is_numeric($value)) || (!is_numeric($digits)))
return PHPExcel_Calculation_Functions::VALUE();
- }
+ $digits = floor($digits);
// Truncate
- if ($number_digits > 0) {
- $value = $value * pow(10, $number_digits);
- }
- $value = intval($value);
- if ($number_digits > 0) {
- $value = $value / pow(10, $number_digits);
- }
+ $adjust = pow(10, $digits);
- // Return
- return $value;
+ if (($digits > 0) && (rtrim(intval((abs($value) - abs(intval($value))) * $adjust),'0') < $adjust/10))
+ return $value;
+
+ return (intval($value * $adjust)) / $adjust;
} // function TRUNC()
} // class PHPExcel_Calculation_MathTrig
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php
index 31c92964ade..2fbb163ef7b 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Statistical.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -57,7 +57,7 @@ define('SQRT2PI', 2.5066282746310005024157652848110452530069867406099);
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Statistical {
@@ -140,11 +140,12 @@ class PHPExcel_Calculation_Statistical {
private static $_logBetaCache_result = 0.0;
/**
- * The natural logarithm of the beta function.
- * @param p require p>0
- * @param q require q>0
- * @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow
- * @author Jaco van Kooten
+ * The natural logarithm of the beta function.
+ *
+ * @param p require p>0
+ * @param q require q>0
+ * @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow
+ * @author Jaco van Kooten
*/
private static function _logBeta($p, $q) {
if ($p != self::$_logBetaCache_p || $q != self::$_logBetaCache_q) {
@@ -161,9 +162,9 @@ class PHPExcel_Calculation_Statistical {
/**
- * Evaluates of continued fraction part of incomplete beta function.
- * Based on an idea from Numerical Recipes (W.H. Press et al, 1992).
- * @author Jaco van Kooten
+ * Evaluates of continued fraction part of incomplete beta function.
+ * Based on an idea from Numerical Recipes (W.H. Press et al, 1992).
+ * @author Jaco van Kooten
*/
private static function _betaFraction($x, $p, $q) {
$c = 1.0;
@@ -683,18 +684,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * AVEDEV
+ * AVEDEV
*
- * Returns the average of the absolute deviations of data points from their mean.
- * AVEDEV is a measure of the variability in a data set.
+ * Returns the average of the absolute deviations of data points from their mean.
+ * AVEDEV is a measure of the variability in a data set.
*
- * Excel Function:
+ * Excel Function:
* AVEDEV(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function AVEDEV() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
@@ -732,17 +733,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * AVERAGE
+ * AVERAGE
*
- * Returns the average (arithmetic mean) of the arguments
+ * Returns the average (arithmetic mean) of the arguments
*
- * Excel Function:
+ * Excel Function:
* AVERAGE(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function AVERAGE() {
$returnValue = $aCount = 0;
@@ -774,17 +775,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * AVERAGEA
+ * AVERAGEA
*
- * Returns the average of its arguments, including numbers, text, and logical values
+ * Returns the average of its arguments, including numbers, text, and logical values
*
- * Excel Function:
+ * Excel Function:
* AVERAGEA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function AVERAGEA() {
// Return value
@@ -822,18 +823,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * AVERAGEIF
+ * AVERAGEIF
*
- * Returns the average value from a range of cells that contain numbers within the list of arguments
+ * Returns the average value from a range of cells that contain numbers within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* AVERAGEIF(value1[,value2[, ...]],condition)
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @param string $condition The criteria that defines which cells will be checked.
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be checked.
+ * @return float
*/
public static function AVERAGEIF($aArgs,$condition,$averageArgs = array()) {
// Return value
@@ -841,7 +842,7 @@ class PHPExcel_Calculation_Statistical {
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$averageArgs = PHPExcel_Calculation_Functions::flattenArray($averageArgs);
- if (count($averageArgs) == 0) {
+ if (empty($averageArgs)) {
$averageArgs = $aArgs;
}
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
@@ -956,21 +957,21 @@ class PHPExcel_Calculation_Statistical {
/**
- * BINOMDIST
+ * BINOMDIST
*
- * Returns the individual term binomial distribution probability. Use BINOMDIST in problems with
- * a fixed number of tests or trials, when the outcomes of any trial are only success or failure,
- * when trials are independent, and when the probability of success is constant throughout the
- * experiment. For example, BINOMDIST can calculate the probability that two of the next three
- * babies born are male.
+ * Returns the individual term binomial distribution probability. Use BINOMDIST in problems with
+ * a fixed number of tests or trials, when the outcomes of any trial are only success or failure,
+ * when trials are independent, and when the probability of success is constant throughout the
+ * experiment. For example, BINOMDIST can calculate the probability that two of the next three
+ * babies born are male.
*
- * @param float $value Number of successes in trials
- * @param float $trials Number of trials
- * @param float $probability Probability of success on each trial
- * @param boolean $cumulative
- * @return float
+ * @param float $value Number of successes in trials
+ * @param float $trials Number of trials
+ * @param float $probability Probability of success on each trial
+ * @param boolean $cumulative
+ * @return float
*
- * @todo Cumulative distribution function
+ * @todo Cumulative distribution function
*
*/
public static function BINOMDIST($value, $trials, $probability, $cumulative) {
@@ -1002,13 +1003,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * CHIDIST
+ * CHIDIST
*
- * Returns the one-tailed probability of the chi-squared distribution.
+ * Returns the one-tailed probability of the chi-squared distribution.
*
- * @param float $value Value for the function
- * @param float $degrees degrees of freedom
- * @return float
+ * @param float $value Value for the function
+ * @param float $degrees degrees of freedom
+ * @return float
*/
public static function CHIDIST($value, $degrees) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -1031,13 +1032,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * CHIINV
+ * CHIINV
*
- * Returns the one-tailed probability of the chi-squared distribution.
+ * Returns the one-tailed probability of the chi-squared distribution.
*
- * @param float $probability Probability for the function
- * @param float $degrees degrees of freedom
- * @return float
+ * @param float $probability Probability for the function
+ * @param float $degrees degrees of freedom
+ * @return float
*/
public static function CHIINV($probability, $degrees) {
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
@@ -1116,13 +1117,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * CORREL
+ * CORREL
*
- * Returns covariance, the average of the products of deviations for each data point pair.
+ * Returns covariance, the average of the products of deviations for each data point pair.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @return float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @return float
*/
public static function CORREL($yValues,$xValues=null) {
if ((is_null($xValues)) || (!is_array($yValues)) || (!is_array($xValues))) {
@@ -1146,17 +1147,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * COUNT
+ * COUNT
*
- * Counts the number of cells that contain numbers within the list of arguments
+ * Counts the number of cells that contain numbers within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* COUNT(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return int
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return int
*/
public static function COUNT() {
// Return value
@@ -1181,17 +1182,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * COUNTA
+ * COUNTA
*
- * Counts the number of cells that are not empty within the list of arguments
+ * Counts the number of cells that are not empty within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* COUNTA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return int
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return int
*/
public static function COUNTA() {
// Return value
@@ -1212,17 +1213,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * COUNTBLANK
+ * COUNTBLANK
*
- * Counts the number of empty cells within the list of arguments
+ * Counts the number of empty cells within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* COUNTBLANK(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return int
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return int
*/
public static function COUNTBLANK() {
// Return value
@@ -1243,18 +1244,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * COUNTIF
+ * COUNTIF
*
- * Counts the number of cells that contain numbers within the list of arguments
+ * Counts the number of cells that contain numbers within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* COUNTIF(value1[,value2[, ...]],condition)
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @param string $condition The criteria that defines which cells will be counted.
- * @return int
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be counted.
+ * @return int
*/
public static function COUNTIF($aArgs,$condition) {
// Return value
@@ -1278,13 +1279,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * COVAR
+ * COVAR
*
- * Returns covariance, the average of the products of deviations for each data point pair.
+ * Returns covariance, the average of the products of deviations for each data point pair.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @return float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @return float
*/
public static function COVAR($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
@@ -1305,19 +1306,19 @@ class PHPExcel_Calculation_Statistical {
/**
- * CRITBINOM
+ * CRITBINOM
*
- * Returns the smallest value for which the cumulative binomial distribution is greater
- * than or equal to a criterion value
+ * Returns the smallest value for which the cumulative binomial distribution is greater
+ * than or equal to a criterion value
*
- * See http://support.microsoft.com/kb/828117/ for details of the algorithm used
+ * See http://support.microsoft.com/kb/828117/ for details of the algorithm used
*
- * @param float $trials number of Bernoulli trials
- * @param float $probability probability of a success on each trial
- * @param float $alpha criterion value
- * @return int
+ * @param float $trials number of Bernoulli trials
+ * @param float $probability probability of a success on each trial
+ * @param float $alpha criterion value
+ * @return int
*
- * @todo Warning. This implementation differs from the algorithm detailed on the MS
+ * @todo Warning. This implementation differs from the algorithm detailed on the MS
* web site in that $CumPGuessMinus1 = $CumPGuess - 1 rather than $CumPGuess - $PGuess
* This eliminates a potential endless loop error, but may have an adverse affect on the
* accuracy of the function (although all my tests have so far returned correct results).
@@ -1415,17 +1416,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * DEVSQ
+ * DEVSQ
*
- * Returns the sum of squares of deviations of data points from their sample mean.
+ * Returns the sum of squares of deviations of data points from their sample mean.
*
- * Excel Function:
+ * Excel Function:
* DEVSQ(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function DEVSQ() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
@@ -1464,16 +1465,16 @@ class PHPExcel_Calculation_Statistical {
/**
- * EXPONDIST
+ * EXPONDIST
*
* Returns the exponential distribution. Use EXPONDIST to model the time between events,
- * such as how long an automated bank teller takes to deliver cash. For example, you can
- * use EXPONDIST to determine the probability that the process takes at most 1 minute.
+ * such as how long an automated bank teller takes to deliver cash. For example, you can
+ * use EXPONDIST to determine the probability that the process takes at most 1 minute.
*
- * @param float $value Value of the function
- * @param float $lambda The parameter value
- * @param boolean $cumulative
- * @return float
+ * @param float $value Value of the function
+ * @param float $lambda The parameter value
+ * @param boolean $cumulative
+ * @return float
*/
public static function EXPONDIST($value, $lambda, $cumulative) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -1497,14 +1498,14 @@ class PHPExcel_Calculation_Statistical {
/**
- * FISHER
+ * FISHER
*
- * Returns the Fisher transformation at x. This transformation produces a function that
- * is normally distributed rather than skewed. Use this function to perform hypothesis
- * testing on the correlation coefficient.
+ * Returns the Fisher transformation at x. This transformation produces a function that
+ * is normally distributed rather than skewed. Use this function to perform hypothesis
+ * testing on the correlation coefficient.
*
- * @param float $value
- * @return float
+ * @param float $value
+ * @return float
*/
public static function FISHER($value) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -1520,14 +1521,14 @@ class PHPExcel_Calculation_Statistical {
/**
- * FISHERINV
+ * FISHERINV
*
- * Returns the inverse of the Fisher transformation. Use this transformation when
- * analyzing correlations between ranges or arrays of data. If y = FISHER(x), then
- * FISHERINV(y) = x.
+ * Returns the inverse of the Fisher transformation. Use this transformation when
+ * analyzing correlations between ranges or arrays of data. If y = FISHER(x), then
+ * FISHERINV(y) = x.
*
- * @param float $value
- * @return float
+ * @param float $value
+ * @return float
*/
public static function FISHERINV($value) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -1540,14 +1541,14 @@ class PHPExcel_Calculation_Statistical {
/**
- * FORECAST
+ * FORECAST
*
- * Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value.
+ * Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value.
*
- * @param float Value of X for which we want to find Y
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @return float
+ * @param float Value of X for which we want to find Y
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @return float
*/
public static function FORECAST($xValue,$yValues,$xValues) {
$xValue = PHPExcel_Calculation_Functions::flattenSingleValue($xValue);
@@ -1688,19 +1689,19 @@ class PHPExcel_Calculation_Statistical {
/**
- * GEOMEAN
+ * GEOMEAN
*
- * Returns the geometric mean of an array or range of positive data. For example, you
+ * Returns the geometric mean of an array or range of positive data. For example, you
* can use GEOMEAN to calculate average growth rate given compound interest with
* variable rates.
*
- * Excel Function:
+ * Excel Function:
* GEOMEAN(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function GEOMEAN() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@@ -1717,15 +1718,15 @@ class PHPExcel_Calculation_Statistical {
/**
- * GROWTH
+ * GROWTH
*
- * Returns values along a predicted emponential trend
+ * Returns values along a predicted emponential trend
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @param array of mixed Values of X for which we want to find Y
- * @param boolean A logical value specifying whether to force the intersect to equal 0.
- * @return array of float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @param array of mixed Values of X for which we want to find Y
+ * @param boolean A logical value specifying whether to force the intersect to equal 0.
+ * @return array of float
*/
public static function GROWTH($yValues,$xValues=array(),$newValues=array(),$const=True) {
$yValues = PHPExcel_Calculation_Functions::flattenArray($yValues);
@@ -1734,7 +1735,7 @@ class PHPExcel_Calculation_Statistical {
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
$bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const);
- if (count($newValues) == 0) {
+ if (empty($newValues)) {
$newValues = $bestFitExponential->getXValues();
}
@@ -1748,18 +1749,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * HARMEAN
+ * HARMEAN
*
- * Returns the harmonic mean of a data set. The harmonic mean is the reciprocal of the
+ * Returns the harmonic mean of a data set. The harmonic mean is the reciprocal of the
* arithmetic mean of reciprocals.
*
- * Excel Function:
+ * Excel Function:
* HARMEAN(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function HARMEAN() {
// Return value
@@ -1833,13 +1834,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * INTERCEPT
+ * INTERCEPT
*
- * Calculates the point at which a line will intersect the y-axis by using existing x-values and y-values.
+ * Calculates the point at which a line will intersect the y-axis by using existing x-values and y-values.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @return float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @return float
*/
public static function INTERCEPT($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
@@ -1900,19 +1901,19 @@ class PHPExcel_Calculation_Statistical {
/**
- * LARGE
+ * LARGE
*
- * Returns the nth largest value in a data set. You can use this function to
+ * Returns the nth largest value in a data set. You can use this function to
* select a value based on its relative standing.
*
- * Excel Function:
+ * Excel Function:
* LARGE(value1[,value2[, ...]],entry)
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @param int $entry Position (ordered from the largest) in the array or range of data to return
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @param int $entry Position (ordered from the largest) in the array or range of data to return
+ * @return float
*
*/
public static function LARGE() {
@@ -1942,16 +1943,16 @@ class PHPExcel_Calculation_Statistical {
/**
- * LINEST
+ * LINEST
*
- * Calculates the statistics for a line by using the "least squares" method to calculate a straight line that best fits your data,
+ * Calculates the statistics for a line by using the "least squares" method to calculate a straight line that best fits your data,
* and then returns an array that describes the line.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @param boolean A logical value specifying whether to force the intersect to equal 0.
- * @param boolean A logical value specifying whether to return additional regression statistics.
- * @return array
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @param boolean A logical value specifying whether to force the intersect to equal 0.
+ * @param boolean A logical value specifying whether to return additional regression statistics.
+ * @return array
*/
public static function LINEST($yValues,$xValues=null,$const=True,$stats=False) {
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
@@ -1995,16 +1996,16 @@ class PHPExcel_Calculation_Statistical {
/**
- * LOGEST
+ * LOGEST
*
- * Calculates an exponential curve that best fits the X and Y data series,
+ * Calculates an exponential curve that best fits the X and Y data series,
* and then returns an array that describes the line.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @param boolean A logical value specifying whether to force the intersect to equal 0.
- * @param boolean A logical value specifying whether to return additional regression statistics.
- * @return array
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @param boolean A logical value specifying whether to force the intersect to equal 0.
+ * @param boolean A logical value specifying whether to return additional regression statistics.
+ * @return array
*/
public static function LOGEST($yValues,$xValues=null,$const=True,$stats=False) {
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
@@ -2105,18 +2106,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * MAX
+ * MAX
*
- * MAX returns the value of the element of the values passed that has the highest value,
+ * MAX returns the value of the element of the values passed that has the highest value,
* with negative numbers considered smaller than positive numbers.
*
- * Excel Function:
+ * Excel Function:
* MAX(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function MAX() {
// Return value
@@ -2142,17 +2143,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * MAXA
+ * MAXA
*
- * Returns the greatest value in a list of arguments, including numbers, text, and logical values
+ * Returns the greatest value in a list of arguments, including numbers, text, and logical values
*
- * Excel Function:
+ * Excel Function:
* MAXA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function MAXA() {
// Return value
@@ -2183,18 +2184,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * MAXIF
+ * MAXIF
*
- * Counts the maximum value within a range of cells that contain numbers within the list of arguments
+ * Counts the maximum value within a range of cells that contain numbers within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* MAXIF(value1[,value2[, ...]],condition)
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @param string $condition The criteria that defines which cells will be checked.
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be checked.
+ * @return float
*/
public static function MAXIF($aArgs,$condition,$sumArgs = array()) {
// Return value
@@ -2202,7 +2203,7 @@ class PHPExcel_Calculation_Statistical {
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
- if (count($sumArgs) == 0) {
+ if (empty($sumArgs)) {
$sumArgs = $aArgs;
}
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
@@ -2223,17 +2224,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * MEDIAN
+ * MEDIAN
*
- * Returns the median of the given numbers. The median is the number in the middle of a set of numbers.
+ * Returns the median of the given numbers. The median is the number in the middle of a set of numbers.
*
- * Excel Function:
+ * Excel Function:
* MEDIAN(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function MEDIAN() {
// Return value
@@ -2267,18 +2268,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * MIN
+ * MIN
*
- * MIN returns the value of the element of the values passed that has the smallest value,
+ * MIN returns the value of the element of the values passed that has the smallest value,
* with negative numbers considered smaller than positive numbers.
*
- * Excel Function:
+ * Excel Function:
* MIN(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function MIN() {
// Return value
@@ -2304,17 +2305,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * MINA
+ * MINA
*
- * Returns the smallest value in a list of arguments, including numbers, text, and logical values
+ * Returns the smallest value in a list of arguments, including numbers, text, and logical values
*
- * Excel Function:
+ * Excel Function:
* MINA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function MINA() {
// Return value
@@ -2345,18 +2346,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * MINIF
+ * MINIF
*
- * Returns the minimum value within a range of cells that contain numbers within the list of arguments
+ * Returns the minimum value within a range of cells that contain numbers within the list of arguments
*
- * Excel Function:
+ * Excel Function:
* MINIF(value1[,value2[, ...]],condition)
*
- * @access public
- * @category Mathematical and Trigonometric Functions
- * @param mixed $arg,... Data values
- * @param string $condition The criteria that defines which cells will be checked.
- * @return float
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be checked.
+ * @return float
*/
public static function MINIF($aArgs,$condition,$sumArgs = array()) {
// Return value
@@ -2364,7 +2365,7 @@ class PHPExcel_Calculation_Statistical {
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
- if (count($sumArgs) == 0) {
+ if (empty($sumArgs)) {
$sumArgs = $aArgs;
}
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
@@ -2419,17 +2420,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * MODE
+ * MODE
*
- * Returns the most frequently occurring, or repetitive, value in an array or range of data
+ * Returns the most frequently occurring, or repetitive, value in an array or range of data
*
- * Excel Function:
+ * Excel Function:
* MODE(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function MODE() {
// Return value
@@ -2446,7 +2447,7 @@ class PHPExcel_Calculation_Statistical {
}
}
- if (count($mArgs) > 0) {
+ if (!empty($mArgs)) {
return self::_modeCalc($mArgs);
}
@@ -2456,18 +2457,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * NEGBINOMDIST
+ * NEGBINOMDIST
*
- * Returns the negative binomial distribution. NEGBINOMDIST returns the probability that
- * there will be number_f failures before the number_s-th success, when the constant
- * probability of a success is probability_s. This function is similar to the binomial
- * distribution, except that the number of successes is fixed, and the number of trials is
- * variable. Like the binomial, trials are assumed to be independent.
+ * Returns the negative binomial distribution. NEGBINOMDIST returns the probability that
+ * there will be number_f failures before the number_s-th success, when the constant
+ * probability of a success is probability_s. This function is similar to the binomial
+ * distribution, except that the number of successes is fixed, and the number of trials is
+ * variable. Like the binomial, trials are assumed to be independent.
*
- * @param float $failures Number of Failures
- * @param float $successes Threshold number of Successes
- * @param float $probability Probability of success on each trial
- * @return float
+ * @param float $failures Number of Failures
+ * @param float $successes Threshold number of Successes
+ * @param float $probability Probability of success on each trial
+ * @return float
*
*/
public static function NEGBINOMDIST($failures, $successes, $probability) {
@@ -2588,18 +2589,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * PERCENTILE
+ * PERCENTILE
*
- * Returns the nth percentile of values in a range..
+ * Returns the nth percentile of values in a range..
*
- * Excel Function:
+ * Excel Function:
* PERCENTILE(value1[,value2[, ...]],entry)
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @param float $entry Percentile value in the range 0..1, inclusive.
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @param float $entry Percentile value in the range 0..1, inclusive.
+ * @return float
*/
public static function PERCENTILE() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@@ -2638,14 +2639,14 @@ class PHPExcel_Calculation_Statistical {
/**
- * PERCENTRANK
+ * PERCENTRANK
*
- * Returns the rank of a value in a data set as a percentage of the data set.
+ * Returns the rank of a value in a data set as a percentage of the data set.
*
- * @param array of number An array of, or a reference to, a list of numbers.
- * @param number The number whose rank you want to find.
- * @param number The number of significant digits for the returned percentage value.
- * @return float
+ * @param array of number An array of, or a reference to, a list of numbers.
+ * @param number The number whose rank you want to find.
+ * @param number The number of significant digits for the returned percentage value.
+ * @return float
*/
public static function PERCENTRANK($valueSet,$value,$significance=3) {
$valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet);
@@ -2684,17 +2685,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * PERMUT
+ * PERMUT
*
- * Returns the number of permutations for a given number of objects that can be
- * selected from number objects. A permutation is any set or subset of objects or
- * events where internal order is significant. Permutations are different from
- * combinations, for which the internal order is not significant. Use this function
- * for lottery-style probability calculations.
+ * Returns the number of permutations for a given number of objects that can be
+ * selected from number objects. A permutation is any set or subset of objects or
+ * events where internal order is significant. Permutations are different from
+ * combinations, for which the internal order is not significant. Use this function
+ * for lottery-style probability calculations.
*
- * @param int $numObjs Number of different objects
- * @param int $numInSet Number of objects in each permutation
- * @return int Number of permutations
+ * @param int $numObjs Number of different objects
+ * @param int $numInSet Number of objects in each permutation
+ * @return int Number of permutations
*/
public static function PERMUT($numObjs,$numInSet) {
$numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs);
@@ -2749,18 +2750,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * QUARTILE
+ * QUARTILE
*
- * Returns the quartile of a data set.
+ * Returns the quartile of a data set.
*
- * Excel Function:
+ * Excel Function:
* QUARTILE(value1[,value2[, ...]],entry)
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @param int $entry Quartile value in the range 1..3, inclusive.
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @param int $entry Quartile value in the range 1..3, inclusive.
+ * @return float
*/
public static function QUARTILE() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@@ -2780,14 +2781,14 @@ class PHPExcel_Calculation_Statistical {
/**
- * RANK
+ * RANK
*
- * Returns the rank of a number in a list of numbers.
+ * Returns the rank of a number in a list of numbers.
*
- * @param number The number whose rank you want to find.
- * @param array of number An array of, or a reference to, a list of numbers.
- * @param mixed Order to sort the values in the value set
- * @return float
+ * @param number The number whose rank you want to find.
+ * @param array of number An array of, or a reference to, a list of numbers.
+ * @param mixed Order to sort the values in the value set
+ * @return float
*/
public static function RANK($value,$valueSet,$order=0) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -2815,13 +2816,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * RSQ
+ * RSQ
*
- * Returns the square of the Pearson product moment correlation coefficient through data points in known_y's and known_x's.
+ * Returns the square of the Pearson product moment correlation coefficient through data points in known_y's and known_x's.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @return float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @return float
*/
public static function RSQ($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
@@ -2880,13 +2881,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * SLOPE
+ * SLOPE
*
- * Returns the slope of the linear regression line through data points in known_y's and known_x's.
+ * Returns the slope of the linear regression line through data points in known_y's and known_x's.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @return float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @return float
*/
public static function SLOPE($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
@@ -2907,19 +2908,19 @@ class PHPExcel_Calculation_Statistical {
/**
- * SMALL
+ * SMALL
*
- * Returns the nth smallest value in a data set. You can use this function to
+ * Returns the nth smallest value in a data set. You can use this function to
* select a value based on its relative standing.
*
- * Excel Function:
+ * Excel Function:
* SMALL(value1[,value2[, ...]],entry)
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @param int $entry Position (ordered from the smallest) in the array or range of data to return
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @param int $entry Position (ordered from the smallest) in the array or range of data to return
+ * @return float
*/
public static function SMALL() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@@ -2948,14 +2949,14 @@ class PHPExcel_Calculation_Statistical {
/**
- * STANDARDIZE
+ * STANDARDIZE
*
- * Returns a normalized value from a distribution characterized by mean and standard_dev.
+ * Returns a normalized value from a distribution characterized by mean and standard_dev.
*
- * @param float $value Value to normalize
- * @param float $mean Mean Value
- * @param float $stdDev Standard Deviation
- * @return float Standardized value
+ * @param float $value Value to normalize
+ * @param float $mean Mean Value
+ * @param float $stdDev Standard Deviation
+ * @return float Standardized value
*/
public static function STANDARDIZE($value,$mean,$stdDev) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -2973,18 +2974,18 @@ class PHPExcel_Calculation_Statistical {
/**
- * STDEV
+ * STDEV
*
- * Estimates standard deviation based on a sample. The standard deviation is a measure of how
- * widely values are dispersed from the average value (the mean).
+ * Estimates standard deviation based on a sample. The standard deviation is a measure of how
+ * widely values are dispersed from the average value (the mean).
*
- * Excel Function:
+ * Excel Function:
* STDEV(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function STDEV() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
@@ -3021,17 +3022,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * STDEVA
+ * STDEVA
*
- * Estimates standard deviation based on a sample, including numbers, text, and logical values
+ * Estimates standard deviation based on a sample, including numbers, text, and logical values
*
- * Excel Function:
+ * Excel Function:
* STDEVA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function STDEVA() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
@@ -3073,17 +3074,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * STDEVP
+ * STDEVP
*
- * Calculates standard deviation based on the entire population
+ * Calculates standard deviation based on the entire population
*
- * Excel Function:
+ * Excel Function:
* STDEVP(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function STDEVP() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
@@ -3120,17 +3121,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * STDEVPA
+ * STDEVPA
*
- * Calculates standard deviation based on the entire population, including numbers, text, and logical values
+ * Calculates standard deviation based on the entire population, including numbers, text, and logical values
*
- * Excel Function:
+ * Excel Function:
* STDEVPA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function STDEVPA() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
@@ -3172,13 +3173,13 @@ class PHPExcel_Calculation_Statistical {
/**
- * STEYX
+ * STEYX
*
- * Returns the standard error of the predicted y-value for each x in the regression.
+ * Returns the standard error of the predicted y-value for each x in the regression.
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @return float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @return float
*/
public static function STEYX($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
@@ -3315,15 +3316,15 @@ class PHPExcel_Calculation_Statistical {
/**
- * TREND
+ * TREND
*
- * Returns values along a linear trend
+ * Returns values along a linear trend
*
- * @param array of mixed Data Series Y
- * @param array of mixed Data Series X
- * @param array of mixed Values of X for which we want to find Y
- * @param boolean A logical value specifying whether to force the intersect to equal 0.
- * @return array of float
+ * @param array of mixed Data Series Y
+ * @param array of mixed Data Series X
+ * @param array of mixed Values of X for which we want to find Y
+ * @param boolean A logical value specifying whether to force the intersect to equal 0.
+ * @return array of float
*/
public static function TREND($yValues,$xValues=array(),$newValues=array(),$const=True) {
$yValues = PHPExcel_Calculation_Functions::flattenArray($yValues);
@@ -3332,7 +3333,7 @@ class PHPExcel_Calculation_Statistical {
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const);
- if (count($newValues) == 0) {
+ if (empty($newValues)) {
$newValues = $bestFitLinear->getXValues();
}
@@ -3346,20 +3347,20 @@ class PHPExcel_Calculation_Statistical {
/**
- * TRIMMEAN
+ * TRIMMEAN
*
- * Returns the mean of the interior of a data set. TRIMMEAN calculates the mean
- * taken by excluding a percentage of data points from the top and bottom tails
- * of a data set.
+ * Returns the mean of the interior of a data set. TRIMMEAN calculates the mean
+ * taken by excluding a percentage of data points from the top and bottom tails
+ * of a data set.
*
- * Excel Function:
+ * Excel Function:
* TRIMEAN(value1[,value2[, ...]],$discard)
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @param float $discard Percentage to discard
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @param float $discard Percentage to discard
+ * @return float
*/
public static function TRIMMEAN() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
@@ -3391,17 +3392,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * VARFunc
+ * VARFunc
*
- * Estimates variance based on a sample.
+ * Estimates variance based on a sample.
*
- * Excel Function:
+ * Excel Function:
* VAR(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function VARFunc() {
// Return value
@@ -3433,17 +3434,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * VARA
+ * VARA
*
- * Estimates variance based on a sample, including numbers, text, and logical values
+ * Estimates variance based on a sample, including numbers, text, and logical values
*
- * Excel Function:
+ * Excel Function:
* VARA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function VARA() {
// Return value
@@ -3486,17 +3487,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * VARP
+ * VARP
*
- * Calculates variance based on the entire population
+ * Calculates variance based on the entire population
*
- * Excel Function:
+ * Excel Function:
* VARP(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function VARP() {
// Return value
@@ -3528,17 +3529,17 @@ class PHPExcel_Calculation_Statistical {
/**
- * VARPA
+ * VARPA
*
- * Calculates variance based on the entire population, including numbers, text, and logical values
+ * Calculates variance based on the entire population, including numbers, text, and logical values
*
- * Excel Function:
+ * Excel Function:
* VARPA(value1[,value2[, ...]])
*
- * @access public
- * @category Statistical Functions
- * @param mixed $arg,... Data values
- * @return float
+ * @access public
+ * @category Statistical Functions
+ * @param mixed $arg,... Data values
+ * @return float
*/
public static function VARPA() {
// Return value
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php
index 9916876257b..3289645f519 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/TextData.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_TextData {
@@ -87,16 +87,16 @@ class PHPExcel_Calculation_TextData {
/**
- * TRIMNONPRINTABLE
+ * TRIMNONPRINTABLE
*
- * @param mixed $value Value to check
- * @return string
+ * @param mixed $value Value to check
+ * @return string
*/
public static function TRIMNONPRINTABLE($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) {
- $stringValue = ($stringValue) ? 'TRUE' : 'FALSE';
+ return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (self::$_invalidChars == Null) {
@@ -106,23 +106,27 @@ class PHPExcel_Calculation_TextData {
if (is_string($stringValue) || is_numeric($stringValue)) {
return str_replace(self::$_invalidChars,'',trim($stringValue,"\x00..\x1F"));
}
- return Null;
+ return NULL;
} // function TRIMNONPRINTABLE()
/**
- * TRIMSPACES
+ * TRIMSPACES
*
- * @param mixed $value Value to check
- * @return string
+ * @param mixed $value Value to check
+ * @return string
*/
public static function TRIMSPACES($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
- if (is_string($stringValue) || is_numeric($stringValue)) {
- return trim(preg_replace('/ +/',' ',$stringValue));
+ if (is_bool($stringValue)) {
+ return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
- return Null;
+
+ if (is_string($stringValue) || is_numeric($stringValue)) {
+ return trim(preg_replace('/ +/',' ',trim($stringValue,' ')));
+ }
+ return NULL;
} // function TRIMSPACES()
@@ -133,16 +137,14 @@ class PHPExcel_Calculation_TextData {
* @return int
*/
public static function ASCIICODE($characters) {
+ if (($characters === NULL) || ($characters === ''))
+ return PHPExcel_Calculation_Functions::VALUE();
$characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters);
if (is_bool($characters)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$characters = (int) $characters;
} else {
- if ($characters) {
- $characters = 'True';
- } else {
- $characters = 'False';
- }
+ $characters = ($characters) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
}
@@ -173,11 +175,7 @@ class PHPExcel_Calculation_TextData {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$arg = (int) $arg;
} else {
- if ($arg) {
- $arg = 'TRUE';
- } else {
- $arg = 'FALSE';
- }
+ $arg = ($arg) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
}
$returnValue .= $arg;
@@ -189,16 +187,16 @@ class PHPExcel_Calculation_TextData {
/**
- * DOLLAR
+ * DOLLAR
*
- * This function converts a number to text using currency format, with the decimals rounded to the specified place.
- * The format used is $#,##0.00_);($#,##0.00)..
+ * This function converts a number to text using currency format, with the decimals rounded to the specified place.
+ * The format used is $#,##0.00_);($#,##0.00)..
*
- * @param float $value The value to format
- * @param int $decimals The number of digits to display to the right of the decimal point.
+ * @param float $value The value to format
+ * @param int $decimals The number of digits to display to the right of the decimal point.
* If decimals is negative, number is rounded to the left of the decimal point.
* If you omit decimals, it is assumed to be 2
- * @return string
+ * @return string
*/
public static function DOLLAR($value = 0, $decimals = 2) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -238,12 +236,15 @@ class PHPExcel_Calculation_TextData {
if (!is_bool($needle)) {
if (is_bool($haystack)) {
- $haystack = ($haystack) ? 'TRUE' : 'FALSE';
+ $haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
- if (($offset > 0) && (strlen($haystack) > $offset)) {
+ if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) {
+ if (PHPExcel_Shared_String::CountCharacters($needle) == 0) {
+ return $offset;
+ }
if (function_exists('mb_strpos')) {
- $pos = mb_strpos($haystack, $needle, --$offset,'UTF-8');
+ $pos = mb_strpos($haystack, $needle, --$offset, 'UTF-8');
} else {
$pos = strpos($haystack, $needle, --$offset);
}
@@ -271,10 +272,13 @@ class PHPExcel_Calculation_TextData {
if (!is_bool($needle)) {
if (is_bool($haystack)) {
- $haystack = ($haystack) ? 'TRUE' : 'FALSE';
+ $haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
- if (($offset > 0) && (strlen($haystack) > $offset)) {
+ if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) {
+ if (PHPExcel_Shared_String::CountCharacters($needle) == 0) {
+ return $offset;
+ }
if (function_exists('mb_stripos')) {
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
} else {
@@ -290,15 +294,21 @@ class PHPExcel_Calculation_TextData {
/**
- * FIXEDFORMAT
+ * FIXEDFORMAT
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
- public static function FIXEDFORMAT($value,$decimals=2,$no_commas=false) {
+ public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
- $no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);
+ $no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);
+
+ // Validate parameters
+ if (!is_numeric($value) || !is_numeric($decimals)) {
+ return PHPExcel_Calculation_Functions::NaN();
+ }
+ $decimals = floor($decimals);
$valueResult = round($value,$decimals);
if ($decimals < 0) { $decimals = 0; }
@@ -326,7 +336,7 @@ class PHPExcel_Calculation_TextData {
}
if (is_bool($value)) {
- $value = ($value) ? 'TRUE' : 'FALSE';
+ $value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (function_exists('mb_substr')) {
@@ -338,12 +348,12 @@ class PHPExcel_Calculation_TextData {
/**
- * MID
+ * MID
*
- * @param string $value Value
- * @param int $start Start character
- * @param int $chars Number of characters
- * @return string
+ * @param string $value Value
+ * @param int $start Start character
+ * @param int $chars Number of characters
+ * @return string
*/
public static function MID($value = '', $start = 1, $chars = null) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -355,7 +365,7 @@ class PHPExcel_Calculation_TextData {
}
if (is_bool($value)) {
- $value = ($value) ? 'TRUE' : 'FALSE';
+ $value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (function_exists('mb_substr')) {
@@ -367,11 +377,11 @@ class PHPExcel_Calculation_TextData {
/**
- * RIGHT
+ * RIGHT
*
- * @param string $value Value
- * @param int $chars Number of characters
- * @return string
+ * @param string $value Value
+ * @param int $chars Number of characters
+ * @return string
*/
public static function RIGHT($value = '', $chars = 1) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
@@ -382,7 +392,7 @@ class PHPExcel_Calculation_TextData {
}
if (is_bool($value)) {
- $value = ($value) ? 'TRUE' : 'FALSE';
+ $value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) {
@@ -404,7 +414,7 @@ class PHPExcel_Calculation_TextData {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (is_bool($value)) {
- $value = ($value) ? 'TRUE' : 'FALSE';
+ $value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (function_exists('mb_strlen')) {
@@ -416,18 +426,18 @@ class PHPExcel_Calculation_TextData {
/**
- * LOWERCASE
+ * LOWERCASE
*
- * Converts a string value to upper case.
+ * Converts a string value to upper case.
*
- * @param string $mixedCaseString
- * @return string
+ * @param string $mixedCaseString
+ * @return string
*/
public static function LOWERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
- $mixedCaseString = ($mixedCaseString) ? 'TRUE' : 'FALSE';
+ $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (function_exists('mb_convert_case')) {
@@ -439,18 +449,18 @@ class PHPExcel_Calculation_TextData {
/**
- * UPPERCASE
+ * UPPERCASE
*
- * Converts a string value to upper case.
+ * Converts a string value to upper case.
*
- * @param string $mixedCaseString
- * @return string
+ * @param string $mixedCaseString
+ * @return string
*/
public static function UPPERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
- $mixedCaseString = ($mixedCaseString) ? 'TRUE' : 'FALSE';
+ $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (function_exists('mb_convert_case')) {
@@ -462,18 +472,18 @@ class PHPExcel_Calculation_TextData {
/**
- * PROPERCASE
+ * PROPERCASE
*
- * Converts a string value to upper case.
+ * Converts a string value to upper case.
*
- * @param string $mixedCaseString
- * @return string
+ * @param string $mixedCaseString
+ * @return string
*/
public static function PROPERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
- $mixedCaseString = ($mixedCaseString) ? 'TRUE' : 'FALSE';
+ $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (function_exists('mb_convert_case')) {
@@ -485,12 +495,12 @@ class PHPExcel_Calculation_TextData {
/**
- * REPLACE
+ * REPLACE
*
- * @param string $value Value
- * @param int $start Start character
- * @param int $chars Number of characters
- * @return string
+ * @param string $value Value
+ * @param int $start Start character
+ * @param int $chars Number of characters
+ * @return string
*/
public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText) {
$oldText = PHPExcel_Calculation_Functions::flattenSingleValue($oldText);
@@ -506,13 +516,13 @@ class PHPExcel_Calculation_TextData {
/**
- * SUBSTITUTE
+ * SUBSTITUTE
*
- * @param string $text Value
- * @param string $fromText From Value
- * @param string $toText To Value
- * @param integer $instance Instance Number
- * @return string
+ * @param string $text Value
+ * @param string $fromText From Value
+ * @param string $toText To Value
+ * @param integer $instance Instance Number
+ * @return string
*/
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) {
$text = PHPExcel_Calculation_Functions::flattenSingleValue($text);
@@ -548,15 +558,15 @@ class PHPExcel_Calculation_TextData {
}
}
- return $left.$newText.$right;
+ return $text;
} // function SUBSTITUTE()
/**
- * RETURNSTRING
+ * RETURNSTRING
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
public static function RETURNSTRING($testValue = '') {
$testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
@@ -569,10 +579,10 @@ class PHPExcel_Calculation_TextData {
/**
- * TEXTFORMAT
+ * TEXTFORMAT
*
- * @param mixed $value Value to check
- * @return boolean
+ * @param mixed $value Value to check
+ * @return boolean
*/
public static function TEXTFORMAT($value,$format) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Calculation/Token/Stack.php b/htdocs/includes/phpexcel/PHPExcel/Calculation/Token/Stack.php
new file mode 100644
index 00000000000..ea7efa0c923
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Calculation/Token/Stack.php
@@ -0,0 +1,73 @@
+_count;
+ } // function count()
+
+
+ public function push($type,$value,$reference=null) {
+ $this->_stack[$this->_count++] = array('type' => $type,
+ 'value' => $value,
+ 'reference' => $reference
+ );
+ if ($type == 'Function') {
+ $localeFunction = PHPExcel_Calculation::_localeFunc($value);
+ if ($localeFunction != $value) {
+ $this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
+ }
+ }
+ } // function push()
+
+
+ public function pop() {
+ if ($this->_count > 0) {
+ return $this->_stack[--$this->_count];
+ }
+ return null;
+ } // function pop()
+
+
+ public function last($n=1) {
+ if ($this->_count-$n < 0) {
+ return null;
+ }
+ return $this->_stack[$this->_count-$n];
+ } // function last()
+
+
+ function __construct() {
+ }
+
+} // class PHPExcel_Calculation_Token_Stack
diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell.php b/htdocs/includes/phpexcel/PHPExcel/Cell.php
index 996d68aa754..75996f2942f 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Cell.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Cell.php
@@ -1,107 +1,120 @@
_parent->getCellCacheController()->updateCacheData($this);
@@ -109,7 +122,7 @@ class PHPExcel_Cell
}
public function detach() {
- $this->_parent = null;
+ $this->_parent = NULL;
}
public function attach($parent) {
@@ -118,16 +131,16 @@ class PHPExcel_Cell
/**
- * Create a new Cell
+ * Create a new Cell
*
- * @param string $pColumn
- * @param int $pRow
- * @param mixed $pValue
- * @param string $pDataType
- * @param PHPExcel_Worksheet $pSheet
- * @throws Exception
+ * @param string $pColumn
+ * @param int $pRow
+ * @param mixed $pValue
+ * @param string $pDataType
+ * @param PHPExcel_Worksheet $pSheet
+ * @throws PHPExcel_Exception
*/
- public function __construct($pColumn = 'A', $pRow = 1, $pValue = null, $pDataType = null, PHPExcel_Worksheet $pSheet = null)
+ public function __construct($pColumn = 'A', $pRow = 1, $pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL)
{
// Initialise cell coordinate
$this->_column = strtoupper($pColumn);
@@ -140,13 +153,13 @@ class PHPExcel_Cell
$this->_parent = $pSheet;
// Set datatype?
- if ($pDataType !== null) {
+ if ($pDataType !== NULL) {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType;
} else {
if (!self::getValueBinder()->bindValue($this, $pValue)) {
- throw new Exception("Value could not be bound to cell.");
+ throw new PHPExcel_Exception("Value could not be bound to cell.");
}
}
@@ -155,9 +168,9 @@ class PHPExcel_Cell
}
/**
- * Get cell coordinate column
+ * Get cell coordinate column
*
- * @return string
+ * @return string
*/
public function getColumn()
{
@@ -165,9 +178,9 @@ class PHPExcel_Cell
}
/**
- * Get cell coordinate row
+ * Get cell coordinate row
*
- * @return int
+ * @return int
*/
public function getRow()
{
@@ -175,9 +188,9 @@ class PHPExcel_Cell
}
/**
- * Get cell coordinate
+ * Get cell coordinate
*
- * @return string
+ * @return string
*/
public function getCoordinate()
{
@@ -185,9 +198,9 @@ class PHPExcel_Cell
}
/**
- * Get cell value
+ * Get cell value
*
- * @return mixed
+ * @return mixed
*/
public function getValue()
{
@@ -195,42 +208,45 @@ class PHPExcel_Cell
}
/**
- * Get cell value with formatting
+ * Get cell value with formatting
*
- * @return string
+ * @return string
*/
public function getFormattedValue()
{
- return PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(),
- $this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())->getNumberFormat()->getFormatCode()
- );
+ return (string) PHPExcel_Style_NumberFormat::toFormattedString(
+ $this->getCalculatedValue(),
+ $this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())
+ ->getNumberFormat()->getFormatCode()
+ );
}
/**
- * Set cell value
+ * Set cell value
*
- * This clears the cell formula.
+ * Sets the value for a cell, automatically determining the datatype using the value binder
*
- * @param mixed $pValue Value
- * @return PHPExcel_Cell
+ * @param mixed $pValue Value
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
*/
- public function setValue($pValue = null)
+ public function setValue($pValue = NULL)
{
if (!self::getValueBinder()->bindValue($this, $pValue)) {
- throw new Exception("Value could not be bound to cell.");
+ throw new PHPExcel_Exception("Value could not be bound to cell.");
}
return $this;
}
/**
- * Set cell value (with explicit data type given)
+ * Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder)
*
- * @param mixed $pValue Value
- * @param string $pDataType Explicit data type
- * @return PHPExcel_Cell
- * @throws Exception
+ * @param mixed $pValue Value
+ * @param string $pDataType Explicit data type
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
*/
- public function setValueExplicit($pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
+ public function setValueExplicit($pValue = NULL, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
// set the value according to data type
switch ($pDataType) {
@@ -241,25 +257,20 @@ class PHPExcel_Cell
case PHPExcel_Cell_DataType::TYPE_INLINE:
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
break;
-
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
$this->_value = (float)$pValue;
break;
-
case PHPExcel_Cell_DataType::TYPE_FORMULA:
$this->_value = (string)$pValue;
break;
-
case PHPExcel_Cell_DataType::TYPE_BOOL:
$this->_value = (bool)$pValue;
break;
-
case PHPExcel_Cell_DataType::TYPE_ERROR:
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
break;
-
default:
- throw new Exception('Invalid datatype: ' . $pDataType);
+ throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
break;
}
@@ -270,11 +281,14 @@ class PHPExcel_Cell
}
/**
- * Get calculated cell value
+ * Get calculated cell value
*
- * @return mixed
+ * @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
+ *
+ * @return mixed
+ * @throws PHPExcel_Exception
*/
- public function getCalculatedValue($resetLog=true)
+ public function getCalculatedValue($resetLog = TRUE)
{
// echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().' ';
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
@@ -283,9 +297,17 @@ class PHPExcel_Cell
$result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog);
// echo $this->getCoordinate().' calculation result is '.$result.' ';
} catch ( Exception $ex ) {
+ if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
+// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().' ';
+ return $this->_calculatedValue; // Fallback for calculations referencing external files.
+ }
// echo 'Calculation Exception: '.$ex->getMessage().' ';
$result = '#N/A';
- throw(new Exception($this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()));
+ throw(
+ new PHPExcel_Exception(
+ $this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()
+ )
+ );
}
if ($result === '#Not Yet Implemented') {
@@ -296,33 +318,38 @@ class PHPExcel_Cell
return $result;
}
-// if (is_null($this->_value)) {
+// if ($this->_value === NULL) {
// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise ';
-// return null;
+// return NULL;
// }
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.' ';
return $this->_value;
}
/**
- * Set calculated value (used for caching)
+ * Set old calculated value (cached)
*
- * @param mixed $pValue Value
- * @return PHPExcel_Cell
+ * @param mixed $pValue Value
+ * @return PHPExcel_Cell
*/
- public function setCalculatedValue($pValue = null)
+ public function setCalculatedValue($pValue = NULL)
{
- if (!is_null($pValue)) {
- $this->_calculatedValue = $pValue;
+ if ($pValue !== NULL) {
+ $this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
}
return $this->notifyCacheController();
}
/**
- * Get old calculated value (cached)
+ * Get old calculated value (cached)
+ * This returns the value last calculated by MS Excel or whichever spreadsheet program was used to
+ * create the original spreadsheet file.
+ * Note that this value is not guaranteed to refelect the actual calculated value because it is
+ * possible that auto-calculation was disabled in the original spreadsheet, and underlying data
+ * values used by the formula have changed since it was last calculated.
*
- * @return mixed
+ * @return mixed
*/
public function getOldCalculatedValue()
{
@@ -330,9 +357,9 @@ class PHPExcel_Cell
}
/**
- * Get cell data type
+ * Get cell data type
*
- * @return string
+ * @return string
*/
public function getDataType()
{
@@ -340,10 +367,10 @@ class PHPExcel_Cell
}
/**
- * Set cell data type
+ * Set cell data type
*
- * @param string $pDataType
- * @return PHPExcel_Cell
+ * @param string $pDataType
+ * @return PHPExcel_Cell
*/
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
@@ -356,44 +383,46 @@ class PHPExcel_Cell
}
/**
- * Has Data validation?
+ * Does this cell contain Data validation rules?
*
- * @return boolean
+ * @return boolean
+ * @throws PHPExcel_Exception
*/
public function hasDataValidation()
{
if (!isset($this->_parent)) {
- throw new Exception('Cannot check for data validation when cell is not bound to a worksheet');
+ throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
}
return $this->_parent->dataValidationExists($this->getCoordinate());
}
/**
- * Get Data validation
+ * Get Data validation rules
*
- * @return PHPExcel_Cell_DataValidation
+ * @return PHPExcel_Cell_DataValidation
+ * @throws PHPExcel_Exception
*/
public function getDataValidation()
{
if (!isset($this->_parent)) {
- throw new Exception('Cannot get data validation for cell that is not bound to a worksheet');
+ throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
}
return $this->_parent->getDataValidation($this->getCoordinate());
}
/**
- * Set Data validation
+ * Set Data validation rules
*
- * @param PHPExcel_Cell_DataValidation $pDataValidation
- * @throws Exception
- * @return PHPExcel_Cell
+ * @param PHPExcel_Cell_DataValidation $pDataValidation
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
*/
- public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null)
+ public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = NULL)
{
if (!isset($this->_parent)) {
- throw new Exception('Cannot set data validation for cell that is not bound to a worksheet');
+ throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
}
$this->_parent->setDataValidation($this->getCoordinate(), $pDataValidation);
@@ -402,45 +431,46 @@ class PHPExcel_Cell
}
/**
- * Has Hyperlink
+ * Does this cell contain a Hyperlink?
*
- * @return boolean
+ * @return boolean
+ * @throws PHPExcel_Exception
*/
public function hasHyperlink()
{
if (!isset($this->_parent)) {
- throw new Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
+ throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
}
return $this->_parent->hyperlinkExists($this->getCoordinate());
}
/**
- * Get Hyperlink
+ * Get Hyperlink
*
- * @throws Exception
- * @return PHPExcel_Cell_Hyperlink
+ * @return PHPExcel_Cell_Hyperlink
+ * @throws PHPExcel_Exception
*/
public function getHyperlink()
{
if (!isset($this->_parent)) {
- throw new Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
+ throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
}
return $this->_parent->getHyperlink($this->getCoordinate());
}
/**
- * Set Hyperlink
+ * Set Hyperlink
*
- * @param PHPExcel_Cell_Hyperlink $pHyperlink
- * @throws Exception
- * @return PHPExcel_Cell
+ * @param PHPExcel_Cell_Hyperlink $pHyperlink
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
*/
- public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null)
+ public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = NULL)
{
if (!isset($this->_parent)) {
- throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
+ throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
}
$this->_parent->setHyperlink($this->getCoordinate(), $pHyperlink);
@@ -449,19 +479,19 @@ class PHPExcel_Cell
}
/**
- * Get parent
+ * Get parent worksheet
*
- * @return PHPExcel_Worksheet
+ * @return PHPExcel_Worksheet
*/
public function getParent() {
return $this->_parent;
}
/**
- * Re-bind parent
+ * Re-bind parent
*
- * @param PHPExcel_Worksheet $parent
- * @return PHPExcel_Cell
+ * @param PHPExcel_Worksheet $parent
+ * @return PHPExcel_Cell
*/
public function rebindParent(PHPExcel_Worksheet $parent) {
$this->_parent = $parent;
@@ -470,17 +500,17 @@ class PHPExcel_Cell
}
/**
- * Is cell in a specific range?
+ * Is cell in a specific range?
*
- * @param string $pRange Cell range (e.g. A1:A1)
- * @return boolean
+ * @param string $pRange Cell range (e.g. A1:A1)
+ * @return boolean
*/
public function isInRange($pRange = 'A1:A1')
{
- list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange);
+ list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
// Translate properties
- $myColumn = PHPExcel_Cell::columnIndexFromString($this->getColumn());
+ $myColumn = self::columnIndexFromString($this->getColumn());
$myRow = $this->getRow();
// Verify if cell is in range
@@ -490,75 +520,99 @@ class PHPExcel_Cell
}
/**
- * Coordinate from string
+ * Coordinate from string
*
- * @param string $pCoordinateString
- * @return array Array containing column and row (indexes 0 and 1)
- * @throws Exception
+ * @param string $pCoordinateString
+ * @return array Array containing column and row (indexes 0 and 1)
+ * @throws PHPExcel_Exception
*/
public static function coordinateFromString($pCoordinateString = 'A1')
{
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
return array($matches[1],$matches[2]);
- } elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) {
- throw new Exception('Cell coordinate string can not be a range of cells.');
+ } elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) {
+ throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') {
- throw new Exception('Cell coordinate can not be zero-length string.');
- } else {
- throw new Exception('Invalid cell coordinate '.$pCoordinateString);
+ throw new PHPExcel_Exception('Cell coordinate can not be zero-length string');
}
+
+ throw new PHPExcel_Exception('Invalid cell coordinate '.$pCoordinateString);
}
/**
- * Make string row, column or cell coordinate absolute
+ * Make string row, column or cell coordinate absolute
*
- * @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
- * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
- * @throws Exception
+ * @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
+ * Note that this value can be a row or column reference as well as a cell reference
+ * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
+ * @throws PHPExcel_Exception
*/
public static function absoluteReference($pCoordinateString = 'A1')
{
- if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
+ if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
+ // Split out any worksheet name from the reference
+ $worksheet = '';
+ $cellAddress = explode('!',$pCoordinateString);
+ if (count($cellAddress) > 1) {
+ list($worksheet,$pCoordinateString) = $cellAddress;
+ }
+ if ($worksheet > '') $worksheet .= '!';
+
// Create absolute coordinate
if (ctype_digit($pCoordinateString)) {
- return '$'.$pCoordinateString;
+ return $worksheet . '$' . $pCoordinateString;
} elseif (ctype_alpha($pCoordinateString)) {
- return '$'.strtoupper($pCoordinateString);
+ return $worksheet . '$' . strtoupper($pCoordinateString);
}
- return self::absoluteCoordinate($pCoordinateString);
- } else {
- throw new Exception("Coordinate string should not be a cell range.");
+ return $worksheet . self::absoluteCoordinate($pCoordinateString);
}
+
+ throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
}
/**
- * Make string coordinate absolute
+ * Make string coordinate absolute
*
- * @param string $pCoordinateString e.g. 'A1'
- * @return string Absolute coordinate e.g. '$A$1'
- * @throws Exception
+ * @param string $pCoordinateString e.g. 'A1'
+ * @return string Absolute coordinate e.g. '$A$1'
+ * @throws PHPExcel_Exception
*/
public static function absoluteCoordinate($pCoordinateString = 'A1')
{
- if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
+ if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
+ // Split out any worksheet name from the coordinate
+ $worksheet = '';
+ $cellAddress = explode('!',$pCoordinateString);
+ if (count($cellAddress) > 1) {
+ list($worksheet,$pCoordinateString) = $cellAddress;
+ }
+ if ($worksheet > '') $worksheet .= '!';
+
// Create absolute coordinate
- list($column, $row) = PHPExcel_Cell::coordinateFromString($pCoordinateString);
- if ($column[0] == '$') $column = substr($column,1);
- if ($row[0] == '$') $row = substr($row,1);
- return '$' . $column . '$' . $row;
- } else {
- throw new Exception("Coordinate string should not be a cell range.");
+ list($column, $row) = self::coordinateFromString($pCoordinateString);
+ $column = ltrim($column,'$');
+ $row = ltrim($row,'$');
+ return $worksheet . '$' . $column . '$' . $row;
}
+
+ throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
}
/**
- * Split range into coordinate strings
+ * Split range into coordinate strings
*
- * @param string $pRange
- * @return array Array containg one or more arrays containing one or two coordinate strings
+ * @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4'
+ * @return array Array containg one or more arrays containing one or two coordinate strings
+ * e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11'))
+ * or array('B4')
*/
public static function splitRange($pRange = 'A1:A1')
{
+ // Ensure $pRange is a valid range
+ if(empty($pRange)) {
+ $pRange = self::DEFAULT_RANGE;
+ }
+
$exploded = explode(',', $pRange);
$counter = count($exploded);
for ($i = 0; $i < $counter; ++$i) {
@@ -568,17 +622,17 @@ class PHPExcel_Cell
}
/**
- * Build range from coordinate strings
+ * Build range from coordinate strings
*
- * @param array $pRange Array containg one or more arrays containing one or two coordinate strings
- * @return string String representation of $pRange
- * @throws Exception
+ * @param array $pRange Array containg one or more arrays containing one or two coordinate strings
+ * @return string String representation of $pRange
+ * @throws PHPExcel_Exception
*/
public static function buildRange($pRange)
{
// Verify range
- if (!is_array($pRange) || count($pRange) == 0 || !is_array($pRange[0])) {
- throw new Exception('Range does not contain any information.');
+ if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) {
+ throw new PHPExcel_Exception('Range does not contain any information');
}
// Build range
@@ -593,61 +647,73 @@ class PHPExcel_Cell
}
/**
- * Calculate range boundaries
+ * Calculate range boundaries
*
- * @param string $pRange Cell range (e.g. A1:A1)
- * @return array Range coordinates (Start Cell, End Cell) where Start Cell and End Cell are arrays (Column Number, Row Number)
+ * @param string $pRange Cell range (e.g. A1:A1)
+ * @return array Range coordinates array(Start Cell, End Cell)
+ * where Start Cell and End Cell are arrays (Column Number, Row Number)
*/
public static function rangeBoundaries($pRange = 'A1:A1')
{
+ // Ensure $pRange is a valid range
+ if(empty($pRange)) {
+ $pRange = self::DEFAULT_RANGE;
+ }
+
// Uppercase coordinate
$pRange = strtoupper($pRange);
// Extract range
- if (strpos($pRange, ':') === false) {
+ if (strpos($pRange, ':') === FALSE) {
$rangeA = $rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
}
// Calculate range outer borders
- $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA);
- $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
+ $rangeStart = self::coordinateFromString($rangeA);
+ $rangeEnd = self::coordinateFromString($rangeB);
// Translate column into index
- $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]);
- $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]);
+ $rangeStart[0] = self::columnIndexFromString($rangeStart[0]);
+ $rangeEnd[0] = self::columnIndexFromString($rangeEnd[0]);
return array($rangeStart, $rangeEnd);
}
/**
- * Calculate range dimension
+ * Calculate range dimension
*
- * @param string $pRange Cell range (e.g. A1:A1)
- * @return array Range dimension (width, height)
+ * @param string $pRange Cell range (e.g. A1:A1)
+ * @return array Range dimension (width, height)
*/
public static function rangeDimension($pRange = 'A1:A1')
{
// Calculate range outer borders
- list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange);
+ list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
}
/**
- * Calculate range boundaries
+ * Calculate range boundaries
*
- * @param string $pRange Cell range (e.g. A1:A1)
- * @return array Range boundaries (staring Column, starting Row, Final Column, Final Row)
+ * @param string $pRange Cell range (e.g. A1:A1)
+ * @return array Range coordinates array(Start Cell, End Cell)
+ * where Start Cell and End Cell are arrays (Column ID, Row Number)
*/
public static function getRangeBoundaries($pRange = 'A1:A1')
{
+ // Ensure $pRange is a valid range
+ if(empty($pRange)) {
+ $pRange = self::DEFAULT_RANGE;
+ }
+
// Uppercase coordinate
$pRange = strtoupper($pRange);
// Extract range
- if (strpos($pRange, ':') === false) {
+ if (strpos($pRange, ':') === FALSE) {
$rangeA = $rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
@@ -657,14 +723,22 @@ class PHPExcel_Cell
}
/**
- * Column index from string
+ * Column index from string
*
- * @param string $pString
- * @return int Column index (base 1 !!!)
- * @throws Exception
+ * @param string $pString
+ * @return int Column index (base 1 !!!)
+ * @throws Exception
*/
public static function columnIndexFromString($pString = 'A')
{
+ // Using a lookup cache adds a slight memory overhead, but boosts speed
+ // caching using a static within the method is faster than a class static,
+ // though it's additional memory overhead
+ static $_indexCache = array();
+
+ if (isset($_indexCache[$pString]))
+ return $_indexCache[$pString];
+
// It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord()
// and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant
// memory overhead either
@@ -679,38 +753,53 @@ class PHPExcel_Cell
// for improved performance
if (isset($pString{0})) {
if (!isset($pString{1})) {
- return $_columnLookup[$pString];
+ $_indexCache[$pString] = $_columnLookup[$pString];
+ return $_indexCache[$pString];
} elseif(!isset($pString{2})) {
- return $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
+ $_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
+ return $_indexCache[$pString];
} elseif(!isset($pString{3})) {
- return $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
+ $_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
+ return $_indexCache[$pString];
}
}
- throw new Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty") . ".");
+ throw new PHPExcel_Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty"));
}
/**
- * String from columnindex
+ * String from columnindex
*
- * @param int $pColumnIndex Column index (base 0 !!!)
- * @return string
+ * @param int $pColumnIndex Column index (base 0 !!!)
+ * @return string
*/
public static function stringFromColumnIndex($pColumnIndex = 0)
{
- // Determine column string
- if ($pColumnIndex < 26) {
- return chr(65 + $pColumnIndex);
- } elseif ($pColumnIndex < 702) {
- return chr(64 + ($pColumnIndex / 26)).chr(65 + $pColumnIndex % 26);
+ // Using a lookup cache adds a slight memory overhead, but boosts speed
+ // caching using a static within the method is faster than a class static,
+ // though it's additional memory overhead
+ static $_indexCache = array();
+
+ if (!isset($_indexCache[$pColumnIndex])) {
+ // Determine column string
+ if ($pColumnIndex < 26) {
+ $_indexCache[$pColumnIndex] = chr(65 + $pColumnIndex);
+ } elseif ($pColumnIndex < 702) {
+ $_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)) .
+ chr(65 + $pColumnIndex % 26);
+ } else {
+ $_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676)) .
+ chr(65 + ((($pColumnIndex - 26) % 676) / 26)) .
+ chr(65 + $pColumnIndex % 26);
+ }
}
- return chr(64 + (($pColumnIndex - 26) / 676)).chr(65 + ((($pColumnIndex - 26) % 676) / 26)).chr(65 + $pColumnIndex % 26);
+ return $_indexCache[$pColumnIndex];
}
/**
- * Extract all cell references in range
+ * Extract all cell references in range
*
- * @param string $pRange Range (e.g. A1 or A1:A10 or A1:A10 A100:A1000)
- * @return array Array containing single cell references
+ * @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
+ * @return array Array containing single cell references
*/
public static function extractAllCellReferencesInRange($pRange = 'A1') {
// Returnvalue
@@ -720,13 +809,13 @@ class PHPExcel_Cell
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
foreach ($cellBlocks as $cellBlock) {
// Single cell?
- if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) {
+ if (strpos($cellBlock,':') === FALSE && strpos($cellBlock,',') === FALSE) {
$returnValue[] = $cellBlock;
continue;
}
// Range...
- $ranges = PHPExcel_Cell::splitRange($cellBlock);
+ $ranges = self::splitRange($cellBlock);
foreach($ranges as $range) {
// Single cell?
if (!isset($range[1])) {
@@ -756,8 +845,16 @@ class PHPExcel_Cell
}
}
+ // Sort the result by column and row
+ $sortKeys = array();
+ foreach (array_unique($returnValue) as $coord) {
+ list($column,$row) = sscanf($coord,'%[A-Z]%d');
+ $sortKeys[sprintf('%3s%09d',$column,$row)] = $coord;
+ }
+ ksort($sortKeys);
+
// Return value
- return $returnValue;
+ return array_values($sortKeys);
}
/**
@@ -773,7 +870,7 @@ class PHPExcel_Cell
return -1;
} elseif ($a->_row > $b->_row) {
return 1;
- } elseif (PHPExcel_Cell::columnIndexFromString($a->_column) < PHPExcel_Cell::columnIndexFromString($b->_column)) {
+ } elseif (self::columnIndexFromString($a->_column) < self::columnIndexFromString($b->_column)) {
return -1;
} else {
return 1;
@@ -786,7 +883,7 @@ class PHPExcel_Cell
* @return PHPExcel_Cell_IValueBinder
*/
public static function getValueBinder() {
- if (is_null(self::$_valueBinder)) {
+ if (self::$_valueBinder === NULL) {
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder();
}
@@ -799,8 +896,8 @@ class PHPExcel_Cell
* @param PHPExcel_Cell_IValueBinder $binder
* @throws Exception
*/
- public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = null) {
- if (is_null($binder)) {
+ public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) {
+ if ($binder === NULL) {
throw new Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
}
@@ -844,17 +941,32 @@ class PHPExcel_Cell
return $this->notifyCacheController();
}
-
+ /**
+ * @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
+ */
public function setFormulaAttributes($pAttributes)
{
$this->_formulaAttributes = $pAttributes;
return $this;
}
+ /**
+ * @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
+ */
public function getFormulaAttributes()
{
return $this->_formulaAttributes;
}
+ /**
+ * Convert to string
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->getValue();
+ }
+
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php b/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php
index df959dfa53e..3603f5ee61d 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Cell/AdvancedValueBinder.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{
@@ -66,10 +66,10 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Test for booleans using locale-setting
if ($value == PHPExcel_Calculation::getTRUE()) {
- $cell->setValueExplicit( True, PHPExcel_Cell_DataType::TYPE_BOOL);
+ $cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) {
- $cell->setValueExplicit( False, PHPExcel_Cell_DataType::TYPE_BOOL);
+ $cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
}
@@ -79,34 +79,82 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
return true;
}
+ // Check for fraction
+ if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
+ // Convert value to number
+ $value = $matches[2] / $matches[3];
+ if ($matches[1] == '-') $value = 0 - $value;
+ $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ // Set style
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode( '??/??' );
+ return true;
+ } elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
+ // Convert value to number
+ $value = $matches[2] + ($matches[3] / $matches[4]);
+ if ($matches[1] == '-') $value = 0 - $value;
+ $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ // Set style
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode( '# ??/??' );
+ return true;
+ }
+
// Check for percentage
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
// Convert value to number
- $cell->setValueExplicit( (float)str_replace('%', '', $value) / 100, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ $value = (float) str_replace('%', '', $value) / 100;
+ $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
- $cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE );
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
+ return true;
+ }
+
+ // Check for currency
+ $currencyCode = PHPExcel_Shared_String::getCurrencyCode();
+ if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
+ // Convert value to number
+ $value = (float) trim(str_replace(array($currencyCode,','), '', $value));
+ $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ // Set style
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode(
+ str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
+ );
+ return true;
+ } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
+ // Convert value to number
+ $value = (float) trim(str_replace(array('$',','), '', $value));
+ $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ // Set style
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
return true;
}
// Check for time without seconds e.g. '9:45', '09:45'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
+ // Convert value to number
list($h, $m) = explode(':', $value);
$days = $h / 24 + $m / 1440;
- // Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
- $cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
return true;
}
// Check for time with seconds '9:45:59', '09:45:59'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
+ // Convert value to number
list($h, $m, $s) = explode(':', $value);
$days = $h / 24 + $m / 1440 + $s / 86400;
// Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
- $cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
return true;
}
@@ -120,16 +168,18 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
} else {
$formatCode = 'yyyy-mm-dd';
}
- $cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode($formatCode);
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getNumberFormat()->setFormatCode($formatCode);
return true;
}
// Check for newline character "\n"
- if (strpos($value, "\n") !== false) {
+ if (strpos($value, "\n") !== FALSE) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
// Set style
- $cell->getParent()->getStyle( $cell->getCoordinate() )->getAlignment()->setWrapText(true);
+ $cell->getParent()->getStyle( $cell->getCoordinate() )
+ ->getAlignment()->setWrapText(TRUE);
return true;
}
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php b/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php
index 3143cded790..a833a5a44e3 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Cell/DataType.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DataType
{
@@ -41,7 +41,7 @@ class PHPExcel_Cell_DataType
const TYPE_FORMULA = 'f';
const TYPE_NUMERIC = 'n';
const TYPE_BOOL = 'b';
- const TYPE_NULL = 's';
+ const TYPE_NULL = 'null';
const TYPE_INLINE = 'inlineStr';
const TYPE_ERROR = 'e';
diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php b/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php
index 950c47709ef..01b1edb7e52 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Cell/DataValidation.php
@@ -2,27 +2,27 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DataValidation
{
@@ -44,12 +44,12 @@ class PHPExcel_Cell_DataValidation
const TYPE_TEXTLENGTH = 'textLength';
const TYPE_TIME = 'time';
const TYPE_WHOLE = 'whole';
-
+
/* Data validation error styles */
const STYLE_STOP = 'stop';
const STYLE_WARNING = 'warning';
const STYLE_INFORMATION = 'information';
-
+
/* Data validation operators */
const OPERATOR_BETWEEN = 'between';
const OPERATOR_EQUAL = 'equal';
@@ -59,98 +59,98 @@ class PHPExcel_Cell_DataValidation
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
const OPERATOR_NOTBETWEEN = 'notBetween';
const OPERATOR_NOTEQUAL = 'notEqual';
-
+
/**
* Formula 1
*
* @var string
*/
private $_formula1;
-
+
/**
* Formula 2
*
* @var string
*/
private $_formula2;
-
+
/**
* Type
*
* @var string
*/
private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
-
+
/**
* Error style
*
* @var string
*/
private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
-
+
/**
* Operator
*
* @var string
*/
private $_operator;
-
+
/**
* Allow Blank
*
* @var boolean
*/
private $_allowBlank;
-
+
/**
* Show DropDown
*
* @var boolean
*/
private $_showDropDown;
-
+
/**
* Show InputMessage
*
* @var boolean
*/
private $_showInputMessage;
-
+
/**
* Show ErrorMessage
*
* @var boolean
*/
private $_showErrorMessage;
-
+
/**
* Error title
*
* @var string
*/
private $_errorTitle;
-
+
/**
* Error
*
* @var string
*/
private $_error;
-
+
/**
* Prompt title
*
* @var string
*/
private $_promptTitle;
-
+
/**
* Prompt
*
* @var string
*/
private $_prompt;
-
+
/**
* Create a new PHPExcel_Cell_DataValidation
*
@@ -173,7 +173,7 @@ class PHPExcel_Cell_DataValidation
$this->_promptTitle = '';
$this->_prompt = '';
}
-
+
/**
* Get Formula 1
*
@@ -213,7 +213,7 @@ class PHPExcel_Cell_DataValidation
$this->_formula2 = $value;
return $this;
}
-
+
/**
* Get Type
*
@@ -433,12 +433,12 @@ class PHPExcel_Cell_DataValidation
$this->_prompt = $value;
return $this;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_formula1
@@ -457,7 +457,7 @@ class PHPExcel_Cell_DataValidation
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php b/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php
index 07134633f0c..f520cc5ed7a 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Cell/DefaultValueBinder.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -41,7 +41,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{
@@ -60,7 +60,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
}
// Set value explicit
- $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::dataTypeForValue($value) );
+ $cell->setValueExplicit( $value, self::dataTypeForValue($value) );
// Done!
return true;
@@ -81,7 +81,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ($pValue instanceof PHPExcel_RichText) {
- return PHPExcel_Cell_DataType::TYPE_STRING;
+ return PHPExcel_Cell_DataType::TYPE_INLINE;
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA;
diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php b/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php
index dba5e776b0f..9dc13042aa5 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Cell/Hyperlink.php
@@ -2,27 +2,27 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_Hyperlink
{
@@ -41,14 +41,14 @@ class PHPExcel_Cell_Hyperlink
* @var string
*/
private $_url;
-
+
/**
* Tooltip to display on the hyperlink
*
* @var string
*/
- private $_tooltip;
-
+ private $_tooltip;
+
/**
* Create a new PHPExcel_Cell_Hyperlink
*
@@ -62,7 +62,7 @@ class PHPExcel_Cell_Hyperlink
$this->_url = $pUrl;
$this->_tooltip = $pTooltip;
}
-
+
/**
* Get URL
*
@@ -82,7 +82,7 @@ class PHPExcel_Cell_Hyperlink
$this->_url = $value;
return $this;
}
-
+
/**
* Get tooltip
*
@@ -102,7 +102,7 @@ class PHPExcel_Cell_Hyperlink
$this->_tooltip = $value;
return $this;
}
-
+
/**
* Is this hyperlink internal? (to another sheet)
*
@@ -111,12 +111,12 @@ class PHPExcel_Cell_Hyperlink
public function isInternal() {
return strpos($this->_url, 'sheet://') !== false;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_url
diff --git a/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php b/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php
index b175705a501..4070b674c77 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Cell/IValueBinder.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Cell
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Cell_IValueBinder
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart.php b/htdocs/includes/phpexcel/PHPExcel/Chart.php
new file mode 100644
index 00000000000..4fa4cddb2df
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart.php
@@ -0,0 +1,527 @@
+_name = $name;
+ $this->_title = $title;
+ $this->_legend = $legend;
+ $this->_xAxisLabel = $xAxisLabel;
+ $this->_yAxisLabel = $yAxisLabel;
+ $this->_plotArea = $plotArea;
+ $this->_plotVisibleOnly = $plotVisibleOnly;
+ $this->_displayBlanksAs = $displayBlanksAs;
+ }
+
+ /**
+ * Get Name
+ *
+ * @return string
+ */
+ public function getName() {
+ return $this->_name;
+ }
+
+ /**
+ * Get Worksheet
+ *
+ * @return PHPExcel_Worksheet
+ */
+ public function getWorksheet() {
+ return $this->_worksheet;
+ }
+
+ /**
+ * Set Worksheet
+ *
+ * @param PHPExcel_Worksheet $pValue
+ * @throws Exception
+ * @return PHPExcel_Chart
+ */
+ public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
+ $this->_worksheet = $pValue;
+
+ return $this;
+ }
+
+ /**
+ * Get Title
+ *
+ * @return PHPExcel_Chart_Title
+ */
+ public function getTitle() {
+ return $this->_title;
+ }
+
+ /**
+ * Set Title
+ *
+ * @param PHPExcel_Chart_Title $title
+ * @return PHPExcel_Chart
+ */
+ public function setTitle(PHPExcel_Chart_Title $title) {
+ $this->_title = $title;
+
+ return $this;
+ }
+
+ /**
+ * Get Legend
+ *
+ * @return PHPExcel_Chart_Legend
+ */
+ public function getLegend() {
+ return $this->_legend;
+ }
+
+ /**
+ * Set Legend
+ *
+ * @param PHPExcel_Chart_Legend $legend
+ * @return PHPExcel_Chart
+ */
+ public function setLegend(PHPExcel_Chart_Legend $legend) {
+ $this->_legend = $legend;
+
+ return $this;
+ }
+
+ /**
+ * Get X-Axis Label
+ *
+ * @return PHPExcel_Chart_Title
+ */
+ public function getXAxisLabel() {
+ return $this->_xAxisLabel;
+ }
+
+ /**
+ * Set X-Axis Label
+ *
+ * @param PHPExcel_Chart_Title $label
+ * @return PHPExcel_Chart
+ */
+ public function setXAxisLabel(PHPExcel_Chart_Title $label) {
+ $this->_xAxisLabel = $label;
+
+ return $this;
+ }
+
+ /**
+ * Get Y-Axis Label
+ *
+ * @return PHPExcel_Chart_Title
+ */
+ public function getYAxisLabel() {
+ return $this->_yAxisLabel;
+ }
+
+ /**
+ * Set Y-Axis Label
+ *
+ * @param PHPExcel_Chart_Title $label
+ * @return PHPExcel_Chart
+ */
+ public function setYAxisLabel(PHPExcel_Chart_Title $label) {
+ $this->_yAxisLabel = $label;
+
+ return $this;
+ }
+
+ /**
+ * Get Plot Area
+ *
+ * @return PHPExcel_Chart_PlotArea
+ */
+ public function getPlotArea() {
+ return $this->_plotArea;
+ }
+
+ /**
+ * Get Plot Visible Only
+ *
+ * @return boolean
+ */
+ public function getPlotVisibleOnly() {
+ return $this->_plotVisibleOnly;
+ }
+
+ /**
+ * Set Plot Visible Only
+ *
+ * @param boolean $plotVisibleOnly
+ * @return PHPExcel_Chart
+ */
+ public function setPlotVisibleOnly($plotVisibleOnly = true) {
+ $this->_plotVisibleOnly = $plotVisibleOnly;
+
+ return $this;
+ }
+
+ /**
+ * Get Display Blanks as
+ *
+ * @return string
+ */
+ public function getDisplayBlanksAs() {
+ return $this->_displayBlanksAs;
+ }
+
+ /**
+ * Set Display Blanks as
+ *
+ * @param string $displayBlanksAs
+ * @return PHPExcel_Chart
+ */
+ public function setDisplayBlanksAs($displayBlanksAs = '0') {
+ $this->_displayBlanksAs = $displayBlanksAs;
+ }
+
+
+ /**
+ * Set the Top Left position for the chart
+ *
+ * @param string $cell
+ * @param integer $xOffset
+ * @param integer $yOffset
+ * @return PHPExcel_Chart
+ */
+ public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
+ $this->_topLeftCellRef = $cell;
+ if (!is_null($xOffset))
+ $this->setTopLeftXOffset($xOffset);
+ if (!is_null($yOffset))
+ $this->setTopLeftYOffset($yOffset);
+
+ return $this;
+ }
+
+ /**
+ * Get the top left position of the chart
+ *
+ * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
+ */
+ public function getTopLeftPosition() {
+ return array( 'cell' => $this->_topLeftCellRef,
+ 'xOffset' => $this->_topLeftXOffset,
+ 'yOffset' => $this->_topLeftYOffset
+ );
+ }
+
+ /**
+ * Get the cell address where the top left of the chart is fixed
+ *
+ * @return string
+ */
+ public function getTopLeftCell() {
+ return $this->_topLeftCellRef;
+ }
+
+ /**
+ * Set the Top Left cell position for the chart
+ *
+ * @param string $cell
+ * @return PHPExcel_Chart
+ */
+ public function setTopLeftCell($cell) {
+ $this->_topLeftCellRef = $cell;
+
+ return $this;
+ }
+
+ public function setTopLeftOffset($xOffset=null,$yOffset=null) {
+ if (!is_null($xOffset))
+ $this->setTopLeftXOffset($xOffset);
+ if (!is_null($yOffset))
+ $this->setTopLeftYOffset($yOffset);
+
+ return $this;
+ }
+
+ public function getTopLeftOffset() {
+ return array( 'X' => $this->_topLeftXOffset,
+ 'Y' => $this->_topLeftYOffset
+ );
+ }
+
+ public function setTopLeftXOffset($xOffset) {
+ $this->_topLeftXOffset = $xOffset;
+
+ return $this;
+ }
+
+ public function getTopLeftXOffset() {
+ return $this->_topLeftXOffset;
+ }
+
+ public function setTopLeftYOffset($yOffset) {
+ $this->_topLeftYOffset = $yOffset;
+
+ return $this;
+ }
+
+ public function getTopLeftYOffset() {
+ return $this->_topLeftYOffset;
+ }
+
+ /**
+ * Set the Bottom Right position of the chart
+ *
+ * @param string $cell
+ * @param integer $xOffset
+ * @param integer $yOffset
+ * @return PHPExcel_Chart
+ */
+ public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
+ $this->_bottomRightCellRef = $cell;
+ if (!is_null($xOffset))
+ $this->setBottomRightXOffset($xOffset);
+ if (!is_null($yOffset))
+ $this->setBottomRightYOffset($yOffset);
+
+ return $this;
+ }
+
+ /**
+ * Get the bottom right position of the chart
+ *
+ * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
+ */
+ public function getBottomRightPosition() {
+ return array( 'cell' => $this->_bottomRightCellRef,
+ 'xOffset' => $this->_bottomRightXOffset,
+ 'yOffset' => $this->_bottomRightYOffset
+ );
+ }
+
+ public function setBottomRightCell($cell) {
+ $this->_bottomRightCellRef = $cell;
+
+ return $this;
+ }
+
+ /**
+ * Get the cell address where the bottom right of the chart is fixed
+ *
+ * @return string
+ */
+ public function getBottomRightCell() {
+ return $this->_bottomRightCellRef;
+ }
+
+ public function setBottomRightOffset($xOffset=null,$yOffset=null) {
+ if (!is_null($xOffset))
+ $this->setBottomRightXOffset($xOffset);
+ if (!is_null($yOffset))
+ $this->setBottomRightYOffset($yOffset);
+
+ return $this;
+ }
+
+ public function getBottomRightOffset() {
+ return array( 'X' => $this->_bottomRightXOffset,
+ 'Y' => $this->_bottomRightYOffset
+ );
+ }
+
+ public function setBottomRightXOffset($xOffset) {
+ $this->_bottomRightXOffset = $xOffset;
+
+ return $this;
+ }
+
+ public function getBottomRightXOffset() {
+ return $this->_bottomRightXOffset;
+ }
+
+ public function setBottomRightYOffset($yOffset) {
+ $this->_bottomRightYOffset = $yOffset;
+
+ return $this;
+ }
+
+ public function getBottomRightYOffset() {
+ return $this->_bottomRightYOffset;
+ }
+
+
+ public function refresh() {
+ if ($this->_worksheet !== NULL) {
+ $this->_plotArea->refresh($this->_worksheet);
+ }
+ }
+
+ public function render($outputDestination = null) {
+ $libraryName = PHPExcel_Settings::getChartRendererName();
+ if (is_null($libraryName)) {
+ return false;
+ }
+ // Ensure that data series values are up-to-date before we render
+ $this->refresh();
+
+ $libraryPath = PHPExcel_Settings::getChartRendererPath();
+ $includePath = str_replace('\\','/',get_include_path());
+ $rendererPath = str_replace('\\','/',$libraryPath);
+ if (strpos($rendererPath,$includePath) === false) {
+ set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
+ }
+
+ $rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName;
+ $renderer = new $rendererName($this);
+
+ if ($outputDestination == 'php://output') {
+ $outputDestination = null;
+ }
+ return $renderer->render($outputDestination);
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeries.php b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeries.php
new file mode 100644
index 00000000000..16e5e23194f
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeries.php
@@ -0,0 +1,354 @@
+_plotType = $plotType;
+ $this->_plotGrouping = $plotGrouping;
+ $this->_plotOrder = $plotOrder;
+ $keys = array_keys($plotValues);
+ $this->_plotValues = $plotValues;
+ if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
+ $plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
+ }
+
+ $this->_plotLabel = $plotLabel;
+ if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
+ $plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
+ }
+ $this->_plotCategory = $plotCategory;
+ $this->_smoothLine = $smoothLine;
+ $this->_plotStyle = $plotStyle;
+ }
+
+ /**
+ * Get Plot Type
+ *
+ * @return string
+ */
+ public function getPlotType() {
+ return $this->_plotType;
+ }
+
+ /**
+ * Set Plot Type
+ *
+ * @param string $plotType
+ */
+ public function setPlotType($plotType = '') {
+ $this->_plotType = $plotType;
+ }
+
+ /**
+ * Get Plot Grouping Type
+ *
+ * @return string
+ */
+ public function getPlotGrouping() {
+ return $this->_plotGrouping;
+ }
+
+ /**
+ * Set Plot Grouping Type
+ *
+ * @param string $groupingType
+ */
+ public function setPlotGrouping($groupingType = null) {
+ $this->_plotGrouping = $groupingType;
+ }
+
+ /**
+ * Get Plot Direction
+ *
+ * @return string
+ */
+ public function getPlotDirection() {
+ return $this->_plotDirection;
+ }
+
+ /**
+ * Set Plot Direction
+ *
+ * @param string $plotDirection
+ */
+ public function setPlotDirection($plotDirection = null) {
+ $this->_plotDirection = $plotDirection;
+ }
+
+ /**
+ * Get Plot Order
+ *
+ * @return string
+ */
+ public function getPlotOrder() {
+ return $this->_plotOrder;
+ }
+
+ /**
+ * Get Plot Labels
+ *
+ * @return array of PHPExcel_Chart_DataSeriesValues
+ */
+ public function getPlotLabels() {
+ return $this->_plotLabel;
+ }
+
+ /**
+ * Get Plot Label by Index
+ *
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function getPlotLabelByIndex($index) {
+ $keys = array_keys($this->_plotLabel);
+ if (in_array($index,$keys)) {
+ return $this->_plotLabel[$index];
+ } elseif(isset($keys[$index])) {
+ return $this->_plotLabel[$keys[$index]];
+ }
+ return false;
+ }
+
+ /**
+ * Get Plot Categories
+ *
+ * @return array of PHPExcel_Chart_DataSeriesValues
+ */
+ public function getPlotCategories() {
+ return $this->_plotCategory;
+ }
+
+ /**
+ * Get Plot Category by Index
+ *
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function getPlotCategoryByIndex($index) {
+ $keys = array_keys($this->_plotCategory);
+ if (in_array($index,$keys)) {
+ return $this->_plotCategory[$index];
+ } elseif(isset($keys[$index])) {
+ return $this->_plotCategory[$keys[$index]];
+ }
+ return false;
+ }
+
+ /**
+ * Get Plot Style
+ *
+ * @return string
+ */
+ public function getPlotStyle() {
+ return $this->_plotStyle;
+ }
+
+ /**
+ * Set Plot Style
+ *
+ * @param string $plotStyle
+ */
+ public function setPlotStyle($plotStyle = null) {
+ $this->_plotStyle = $plotStyle;
+ }
+
+ /**
+ * Get Plot Values
+ *
+ * @return array of PHPExcel_Chart_DataSeriesValues
+ */
+ public function getPlotValues() {
+ return $this->_plotValues;
+ }
+
+ /**
+ * Get Plot Values by Index
+ *
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function getPlotValuesByIndex($index) {
+ $keys = array_keys($this->_plotValues);
+ if (in_array($index,$keys)) {
+ return $this->_plotValues[$index];
+ } elseif(isset($keys[$index])) {
+ return $this->_plotValues[$keys[$index]];
+ }
+ return false;
+ }
+
+ /**
+ * Get Number of Plot Series
+ *
+ * @return integer
+ */
+ public function getPlotSeriesCount() {
+ return count($this->_plotValues);
+ }
+
+ /**
+ * Get Smooth Line
+ *
+ * @return boolean
+ */
+ public function getSmoothLine() {
+ return $this->_smoothLine;
+ }
+
+ /**
+ * Set Smooth Line
+ *
+ * @param boolean $smoothLine
+ */
+ public function setSmoothLine($smoothLine = TRUE) {
+ $this->_smoothLine = $smoothLine;
+ }
+
+ public function refresh(PHPExcel_Worksheet $worksheet) {
+ foreach($this->_plotValues as $plotValues) {
+ if ($plotValues !== NULL)
+ $plotValues->refresh($worksheet, TRUE);
+ }
+ foreach($this->_plotLabel as $plotValues) {
+ if ($plotValues !== NULL)
+ $plotValues->refresh($worksheet, TRUE);
+ }
+ foreach($this->_plotCategory as $plotValues) {
+ if ($plotValues !== NULL)
+ $plotValues->refresh($worksheet, FALSE);
+ }
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeriesValues.php b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeriesValues.php
new file mode 100644
index 00000000000..e49d0c79a84
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/DataSeriesValues.php
@@ -0,0 +1,321 @@
+setDataType($dataType);
+ $this->_dataSource = $dataSource;
+ $this->_formatCode = $formatCode;
+ $this->_pointCount = $pointCount;
+ $this->_dataValues = $dataValues;
+ $this->_marker = $marker;
+ }
+
+ /**
+ * Get Series Data Type
+ *
+ * @return string
+ */
+ public function getDataType() {
+ return $this->_dataType;
+ }
+
+ /**
+ * Set Series Data Type
+ *
+ * @param string $dataType Datatype of this data series
+ * Typical values are:
+ * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
+ * Normally used for axis point values
+ * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
+ * Normally used for chart data values
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
+ if (!in_array($dataType, self::$_dataTypeValues)) {
+ throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
+ }
+ $this->_dataType = $dataType;
+
+ return $this;
+ }
+
+ /**
+ * Get Series Data Source (formula)
+ *
+ * @return string
+ */
+ public function getDataSource() {
+ return $this->_dataSource;
+ }
+
+ /**
+ * Set Series Data Source (formula)
+ *
+ * @param string $dataSource
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function setDataSource($dataSource = null, $refreshDataValues = true) {
+ $this->_dataSource = $dataSource;
+
+ if ($refreshDataValues) {
+ // TO DO
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get Point Marker
+ *
+ * @return string
+ */
+ public function getPointMarker() {
+ return $this->_marker;
+ }
+
+ /**
+ * Set Point Marker
+ *
+ * @param string $marker
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function setPointMarker($marker = null) {
+ $this->_marker = $marker;
+
+ return $this;
+ }
+
+ /**
+ * Get Series Format Code
+ *
+ * @return string
+ */
+ public function getFormatCode() {
+ return $this->_formatCode;
+ }
+
+ /**
+ * Set Series Format Code
+ *
+ * @param string $formatCode
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function setFormatCode($formatCode = null) {
+ $this->_formatCode = $formatCode;
+
+ return $this;
+ }
+
+ /**
+ * Get Series Point Count
+ *
+ * @return integer
+ */
+ public function getPointCount() {
+ return $this->_pointCount;
+ }
+
+ /**
+ * Identify if the Data Series is a multi-level or a simple series
+ *
+ * @return boolean
+ */
+ public function isMultiLevelSeries() {
+ if (count($this->_dataValues) > 0) {
+ return is_array($this->_dataValues[0]);
+ }
+ return null;
+ }
+
+ /**
+ * Return the level count of a multi-level Data Series
+ *
+ * @return boolean
+ */
+ public function multiLevelCount() {
+ $levelCount = 0;
+ foreach($this->_dataValues as $dataValueSet) {
+ $levelCount = max($levelCount,count($dataValueSet));
+ }
+ return $levelCount;
+ }
+
+ /**
+ * Get Series Data Values
+ *
+ * @return array of mixed
+ */
+ public function getDataValues() {
+ return $this->_dataValues;
+ }
+
+ /**
+ * Get the first Series Data value
+ *
+ * @return mixed
+ */
+ public function getDataValue() {
+ $count = count($this->_dataValues);
+ if ($count == 0) {
+ return null;
+ } elseif ($count == 1) {
+ return $this->_dataValues[0];
+ }
+ return $this->_dataValues;
+ }
+
+ /**
+ * Set Series Data Values
+ *
+ * @param array $dataValues
+ * @param boolean $refreshDataSource
+ * TRUE - refresh the value of _dataSource based on the values of $dataValues
+ * FALSE - don't change the value of _dataSource
+ * @return PHPExcel_Chart_DataSeriesValues
+ */
+ public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
+ $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
+ $this->_pointCount = count($dataValues);
+
+ if ($refreshDataSource) {
+ // TO DO
+ }
+
+ return $this;
+ }
+
+ private function _stripNulls($var) {
+ return $var !== NULL;
+ }
+
+ public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
+ if ($this->_dataSource !== NULL) {
+ $calcEngine = PHPExcel_Calculation::getInstance();
+ $newDataValues = PHPExcel_Calculation::_unwrapResult(
+ $calcEngine->_calculateFormulaValue(
+ '='.$this->_dataSource,
+ NULL,
+ $worksheet->getCell('A1')
+ )
+ );
+ if ($flatten) {
+ $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
+ } else {
+ $cellRange = explode('!',$this->_dataSource);
+ if (count($cellRange) > 1) {
+ list(,$cellRange) = $cellRange;
+ }
+
+ $dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
+ if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
+ $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
+ } else {
+ $newArray = array_values(array_shift($newDataValues));
+ foreach($newArray as $i => $newDataSet) {
+ $newArray[$i] = array($newDataSet);
+ }
+
+ foreach($newDataValues as $newDataSet) {
+ $i = 0;
+ foreach($newDataSet as $newDataVal) {
+ array_unshift($newArray[$i++],$newDataVal);
+ }
+ }
+ $this->_dataValues = $newArray;
+ }
+ }
+ $this->_pointCount = count($this->_dataValues);
+ }
+
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Exception.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Exception.php
new file mode 100644
index 00000000000..984d5f91ddb
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Exception.php
@@ -0,0 +1,52 @@
+line = $line;
+ $e->file = $file;
+ throw $e;
+ }
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Layout.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Layout.php
new file mode 100644
index 00000000000..d128382c16f
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Layout.php
@@ -0,0 +1,417 @@
+_layoutTarget = $layout['layoutTarget']; }
+ if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; }
+ if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; }
+ if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; }
+ if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; }
+ if (isset($layout['w'])) { $this->_width = (float) $layout['w']; }
+ if (isset($layout['h'])) { $this->_height = (float) $layout['h']; }
+ }
+
+ /**
+ * Get Layout Target
+ *
+ * @return string
+ */
+ public function getLayoutTarget() {
+ return $this->_layoutTarget;
+ }
+
+ /**
+ * Set Layout Target
+ *
+ * @param Layout Target $value
+ */
+ public function setLayoutTarget($value) {
+ $this->_layoutTarget = $value;
+ }
+
+ /**
+ * Get X-Mode
+ *
+ * @return string
+ */
+ public function getXMode() {
+ return $this->_xMode;
+ }
+
+ /**
+ * Set X-Mode
+ *
+ * @param X-Mode $value
+ */
+ public function setXMode($value) {
+ $this->_xMode = $value;
+ }
+
+ /**
+ * Get Y-Mode
+ *
+ * @return string
+ */
+ public function getYMode() {
+ return $this->_xMode;
+ }
+
+ /**
+ * Set Y-Mode
+ *
+ * @param Y-Mode $value
+ */
+ public function setYMode($value) {
+ $this->_xMode = $value;
+ }
+
+ /**
+ * Get X-Position
+ *
+ * @return number
+ */
+ public function getXPosition() {
+ return $this->_xPos;
+ }
+
+ /**
+ * Set X-Position
+ *
+ * @param X-Position $value
+ */
+ public function setXPosition($value) {
+ $this->_xPos = $value;
+ }
+
+ /**
+ * Get Y-Position
+ *
+ * @return number
+ */
+ public function getYPosition() {
+ return $this->_yPos;
+ }
+
+ /**
+ * Set Y-Position
+ *
+ * @param Y-Position $value
+ */
+ public function setYPosition($value) {
+ $this->_yPos = $value;
+ }
+
+ /**
+ * Get Width
+ *
+ * @return number
+ */
+ public function getWidth() {
+ return $this->_width;
+ }
+
+ /**
+ * Set Width
+ *
+ * @param Width $value
+ */
+ public function setWidth($value) {
+ $this->_width = $value;
+ }
+
+ /**
+ * Get Height
+ *
+ * @return number
+ */
+ public function getHeight() {
+ return $this->_height;
+ }
+
+ /**
+ * Set Height
+ *
+ * @param Height $value
+ */
+ public function setHeight($value) {
+ $this->_height = $value;
+ }
+
+
+ /**
+ * Get show legend key
+ *
+ * @return boolean
+ */
+ public function getShowLegendKey() {
+ return $this->_showLegendKey;
+ }
+
+ /**
+ * Set show legend key
+ * Specifies that legend keys should be shown in data labels.
+ *
+ * @param boolean $value Show legend key
+ */
+ public function setShowLegendKey($value) {
+ $this->_showLegendKey = $value;
+ }
+
+ /**
+ * Get show value
+ *
+ * @return boolean
+ */
+ public function getShowVal() {
+ return $this->_showVal;
+ }
+
+ /**
+ * Set show val
+ * Specifies that the value should be shown in data labels.
+ *
+ * @param boolean $value Show val
+ */
+ public function setShowVal($value) {
+ $this->_showVal = $value;
+ }
+
+ /**
+ * Get show category name
+ *
+ * @return boolean
+ */
+ public function getShowCatName() {
+ return $this->_showCatName;
+ }
+
+ /**
+ * Set show cat name
+ * Specifies that the category name should be shown in data labels.
+ *
+ * @param boolean $value Show cat name
+ */
+ public function setShowCatName($value) {
+ $this->_showCatName = $value;
+ }
+
+ /**
+ * Get show data series name
+ *
+ * @return boolean
+ */
+ public function getShowSerName() {
+ return $this->_showSerName;
+ }
+
+ /**
+ * Set show ser name
+ * Specifies that the series name should be shown in data labels.
+ *
+ * @param boolean $value Show ser name
+ */
+ public function setShowSerName($value) {
+ $this->_showSerName = $value;
+ }
+
+ /**
+ * Get show percentage
+ *
+ * @return boolean
+ */
+ public function getShowPercent() {
+ return $this->_showPercent;
+ }
+
+ /**
+ * Set show percentage
+ * Specifies that the percentage should be shown in data labels.
+ *
+ * @param boolean $value Show percentage
+ */
+ public function setShowPercent($value) {
+ $this->_showPercent = $value;
+ }
+
+ /**
+ * Get show bubble size
+ *
+ * @return boolean
+ */
+ public function getShowBubbleSize() {
+ return $this->_showBubbleSize;
+ }
+
+ /**
+ * Set show bubble size
+ * Specifies that the bubble size should be shown in data labels.
+ *
+ * @param boolean $value Show bubble size
+ */
+ public function setShowBubbleSize($value) {
+ $this->_showBubbleSize = $value;
+ }
+
+ /**
+ * Get show leader lines
+ *
+ * @return boolean
+ */
+ public function getShowLeaderLines() {
+ return $this->_showLeaderLines;
+ }
+
+ /**
+ * Set show leader lines
+ * Specifies that leader lines should be shown in data labels.
+ *
+ * @param boolean $value Show leader lines
+ */
+ public function setShowLeaderLines($value) {
+ $this->_showLeaderLines = $value;
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Legend.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Legend.php
new file mode 100644
index 00000000000..0ccd77e958d
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Legend.php
@@ -0,0 +1,171 @@
+ self::POSITION_BOTTOM,
+ self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
+ self::xlLegendPositionCustom => '??',
+ self::xlLegendPositionLeft => self::POSITION_LEFT,
+ self::xlLegendPositionRight => self::POSITION_RIGHT,
+ self::xlLegendPositionTop => self::POSITION_TOP
+ );
+
+ /**
+ * Legend position
+ *
+ * @var string
+ */
+ private $_position = self::POSITION_RIGHT;
+
+ /**
+ * Allow overlay of other elements?
+ *
+ * @var boolean
+ */
+ private $_overlay = TRUE;
+
+ /**
+ * Legend Layout
+ *
+ * @var PHPExcel_Chart_Layout
+ */
+ private $_layout = NULL;
+
+
+ /**
+ * Create a new PHPExcel_Chart_Legend
+ */
+ public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE)
+ {
+ $this->setPosition($position);
+ $this->_layout = $layout;
+ $this->setOverlay($overlay);
+ }
+
+ /**
+ * Get legend position as an excel string value
+ *
+ * @return string
+ */
+ public function getPosition() {
+ return $this->_position;
+ }
+
+ /**
+ * Get legend position using an excel string value
+ *
+ * @param string $position
+ */
+ public function setPosition($position = self::POSITION_RIGHT) {
+ if (!in_array($position,self::$_positionXLref)) {
+ return false;
+ }
+
+ $this->_position = $position;
+ return true;
+ }
+
+ /**
+ * Get legend position as an Excel internal numeric value
+ *
+ * @return number
+ */
+ public function getPositionXL() {
+ return array_search($this->_position,self::$_positionXLref);
+ }
+
+ /**
+ * Set legend position using an Excel internal numeric value
+ *
+ * @param number $positionXL
+ */
+ public function setPositionXL($positionXL = self::xlLegendPositionRight) {
+ if (!array_key_exists($positionXL,self::$_positionXLref)) {
+ return false;
+ }
+
+ $this->_position = self::$_positionXLref[$positionXL];
+ return true;
+ }
+
+ /**
+ * Get allow overlay of other elements?
+ *
+ * @return boolean
+ */
+ public function getOverlay() {
+ return $this->_overlay;
+ }
+
+ /**
+ * Set allow overlay of other elements?
+ *
+ * @param boolean $overlay
+ * @return boolean
+ */
+ public function setOverlay($overlay = FALSE) {
+ if (!is_bool($overlay)) {
+ return false;
+ }
+
+ $this->_overlay = $overlay;
+ return true;
+ }
+
+ /**
+ * Get Layout
+ *
+ * @return PHPExcel_Chart_Layout
+ */
+ public function getLayout() {
+ return $this->_layout;
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/PlotArea.php b/htdocs/includes/phpexcel/PHPExcel/Chart/PlotArea.php
new file mode 100644
index 00000000000..134ee59550a
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/PlotArea.php
@@ -0,0 +1,125 @@
+_layout = $layout;
+ $this->_plotSeries = $plotSeries;
+ }
+
+ /**
+ * Get Layout
+ *
+ * @return PHPExcel_Chart_Layout
+ */
+ public function getLayout() {
+ return $this->_layout;
+ }
+
+ /**
+ * Get Number of Plot Groups
+ *
+ * @return array of PHPExcel_Chart_DataSeries
+ */
+ public function getPlotGroupCount() {
+ return count($this->_plotSeries);
+ }
+
+ /**
+ * Get Number of Plot Series
+ *
+ * @return integer
+ */
+ public function getPlotSeriesCount() {
+ $seriesCount = 0;
+ foreach($this->_plotSeries as $plot) {
+ $seriesCount += $plot->getPlotSeriesCount();
+ }
+ return $seriesCount;
+ }
+
+ /**
+ * Get Plot Series
+ *
+ * @return array of PHPExcel_Chart_DataSeries
+ */
+ public function getPlotGroup() {
+ return $this->_plotSeries;
+ }
+
+ /**
+ * Get Plot Series by Index
+ *
+ * @return PHPExcel_Chart_DataSeries
+ */
+ public function getPlotGroupByIndex($index) {
+ return $this->_plotSeries[$index];
+ }
+
+ /**
+ * Set Plot Series
+ *
+ * @param array of PHPExcel_Chart_DataSeries
+ */
+ public function setPlotSeries($plotSeries = array()) {
+ $this->_plotSeries = $plotSeries;
+ }
+
+ public function refresh(PHPExcel_Worksheet $worksheet) {
+ foreach($this->_plotSeries as $plotSeries) {
+ $plotSeries->refresh($worksheet);
+ }
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/PHP Charting Libraries.txt b/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/PHP Charting Libraries.txt
new file mode 100644
index 00000000000..faaa61d153b
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/PHP Charting Libraries.txt
@@ -0,0 +1,17 @@
+ChartDirector
+ http://www.advsofteng.com/cdphp.html
+
+GraPHPite
+ http://graphpite.sourceforge.net/
+
+JpGraph
+ http://www.aditus.nu/jpgraph/
+
+LibChart
+ http://naku.dohcrew.com/libchart/pages/introduction/
+
+pChart
+ http://pchart.sourceforge.net/
+
+TeeChart
+ http://www.steema.com/products/teechart/overview.html
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/jpgraph.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/jpgraph.php
new file mode 100644
index 00000000000..889fd9fce08
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Renderer/jpgraph.php
@@ -0,0 +1,839 @@
+ MARK_DIAMOND,
+ 'square' => MARK_SQUARE,
+ 'triangle' => MARK_UTRIANGLE,
+ 'x' => MARK_X,
+ 'star' => MARK_STAR,
+ 'dot' => MARK_FILLEDCIRCLE,
+ 'dash' => MARK_DTRIANGLE,
+ 'circle' => MARK_CIRCLE,
+ 'plus' => MARK_CROSS
+ );
+
+
+ private $_chart = null;
+
+ private $_graph = null;
+
+ private static $_plotColour = 0;
+
+ private static $_plotMark = 0;
+
+
+ private function _formatPointMarker($seriesPlot,$markerID) {
+ $plotMarkKeys = array_keys(self::$_markSet);
+ if (is_null($markerID)) {
+ // Use default plot marker (next marker in the series)
+ self::$_plotMark %= count(self::$_markSet);
+ $seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]);
+ } elseif ($markerID !== 'none') {
+ // Use specified plot marker (if it exists)
+ if (isset(self::$_markSet[$markerID])) {
+ $seriesPlot->mark->SetType(self::$_markSet[$markerID]);
+ } else {
+ // If the specified plot marker doesn't exist, use default plot marker (next marker in the series)
+ self::$_plotMark %= count(self::$_markSet);
+ $seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]);
+ }
+ } else {
+ // Hide plot marker
+ $seriesPlot->mark->Hide();
+ }
+ $seriesPlot->mark->SetColor(self::$_colourSet[self::$_plotColour]);
+ $seriesPlot->mark->SetFillColor(self::$_colourSet[self::$_plotColour]);
+ $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
+
+ return $seriesPlot;
+ } // function _formatPointMarker()
+
+
+ private function _formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '') {
+ $datasetLabelFormatCode = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
+ if (!is_null($datasetLabelFormatCode)) {
+ // Retrieve any label formatting code
+ $datasetLabelFormatCode = stripslashes($datasetLabelFormatCode);
+ }
+
+ $testCurrentIndex = 0;
+ foreach($datasetLabels as $i => $datasetLabel) {
+ array_reverse($datasetLabel);
+
+ if (is_array($datasetLabel)) {
+ if ($rotation == 'bar') {
+ $datasetLabel = array_reverse($datasetLabel);
+ $datasetLabels[$i] = implode(" ",$datasetLabel);
+ } else {
+ $datasetLabels[$i] = implode("\n",$datasetLabel);
+ }
+ } else {
+ // Format labels according to any formatting code
+ if (!is_null($datasetLabelFormatCode)) {
+ $datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode);
+ }
+ }
+ ++$testCurrentIndex;
+ }
+
+ return $datasetLabels;
+ } // function _formatDataSetLabels()
+
+
+ private function _percentageSumCalculation($groupID,$seriesCount) {
+ // Adjust our values to a percentage value across all series in the group
+ for($i = 0; $i < $seriesCount; ++$i) {
+ if ($i == 0) {
+ $sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
+ } else {
+ $nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
+ foreach($nextValues as $k => $value) {
+ if (isset($sumValues[$k])) {
+ $sumValues[$k] += $value;
+ } else {
+ $sumValues[$k] = $value;
+ }
+ }
+ }
+ }
+
+ return $sumValues;
+ } // function _percentageSumCalculation()
+
+
+ private function _percentageAdjustValues($dataValues,$sumValues) {
+ foreach($dataValues as $k => $dataValue) {
+ $dataValues[$k] = $dataValue / $sumValues[$k] * 100;
+ }
+
+ return $dataValues;
+ } // function _percentageAdjustValues()
+
+
+ private function _getCaption($captionElement) {
+ // Read any caption
+ $caption = (!is_null($captionElement)) ? $captionElement->getCaption() : NULL;
+ // Test if we have a title caption to display
+ if (!is_null($caption)) {
+ // If we do, it could be a plain string or an array
+ if (is_array($caption)) {
+ // Implode an array to a plain string
+ $caption = implode('',$caption);
+ }
+ }
+ return $caption;
+ } // function _getCaption()
+
+
+ private function _renderTitle() {
+ $title = $this->_getCaption($this->_chart->getTitle());
+ if (!is_null($title)) {
+ $this->_graph->title->Set($title);
+ }
+ } // function _renderTitle()
+
+
+ private function _renderLegend() {
+ $legend = $this->_chart->getLegend();
+ if (!is_null($legend)) {
+ $legendPosition = $legend->getPosition();
+ $legendOverlay = $legend->getOverlay();
+ switch ($legendPosition) {
+ case 'r' :
+ $this->_graph->legend->SetPos(0.01,0.5,'right','center'); // right
+ $this->_graph->legend->SetColumns(1);
+ break;
+ case 'l' :
+ $this->_graph->legend->SetPos(0.01,0.5,'left','center'); // left
+ $this->_graph->legend->SetColumns(1);
+ break;
+ case 't' :
+ $this->_graph->legend->SetPos(0.5,0.01,'center','top'); // top
+ break;
+ case 'b' :
+ $this->_graph->legend->SetPos(0.5,0.99,'center','bottom'); // bottom
+ break;
+ default :
+ $this->_graph->legend->SetPos(0.01,0.01,'right','top'); // top-right
+ $this->_graph->legend->SetColumns(1);
+ break;
+ }
+ } else {
+ $this->_graph->legend->Hide();
+ }
+ } // function _renderLegend()
+
+
+ private function _renderCartesianPlotArea($type='textlin') {
+ $this->_graph = new Graph(self::$_width,self::$_height);
+ $this->_graph->SetScale($type);
+
+ $this->_renderTitle();
+
+ // Rotate for bar rather than column chart
+ $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection();
+ $reverse = ($rotation == 'bar') ? true : false;
+
+ $xAxisLabel = $this->_chart->getXAxisLabel();
+ if (!is_null($xAxisLabel)) {
+ $title = $this->_getCaption($xAxisLabel);
+ if (!is_null($title)) {
+ $this->_graph->xaxis->SetTitle($title,'center');
+ $this->_graph->xaxis->title->SetMargin(35);
+ if ($reverse) {
+ $this->_graph->xaxis->title->SetAngle(90);
+ $this->_graph->xaxis->title->SetMargin(90);
+ }
+ }
+ }
+
+ $yAxisLabel = $this->_chart->getYAxisLabel();
+ if (!is_null($yAxisLabel)) {
+ $title = $this->_getCaption($yAxisLabel);
+ if (!is_null($title)) {
+ $this->_graph->yaxis->SetTitle($title,'center');
+ if ($reverse) {
+ $this->_graph->yaxis->title->SetAngle(0);
+ $this->_graph->yaxis->title->SetMargin(-55);
+ }
+ }
+ }
+ } // function _renderCartesianPlotArea()
+
+
+ private function _renderPiePlotArea($doughnut = False) {
+ $this->_graph = new PieGraph(self::$_width,self::$_height);
+
+ $this->_renderTitle();
+ } // function _renderPiePlotArea()
+
+
+ private function _renderRadarPlotArea() {
+ $this->_graph = new RadarGraph(self::$_width,self::$_height);
+ $this->_graph->SetScale('lin');
+
+ $this->_renderTitle();
+ } // function _renderRadarPlotArea()
+
+
+ private function _renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') {
+ $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
+
+ $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
+ if ($labelCount > 0) {
+ $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
+ $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount);
+ $this->_graph->xaxis->SetTickLabels($datasetLabels);
+ }
+
+ $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
+ $seriesPlots = array();
+ if ($grouping == 'percentStacked') {
+ $sumValues = $this->_percentageSumCalculation($groupID,$seriesCount);
+ }
+
+ // Loop through each data series in turn
+ for($i = 0; $i < $seriesCount; ++$i) {
+ $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
+ $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
+
+ if ($grouping == 'percentStacked') {
+ $dataValues = $this->_percentageAdjustValues($dataValues,$sumValues);
+ }
+
+ // Fill in any missing values in the $dataValues array
+ $testCurrentIndex = 0;
+ foreach($dataValues as $k => $dataValue) {
+ while($k != $testCurrentIndex) {
+ $dataValues[$testCurrentIndex] = null;
+ ++$testCurrentIndex;
+ }
+ ++$testCurrentIndex;
+ }
+
+ $seriesPlot = new LinePlot($dataValues);
+ if ($combination) {
+ $seriesPlot->SetBarCenter();
+ }
+
+ if ($filled) {
+ $seriesPlot->SetFilled(true);
+ $seriesPlot->SetColor('black');
+ $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
+ } else {
+ // Set the appropriate plot marker
+ $this->_formatPointMarker($seriesPlot,$marker);
+ }
+ $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
+ $seriesPlot->SetLegend($dataLabel);
+
+ $seriesPlots[] = $seriesPlot;
+ }
+
+ if ($grouping == 'standard') {
+ $groupPlot = $seriesPlots;
+ } else {
+ $groupPlot = new AccLinePlot($seriesPlots);
+ }
+ $this->_graph->Add($groupPlot);
+ } // function _renderPlotLine()
+
+
+ private function _renderPlotBar($groupID, $dimensions = '2d') {
+ $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
+ // Rotate for bar rather than column chart
+ if (($groupID == 0) && ($rotation == 'bar')) {
+ $this->_graph->Set90AndMargin();
+ }
+ $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
+
+ $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
+ if ($labelCount > 0) {
+ $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
+ $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation);
+ // Rotate for bar rather than column chart
+ if ($rotation == 'bar') {
+ $datasetLabels = array_reverse($datasetLabels);
+ $this->_graph->yaxis->SetPos('max');
+ $this->_graph->yaxis->SetLabelAlign('center','top');
+ $this->_graph->yaxis->SetLabelSide(SIDE_RIGHT);
+ }
+ $this->_graph->xaxis->SetTickLabels($datasetLabels);
+ }
+
+
+ $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
+ $seriesPlots = array();
+ if ($grouping == 'percentStacked') {
+ $sumValues = $this->_percentageSumCalculation($groupID,$seriesCount);
+ }
+
+ // Loop through each data series in turn
+ for($j = 0; $j < $seriesCount; ++$j) {
+ $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
+ if ($grouping == 'percentStacked') {
+ $dataValues = $this->_percentageAdjustValues($dataValues,$sumValues);
+ }
+
+ // Fill in any missing values in the $dataValues array
+ $testCurrentIndex = 0;
+ foreach($dataValues as $k => $dataValue) {
+ while($k != $testCurrentIndex) {
+ $dataValues[$testCurrentIndex] = null;
+ ++$testCurrentIndex;
+ }
+ ++$testCurrentIndex;
+ }
+
+ // Reverse the $dataValues order for bar rather than column chart
+ if ($rotation == 'bar') {
+ $dataValues = array_reverse($dataValues);
+ }
+ $seriesPlot = new BarPlot($dataValues);
+ $seriesPlot->SetColor('black');
+ $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
+ if ($dimensions == '3d') {
+ $seriesPlot->SetShadow();
+ }
+ if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) {
+ $dataLabel = '';
+ } else {
+ $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue();
+ }
+ $seriesPlot->SetLegend($dataLabel);
+
+ $seriesPlots[] = $seriesPlot;
+ }
+ // Reverse the plot order for bar rather than column chart
+ if (($rotation == 'bar') && (!($grouping == 'percentStacked'))) {
+ $seriesPlots = array_reverse($seriesPlots);
+ }
+
+ if ($grouping == 'clustered') {
+ $groupPlot = new GroupBarPlot($seriesPlots);
+ } elseif ($grouping == 'standard') {
+ $groupPlot = new GroupBarPlot($seriesPlots);
+ } else {
+ $groupPlot = new AccBarPlot($seriesPlots);
+ if ($dimensions == '3d') {
+ $groupPlot->SetShadow();
+ }
+ }
+
+ $this->_graph->Add($groupPlot);
+ } // function _renderPlotBar()
+
+
+ private function _renderPlotScatter($groupID,$bubble) {
+ $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
+ $scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
+
+ $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
+ $seriesPlots = array();
+
+ // Loop through each data series in turn
+ for($i = 0; $i < $seriesCount; ++$i) {
+ $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
+ $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
+
+ foreach($dataValuesY as $k => $dataValueY) {
+ $dataValuesY[$k] = $k;
+ }
+
+ $seriesPlot = new ScatterPlot($dataValuesX,$dataValuesY);
+ if ($scatterStyle == 'lineMarker') {
+ $seriesPlot->SetLinkPoints();
+ $seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]);
+ } elseif ($scatterStyle == 'smoothMarker') {
+ $spline = new Spline($dataValuesY,$dataValuesX);
+ list($splineDataY,$splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20);
+ $lplot = new LinePlot($splineDataX,$splineDataY);
+ $lplot->SetColor(self::$_colourSet[self::$_plotColour]);
+
+ $this->_graph->Add($lplot);
+ }
+
+ if ($bubble) {
+ $this->_formatPointMarker($seriesPlot,'dot');
+ $seriesPlot->mark->SetColor('black');
+ $seriesPlot->mark->SetSize($bubbleSize);
+ } else {
+ $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
+ $this->_formatPointMarker($seriesPlot,$marker);
+ }
+ $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
+ $seriesPlot->SetLegend($dataLabel);
+
+ $this->_graph->Add($seriesPlot);
+ }
+ } // function _renderPlotScatter()
+
+
+ private function _renderPlotRadar($groupID) {
+ $radarStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
+
+ $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
+ $seriesPlots = array();
+
+ // Loop through each data series in turn
+ for($i = 0; $i < $seriesCount; ++$i) {
+ $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
+ $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
+ $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
+
+ $dataValues = array();
+ foreach($dataValuesY as $k => $dataValueY) {
+ $dataValues[$k] = implode(' ',array_reverse($dataValueY));
+ }
+ $tmp = array_shift($dataValues);
+ $dataValues[] = $tmp;
+ $tmp = array_shift($dataValuesX);
+ $dataValuesX[] = $tmp;
+
+ $this->_graph->SetTitles(array_reverse($dataValues));
+
+ $seriesPlot = new RadarPlot(array_reverse($dataValuesX));
+
+ $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
+ $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
+ if ($radarStyle == 'filled') {
+ $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]);
+ }
+ $this->_formatPointMarker($seriesPlot,$marker);
+ $seriesPlot->SetLegend($dataLabel);
+
+ $this->_graph->Add($seriesPlot);
+ }
+ } // function _renderPlotRadar()
+
+
+ private function _renderPlotContour($groupID) {
+ $contourStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
+
+ $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
+ $seriesPlots = array();
+
+ $dataValues = array();
+ // Loop through each data series in turn
+ for($i = 0; $i < $seriesCount; ++$i) {
+ $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
+ $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
+
+ $dataValues[$i] = $dataValuesX;
+ }
+ $seriesPlot = new ContourPlot($dataValues);
+
+ $this->_graph->Add($seriesPlot);
+ } // function _renderPlotContour()
+
+
+ private function _renderPlotStock($groupID) {
+ $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
+ $plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
+ $seriesPlots = array();
+
+ $dataValues = array();
+ // Loop through each data series in turn
+ for($i = 0; $i < $seriesCount; ++$i) {
+ $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
+ $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
+
+ foreach($dataValuesX as $j => $dataValueX)
+ $dataValues[$j][$plotOrder[$i]] = $dataValueX;
+ }
+
+ $seriesPlot = new StockPlot($dataValues);
+
+ $this->_graph->Add($seriesPlot);
+ } // function _renderPlotStock()
+
+
+ private function _renderAreaChart($groupCount, $dimensions = '2d') {
+ require_once('jpgraph_line.php');
+
+ $this->_renderCartesianPlotArea();
+
+ for($i = 0; $i < $groupCount; ++$i) {
+ $this->_renderPlotLine($i,True,False,$dimensions);
+ }
+ } // function _renderAreaChart()
+
+
+ private function _renderLineChart($groupCount, $dimensions = '2d') {
+ require_once('jpgraph_line.php');
+
+ $this->_renderCartesianPlotArea();
+
+ for($i = 0; $i < $groupCount; ++$i) {
+ $this->_renderPlotLine($i,False,False,$dimensions);
+ }
+ } // function _renderLineChart()
+
+
+ private function _renderBarChart($groupCount, $dimensions = '2d') {
+ require_once('jpgraph_bar.php');
+
+ $this->_renderCartesianPlotArea();
+
+ for($i = 0; $i < $groupCount; ++$i) {
+ $this->_renderPlotBar($i,$dimensions);
+ }
+ } // function _renderBarChart()
+
+
+ private function _renderScatterChart($groupCount) {
+ require_once('jpgraph_scatter.php');
+ require_once('jpgraph_regstat.php');
+ require_once('jpgraph_line.php');
+
+ $this->_renderCartesianPlotArea('linlin');
+
+ for($i = 0; $i < $groupCount; ++$i) {
+ $this->_renderPlotScatter($i,false);
+ }
+ } // function _renderScatterChart()
+
+
+ private function _renderBubbleChart($groupCount) {
+ require_once('jpgraph_scatter.php');
+
+ $this->_renderCartesianPlotArea('linlin');
+
+ for($i = 0; $i < $groupCount; ++$i) {
+ $this->_renderPlotScatter($i,true);
+ }
+ } // function _renderBubbleChart()
+
+
+ private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) {
+ require_once('jpgraph_pie.php');
+ if ($dimensions == '3d') {
+ require_once('jpgraph_pie3d.php');
+ }
+
+ $this->_renderPiePlotArea($doughnut);
+
+ $iLimit = ($multiplePlots) ? $groupCount : 1;
+ for($groupID = 0; $groupID < $iLimit; ++$groupID) {
+ $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
+ $exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
+ if ($groupID == 0) {
+ $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
+ if ($labelCount > 0) {
+ $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
+ $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount);
+ }
+ }
+
+ $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
+ $seriesPlots = array();
+ // For pie charts, we only display the first series: doughnut charts generally display all series
+ $jLimit = ($multiplePlots) ? $seriesCount : 1;
+ // Loop through each data series in turn
+ for($j = 0; $j < $jLimit; ++$j) {
+ $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
+
+ // Fill in any missing values in the $dataValues array
+ $testCurrentIndex = 0;
+ foreach($dataValues as $k => $dataValue) {
+ while($k != $testCurrentIndex) {
+ $dataValues[$testCurrentIndex] = null;
+ ++$testCurrentIndex;
+ }
+ ++$testCurrentIndex;
+ }
+
+ if ($dimensions == '3d') {
+ $seriesPlot = new PiePlot3D($dataValues);
+ } else {
+ if ($doughnut) {
+ $seriesPlot = new PiePlotC($dataValues);
+ } else {
+ $seriesPlot = new PiePlot($dataValues);
+ }
+ }
+
+ if ($multiplePlots) {
+ $seriesPlot->SetSize(($jLimit-$j) / ($jLimit * 4));
+ }
+
+ if ($doughnut) {
+ $seriesPlot->SetMidColor('white');
+ }
+
+ $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
+ if (count($datasetLabels) > 0)
+ $seriesPlot->SetLabels(array_fill(0,count($datasetLabels),''));
+ if ($dimensions != '3d') {
+ $seriesPlot->SetGuideLines(false);
+ }
+ if ($j == 0) {
+ if ($exploded) {
+ $seriesPlot->ExplodeAll();
+ }
+ $seriesPlot->SetLegends($datasetLabels);
+ }
+
+ $this->_graph->Add($seriesPlot);
+ }
+ }
+ } // function _renderPieChart()
+
+
+ private function _renderRadarChart($groupCount) {
+ require_once('jpgraph_radar.php');
+
+ $this->_renderRadarPlotArea();
+
+ for($groupID = 0; $groupID < $groupCount; ++$groupID) {
+ $this->_renderPlotRadar($groupID);
+ }
+ } // function _renderRadarChart()
+
+
+ private function _renderStockChart($groupCount) {
+ require_once('jpgraph_stock.php');
+
+ $this->_renderCartesianPlotArea();
+
+ for($groupID = 0; $groupID < $groupCount; ++$i) {
+ $this->_renderPlotStock($groupID);
+ }
+ } // function _renderStockChart()
+
+
+ private function _renderContourChart($groupCount,$dimensions) {
+ require_once('jpgraph_contour.php');
+
+ $this->_renderCartesianPlotArea('intint');
+
+ for($i = 0; $i < $groupCount; ++$i) {
+ $this->_renderPlotContour($i);
+ }
+ } // function _renderContourChart()
+
+
+ private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) {
+ require_once('jpgraph_line.php');
+ require_once('jpgraph_bar.php');
+ require_once('jpgraph_scatter.php');
+ require_once('jpgraph_regstat.php');
+ require_once('jpgraph_line.php');
+
+ $this->_renderCartesianPlotArea();
+
+ for($i = 0; $i < $groupCount; ++$i) {
+ $dimensions = null;
+ $chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
+ switch ($chartType) {
+ case 'area3DChart' :
+ $dimensions = '3d';
+ case 'areaChart' :
+ $this->_renderPlotLine($i,True,True,$dimensions);
+ break;
+ case 'bar3DChart' :
+ $dimensions = '3d';
+ case 'barChart' :
+ $this->_renderPlotBar($i,$dimensions);
+ break;
+ case 'line3DChart' :
+ $dimensions = '3d';
+ case 'lineChart' :
+ $this->_renderPlotLine($i,False,True,$dimensions);
+ break;
+ case 'scatterChart' :
+ $this->_renderPlotScatter($i,false);
+ break;
+ case 'bubbleChart' :
+ $this->_renderPlotScatter($i,true);
+ break;
+ default :
+ $this->_graph = null;
+ return false;
+ }
+ }
+
+ $this->_renderLegend();
+
+ $this->_graph->Stroke($outputDestination);
+ return true;
+ } // function _renderCombinationChart()
+
+
+ public function render($outputDestination) {
+ self::$_plotColour = 0;
+
+ $groupCount = $this->_chart->getPlotArea()->getPlotGroupCount();
+
+ $dimensions = null;
+ if ($groupCount == 1) {
+ $chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
+ } else {
+ $chartTypes = array();
+ for($i = 0; $i < $groupCount; ++$i) {
+ $chartTypes[] = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
+ }
+ $chartTypes = array_unique($chartTypes);
+ if (count($chartTypes) == 1) {
+ $chartType = array_pop($chartTypes);
+ } elseif (count($chartTypes) == 0) {
+ echo 'Chart is not yet implemented ';
+ return false;
+ } else {
+ return $this->_renderCombinationChart($groupCount,$dimensions,$outputDestination);
+ }
+ }
+
+ switch ($chartType) {
+ case 'area3DChart' :
+ $dimensions = '3d';
+ case 'areaChart' :
+ $this->_renderAreaChart($groupCount,$dimensions);
+ break;
+ case 'bar3DChart' :
+ $dimensions = '3d';
+ case 'barChart' :
+ $this->_renderBarChart($groupCount,$dimensions);
+ break;
+ case 'line3DChart' :
+ $dimensions = '3d';
+ case 'lineChart' :
+ $this->_renderLineChart($groupCount,$dimensions);
+ break;
+ case 'pie3DChart' :
+ $dimensions = '3d';
+ case 'pieChart' :
+ $this->_renderPieChart($groupCount,$dimensions,False,False);
+ break;
+ case 'doughnut3DChart' :
+ $dimensions = '3d';
+ case 'doughnutChart' :
+ $this->_renderPieChart($groupCount,$dimensions,True,True);
+ break;
+ case 'scatterChart' :
+ $this->_renderScatterChart($groupCount);
+ break;
+ case 'bubbleChart' :
+ $this->_renderBubbleChart($groupCount);
+ break;
+ case 'radarChart' :
+ $this->_renderRadarChart($groupCount);
+ break;
+ case 'surface3DChart' :
+ $dimensions = '3d';
+ case 'surfaceChart' :
+ $this->_renderContourChart($groupCount,$dimensions);
+ break;
+ case 'stockChart' :
+ $this->_renderStockChart($groupCount,$dimensions);
+ break;
+ default :
+ echo $chartType.' is not yet implemented ';
+ return false;
+ }
+ $this->_renderLegend();
+
+ $this->_graph->Stroke($outputDestination);
+ return true;
+ } // function render()
+
+
+ /**
+ * Create a new PHPExcel_Chart_Renderer_jpgraph
+ */
+ public function __construct(PHPExcel_Chart $chart)
+ {
+ $this->_graph = null;
+ $this->_chart = $chart;
+ } // function __construct()
+
+} // PHPExcel_Chart_Renderer_jpgraph
diff --git a/htdocs/includes/phpexcel/PHPExcel/Chart/Title.php b/htdocs/includes/phpexcel/PHPExcel/Chart/Title.php
new file mode 100644
index 00000000000..ef26f465825
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Chart/Title.php
@@ -0,0 +1,89 @@
+_caption = $caption;
+ $this->_layout = $layout;
+ }
+
+ /**
+ * Get caption
+ *
+ * @return string
+ */
+ public function getCaption() {
+ return $this->_caption;
+ }
+
+ /**
+ * Set caption
+ *
+ * @param string $caption
+ */
+ public function setCaption($caption = null) {
+ $this->_caption = $caption;
+ }
+
+ /**
+ * Get Layout
+ *
+ * @return PHPExcel_Chart_Layout
+ */
+ public function getLayout() {
+ return $this->_layout;
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Comment.php b/htdocs/includes/phpexcel/PHPExcel/Comment.php
index 17fac71d38b..4ba239f4b7c 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Comment.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Comment.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Comment implements PHPExcel_IComparable
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php b/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php
index e1bd0ba0dc8..1f4cad247ca 100644
--- a/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php
+++ b/htdocs/includes/phpexcel/PHPExcel/DocumentProperties.php
@@ -1,28 +1,28 @@
line = $line;
+ $e->file = $file;
+ throw $e;
+ }
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/HashTable.php b/htdocs/includes/phpexcel/PHPExcel/HashTable.php
index 8ca647e8b98..ca15e6e7a79 100644
--- a/htdocs/includes/phpexcel/PHPExcel/HashTable.php
+++ b/htdocs/includes/phpexcel/PHPExcel/HashTable.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_HashTable
{
@@ -57,7 +57,7 @@ class PHPExcel_HashTable
*/
public function __construct($pSource = null)
{
- if (!is_null($pSource)) {
+ if ($pSource !== NULL) {
// Create HashTable
$this->addFromSource($pSource);
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/IComparable.php b/htdocs/includes/phpexcel/PHPExcel/IComparable.php
index 777c1cd90ea..1c87f398cf4 100644
--- a/htdocs/includes/phpexcel/PHPExcel/IComparable.php
+++ b/htdocs/includes/phpexcel/PHPExcel/IComparable.php
@@ -6,21 +6,21 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -29,7 +29,7 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_IComparable
{
@@ -37,7 +37,7 @@ interface PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode();
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/IOFactory.php b/htdocs/includes/phpexcel/PHPExcel/IOFactory.php
index f8e2e8c2855..eeeb2af93a1 100644
--- a/htdocs/includes/phpexcel/PHPExcel/IOFactory.php
+++ b/htdocs/includes/phpexcel/PHPExcel/IOFactory.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,16 +20,16 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
- * @ignore
+ * @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
@@ -40,16 +40,16 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_IOFactory
{
/**
- * Search locations
+ * Search locations
*
- * @var array
- * @access private
- * @static
+ * @var array
+ * @access private
+ * @static
*/
private static $_searchLocations = array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
@@ -57,11 +57,11 @@ class PHPExcel_IOFactory
);
/**
- * Autoresolve classes
+ * Autoresolve classes
*
- * @var array
- * @access private
- * @static
+ * @var array
+ * @access private
+ * @static
*/
private static $_autoResolveClasses = array(
'Excel2007',
@@ -70,6 +70,7 @@ class PHPExcel_IOFactory
'OOCalc',
'SYLK',
'Gnumeric',
+ 'HTML',
'CSV',
);
@@ -79,23 +80,23 @@ class PHPExcel_IOFactory
private function __construct() { }
/**
- * Get search locations
+ * Get search locations
*
- * @static
- * @access public
- * @return array
+ * @static
+ * @access public
+ * @return array
*/
public static function getSearchLocations() {
return self::$_searchLocations;
} // function getSearchLocations()
/**
- * Set search locations
+ * Set search locations
*
- * @static
- * @access public
- * @param array $value
- * @throws Exception
+ * @static
+ * @access public
+ * @param array $value
+ * @throws Exception
*/
public static function setSearchLocations($value) {
if (is_array($value)) {
@@ -106,27 +107,27 @@ class PHPExcel_IOFactory
} // function setSearchLocations()
/**
- * Add search location
+ * Add search location
*
- * @static
- * @access public
- * @param string $type Example: IWriter
- * @param string $location Example: PHPExcel/Writer/{0}.php
- * @param string $classname Example: PHPExcel_Writer_{0}
+ * @static
+ * @access public
+ * @param string $type Example: IWriter
+ * @param string $location Example: PHPExcel/Writer/{0}.php
+ * @param string $classname Example: PHPExcel_Writer_{0}
*/
public static function addSearchLocation($type = '', $location = '', $classname = '') {
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
} // function addSearchLocation()
/**
- * Create PHPExcel_Writer_IWriter
+ * Create PHPExcel_Writer_IWriter
*
- * @static
- * @access public
- * @param PHPExcel $phpExcel
- * @param string $writerType Example: Excel2007
- * @return PHPExcel_Writer_IWriter
- * @throws Exception
+ * @static
+ * @access public
+ * @param PHPExcel $phpExcel
+ * @param string $writerType Example: Excel2007
+ * @return PHPExcel_Writer_IWriter
+ * @throws Exception
*/
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
// Search type
@@ -136,10 +137,9 @@ class PHPExcel_IOFactory
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']);
- $classFile = str_replace('{0}', $writerType, $searchLocation['path']);
$instance = new $className($phpExcel);
- if (!is_null($instance)) {
+ if ($instance !== NULL) {
return $instance;
}
}
@@ -150,13 +150,13 @@ class PHPExcel_IOFactory
} // function createWriter()
/**
- * Create PHPExcel_Reader_IReader
+ * Create PHPExcel_Reader_IReader
*
- * @static
- * @access public
- * @param string $readerType Example: Excel2007
- * @return PHPExcel_Reader_IReader
- * @throws Exception
+ * @static
+ * @access public
+ * @param string $readerType Example: Excel2007
+ * @return PHPExcel_Reader_IReader
+ * @throws Exception
*/
public static function createReader($readerType = '') {
// Search type
@@ -166,10 +166,9 @@ class PHPExcel_IOFactory
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $readerType, $searchLocation['class']);
- $classFile = str_replace('{0}', $readerType, $searchLocation['path']);
$instance = new $className();
- if (!is_null($instance)) {
+ if ($instance !== NULL) {
return $instance;
}
}
@@ -180,13 +179,13 @@ class PHPExcel_IOFactory
} // function createReader()
/**
- * Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
+ * Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
*
- * @static
- * @access public
- * @param string $pFileName
- * @return PHPExcel
- * @throws Exception
+ * @static
+ * @access public
+ * @param string $pFileName The name of the spreadsheet file
+ * @return PHPExcel
+ * @throws Exception
*/
public static function load($pFilename) {
$reader = self::createReaderForFile($pFilename);
@@ -194,13 +193,13 @@ class PHPExcel_IOFactory
} // function load()
/**
- * Identify file type using automatic PHPExcel_Reader_IReader resolution
+ * Identify file type using automatic PHPExcel_Reader_IReader resolution
*
- * @static
- * @access public
- * @param string $pFileName
- * @return string
- * @throws Exception
+ * @static
+ * @access public
+ * @param string $pFileName The name of the spreadsheet file to identify
+ * @return string
+ * @throws Exception
*/
public static function identify($pFilename) {
$reader = self::createReaderForFile($pFilename);
@@ -211,38 +210,48 @@ class PHPExcel_IOFactory
} // function identify()
/**
- * Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
+ * Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
*
- * @static
- * @access public
- * @param string $pFileName
- * @return PHPExcel_Reader_IReader
- * @throws Exception
+ * @static
+ * @access public
+ * @param string $pFileName The name of the spreadsheet file
+ * @return PHPExcel_Reader_IReader
+ * @throws Exception
*/
public static function createReaderForFile($pFilename) {
// First, lucky guess by inspecting file extension
$pathinfo = pathinfo($pFilename);
+ $extensionType = NULL;
if (isset($pathinfo['extension'])) {
switch (strtolower($pathinfo['extension'])) {
- case 'xlsx':
- $reader = self::createReader('Excel2007');
+ case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
+ case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
+ case 'xltx': // Excel (OfficeOpenXML) Template
+ case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
+ $extensionType = 'Excel2007';
break;
- case 'xls':
- $reader = self::createReader('Excel5');
+ case 'xls': // Excel (BIFF) Spreadsheet
+ case 'xlt': // Excel (BIFF) Template
+ $extensionType = 'Excel5';
break;
- case 'ods':
- $reader = self::createReader('OOCalc');
+ case 'ods': // Open/Libre Offic Calc
+ case 'ots': // Open/Libre Offic Calc Template
+ $extensionType = 'OOCalc';
break;
case 'slk':
- $reader = self::createReader('SYLK');
+ $extensionType = 'SYLK';
break;
- case 'xml':
- $reader = self::createReader('Excel2003XML');
+ case 'xml': // Excel 2003 SpreadSheetML
+ $extensionType = 'Excel2003XML';
break;
case 'gnumeric':
- $reader = self::createReader('Gnumeric');
+ $extensionType = 'Gnumeric';
+ break;
+ case 'htm':
+ case 'html':
+ $extensionType = 'HTML';
break;
case 'csv':
// Do nothing
@@ -253,22 +262,27 @@ class PHPExcel_IOFactory
break;
}
- // Let's see if we are lucky
- if (isset($reader) && $reader->canRead($pFilename)) {
- return $reader;
+ if ($extensionType !== NULL) {
+ $reader = self::createReader($extensionType);
+ // Let's see if we are lucky
+ if (isset($reader) && $reader->canRead($pFilename)) {
+ return $reader;
+ }
}
-
}
// If we reach here then "lucky guess" didn't give any result
-
- // Try loading using self::$_autoResolveClasses
+ // Try walking through all the options in self::$_autoResolveClasses
foreach (self::$_autoResolveClasses as $autoResolveClass) {
- $reader = self::createReader($autoResolveClass);
- if ($reader->canRead($pFilename)) {
- return $reader;
+ // Ignore our original guess, we know that won't work
+ if ($autoResolveClass !== $extensionType) {
+ $reader = self::createReader($autoResolveClass);
+ if ($reader->canRead($pFilename)) {
+ return $reader;
+ }
}
}
+ throw new Exception('Unable to identify a reader for this file');
} // function createReaderForFile()
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/NamedRange.php b/htdocs/includes/phpexcel/PHPExcel/NamedRange.php
index 9afb0f9b40d..3debd41a184 100644
--- a/htdocs/includes/phpexcel/PHPExcel/NamedRange.php
+++ b/htdocs/includes/phpexcel/PHPExcel/NamedRange.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_NamedRange
{
@@ -82,7 +82,7 @@ class PHPExcel_NamedRange
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
{
// Validate data
- if (is_null($pName) || is_null($pWorksheet)|| is_null($pRange)) {
+ if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
throw new Exception('Parameters can not be null.');
}
@@ -111,17 +111,17 @@ class PHPExcel_NamedRange
* @return PHPExcel_NamedRange
*/
public function setName($value = null) {
- if (!is_null($value)) {
+ if ($value !== NULL) {
// Old title
$oldTitle = $this->_name;
// Re-attach
- if (!is_null($this->_worksheet)) {
+ if ($this->_worksheet !== NULL) {
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
}
$this->_name = $value;
- if (!is_null($this->_worksheet)) {
+ if ($this->_worksheet !== NULL) {
$this->_worksheet->getParent()->addNamedRange($this);
}
@@ -148,7 +148,7 @@ class PHPExcel_NamedRange
* @return PHPExcel_NamedRange
*/
public function setWorksheet(PHPExcel_Worksheet $value = null) {
- if (!is_null($value)) {
+ if ($value !== NULL) {
$this->_worksheet = $value;
}
return $this;
@@ -170,7 +170,7 @@ class PHPExcel_NamedRange
* @return PHPExcel_NamedRange
*/
public function setRange($value = null) {
- if (!is_null($value)) {
+ if ($value !== NULL) {
$this->_range = $value;
}
return $this;
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php b/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php
index 3bac3af0f23..2739e3c4136 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/CSV.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -40,89 +40,91 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
{
/**
- * Input encoding
+ * Input encoding
*
- * @access private
- * @var string
+ * @access private
+ * @var string
*/
private $_inputEncoding = 'UTF-8';
/**
- * Delimiter
+ * Delimiter
*
- * @access private
- * @var string
+ * @access private
+ * @var string
*/
private $_delimiter = ',';
/**
- * Enclosure
+ * Enclosure
*
- * @access private
- * @var string
+ * @access private
+ * @var string
*/
private $_enclosure = '"';
/**
- * Line ending
+ * Line ending
*
- * @access private
- * @var string
+ * @access private
+ * @var string
*/
private $_lineEnding = PHP_EOL;
/**
- * Sheet index to read
+ * Sheet index to read
*
- * @access private
- * @var int
+ * @access private
+ * @var int
*/
private $_sheetIndex = 0;
/**
- * Load rows contiguously
+ * Load rows contiguously
*
- * @access private
- * @var int
+ * @access private
+ * @var int
*/
private $_contiguous = false;
/**
- * Row counter for loading rows contiguously
+ * Row counter for loading rows contiguously
*
- * @access private
- * @var int
+ * @access private
+ * @var int
*/
private $_contiguousRow = -1;
/**
- * PHPExcel_Reader_IReadFilter instance
+ * PHPExcel_Reader_IReadFilter instance
*
- * @access private
- * @var PHPExcel_Reader_IReadFilter
+ * @access private
+ * @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
+
/**
- * Create a new PHPExcel_Reader_CSV
+ * Create a new PHPExcel_Reader_CSV
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
} // function __construct()
+
/**
- * Can the current PHPExcel_Reader_IReader read the file?
+ * Can the current PHPExcel_Reader_IReader read the file?
*
- * @access public
- * @param string $pFileName
- * @return boolean
- * @throws Exception
+ * @access public
+ * @param string $pFileName
+ * @return boolean
+ * @throws Exception
*/
public function canRead($pFilename)
{
@@ -134,13 +136,133 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
return true;
} // function canRead()
+
/**
- * Loads PHPExcel from file
+ * Read filter
*
- * @access public
- * @param string $pFilename
- * @return PHPExcel
- * @throws Exception
+ * @access public
+ * @return PHPExcel_Reader_IReadFilter
+ */
+ public function getReadFilter() {
+ return $this->_readFilter;
+ } // function getReadFilter()
+
+
+ /**
+ * Set read filter
+ *
+ * @access public
+ * @param PHPExcel_Reader_IReadFilter $pValue
+ */
+ public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
+ $this->_readFilter = $pValue;
+ return $this;
+ } // function setReadFilter()
+
+
+ /**
+ * Set input encoding
+ *
+ * @access public
+ * @param string $pValue Input encoding
+ */
+ public function setInputEncoding($pValue = 'UTF-8')
+ {
+ $this->_inputEncoding = $pValue;
+ return $this;
+ } // function setInputEncoding()
+
+
+ /**
+ * Get input encoding
+ *
+ * @access public
+ * @return string
+ */
+ public function getInputEncoding()
+ {
+ return $this->_inputEncoding;
+ } // function getInputEncoding()
+
+
+ /**
+ * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
+ *
+ * @access public
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetInfo($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ // Open file
+ $fileHandle = fopen($pFilename, 'r');
+ if ($fileHandle === false) {
+ throw new Exception("Could not open file " . $pFilename . " for reading.");
+ }
+
+ // Skip BOM, if any
+ switch ($this->_inputEncoding) {
+ case 'UTF-8':
+ fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
+ fseek($fileHandle, 3) : fseek($fileHandle, 0);
+ break;
+ case 'UTF-16LE':
+ fgets($fileHandle, 3) == "\xFF\xFE" ?
+ fseek($fileHandle, 2) : fseek($fileHandle, 0);
+ break;
+ case 'UTF-16BE':
+ fgets($fileHandle, 3) == "\xFE\xFF" ?
+ fseek($fileHandle, 2) : fseek($fileHandle, 0);
+ break;
+ case 'UTF-32LE':
+ fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ?
+ fseek($fileHandle, 4) : fseek($fileHandle, 0);
+ break;
+ case 'UTF-32BE':
+ fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ?
+ fseek($fileHandle, 4) : fseek($fileHandle, 0);
+ break;
+ default:
+ break;
+ }
+
+ $escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
+
+ $worksheetInfo = array();
+ $worksheetInfo[0]['worksheetName'] = 'Worksheet';
+ $worksheetInfo[0]['lastColumnLetter'] = 'A';
+ $worksheetInfo[0]['lastColumnIndex'] = 0;
+ $worksheetInfo[0]['totalRows'] = 0;
+ $worksheetInfo[0]['totalColumns'] = 0;
+
+ // Loop through each line of the file in turn
+ while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
+ $worksheetInfo[0]['totalRows']++;
+ $worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
+ }
+
+ $worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
+ $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
+
+ // Close file
+ fclose($fileHandle);
+
+ return $worksheetInfo;
+ }
+
+
+ /**
+ * Loads PHPExcel from file
+ *
+ * @access public
+ * @param string $pFilename
+ * @return PHPExcel
+ * @throws Exception
*/
public function load($pFilename)
{
@@ -151,58 +273,15 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
return $this->loadIntoExisting($pFilename, $objPHPExcel);
} // function load()
- /**
- * Read filter
- *
- * @access public
- * @return PHPExcel_Reader_IReadFilter
- */
- public function getReadFilter() {
- return $this->_readFilter;
- } // function getReadFilter()
/**
- * Set read filter
+ * Loads PHPExcel from file into PHPExcel instance
*
- * @access public
- * @param PHPExcel_Reader_IReadFilter $pValue
- */
- public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
- $this->_readFilter = $pValue;
- return $this;
- } // function setReadFilter()
-
- /**
- * Set input encoding
- *
- * @access public
- * @param string $pValue Input encoding
- */
- public function setInputEncoding($pValue = 'UTF-8')
- {
- $this->_inputEncoding = $pValue;
- return $this;
- } // function setInputEncoding()
-
- /**
- * Get input encoding
- *
- * @access public
- * @return string
- */
- public function getInputEncoding()
- {
- return $this->_inputEncoding;
- } // function getInputEncoding()
-
- /**
- * Loads PHPExcel from file into PHPExcel instance
- *
- * @access public
- * @param string $pFilename
- * @param PHPExcel $objPHPExcel
- * @return PHPExcel
- * @throws Exception
+ * @access public
+ * @param string $pFilename
+ * @param PHPExcel $objPHPExcel
+ * @return PHPExcel
+ * @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
@@ -215,7 +294,10 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet();
}
- $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
+ $sheet = $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
+
+ $lineEnding = ini_get('auto_detect_line_endings');
+ ini_set('auto_detect_line_endings', true);
// Open file
$fileHandle = fopen($pFilename, 'r');
@@ -256,7 +338,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Set our starting row based on whether we're in contiguous mode or not
$currentRow = 1;
if ($this->_contiguous) {
- $currentRow = ($this->_contiguousRow == -1) ? $objPHPExcel->getActiveSheet()->getHighestRow(): $this->_contiguousRow;
+ $currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
}
// Loop through each line of the file in turn
@@ -273,7 +355,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
// Set cell value
- $objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowDatum);
+ $sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
}
++$columnLetter;
}
@@ -287,48 +369,54 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
$this->_contiguousRow = $currentRow;
}
+ ini_set('auto_detect_line_endings', $lineEnding);
+
// Return
return $objPHPExcel;
} // function loadIntoExisting()
+
/**
- * Get delimiter
+ * Get delimiter
*
- * @access public
- * @return string
+ * @access public
+ * @return string
*/
public function getDelimiter() {
return $this->_delimiter;
} // function getDelimiter()
+
/**
- * Set delimiter
+ * Set delimiter
*
- * @access public
- * @param string $pValue Delimiter, defaults to ,
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param string $pValue Delimiter, defaults to ,
+ * @return PHPExcel_Reader_CSV
*/
public function setDelimiter($pValue = ',') {
$this->_delimiter = $pValue;
return $this;
} // function setDelimiter()
+
/**
- * Get enclosure
+ * Get enclosure
*
- * @access public
- * @return string
+ * @access public
+ * @return string
*/
public function getEnclosure() {
return $this->_enclosure;
} // function getEnclosure()
+
/**
- * Set enclosure
+ * Set enclosure
*
- * @access public
- * @param string $pValue Enclosure, defaults to "
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param string $pValue Enclosure, defaults to "
+ * @return PHPExcel_Reader_CSV
*/
public function setEnclosure($pValue = '"') {
if ($pValue == '') {
@@ -338,55 +426,60 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
return $this;
} // function setEnclosure()
+
/**
- * Get line ending
+ * Get line ending
*
- * @access public
- * @return string
+ * @access public
+ * @return string
*/
public function getLineEnding() {
return $this->_lineEnding;
} // function getLineEnding()
+
/**
- * Set line ending
+ * Set line ending
*
- * @access public
- * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
+ * @return PHPExcel_Reader_CSV
*/
public function setLineEnding($pValue = PHP_EOL) {
$this->_lineEnding = $pValue;
return $this;
} // function setLineEnding()
+
/**
- * Get sheet index
+ * Get sheet index
*
- * @access public
- * @return int
+ * @access public
+ * @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
} // function getSheetIndex()
+
/**
- * Set sheet index
+ * Set sheet index
*
- * @access public
- * @param int $pValue Sheet index
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param int $pValue Sheet index
+ * @return PHPExcel_Reader_CSV
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
} // function setSheetIndex()
+
/**
- * Set Contiguous
+ * Set Contiguous
*
- * @access public
- * @param string $pValue Input encoding
+ * @access public
+ * @param string $pValue Input encoding
*/
public function setContiguous($contiguous = false)
{
@@ -398,11 +491,12 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
return $this;
} // function setInputEncoding()
+
/**
- * Get Contiguous
+ * Get Contiguous
*
- * @access public
- * @return boolean
+ * @access public
+ * @return boolean
*/
public function getContiguous() {
return $this->_contiguous;
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php b/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php
index 9255f2dfaff..276b974eecc 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/DefaultReadFilter.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -40,7 +40,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php
index cb91a746b34..33ffe6dcb3f 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2003XML.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -40,7 +40,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
{
@@ -72,6 +72,21 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
*/
private $_readFilter = null;
+ /**
+ * Character set used in the file
+ *
+ * @var string
+ */
+ private $_charSet = 'UTF-8';
+
+
+ /**
+ * Create a new PHPExcel_Reader_Excel2003XML
+ */
+ public function __construct() {
+ $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
+ }
+
/**
* Read data only?
@@ -82,6 +97,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this->_readDataOnly;
}
+
/**
* Set read data only
*
@@ -93,6 +109,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this;
}
+
/**
* Get which sheets to load
*
@@ -103,6 +120,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this->_loadSheetsOnly;
}
+
/**
* Set which sheets to load
*
@@ -116,6 +134,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this;
}
+
/**
* Set all sheets to load
*
@@ -127,6 +146,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this;
}
+
/**
* Read filter
*
@@ -136,6 +156,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this->_readFilter;
}
+
/**
* Set read filter
*
@@ -147,31 +168,26 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this;
}
- /**
- * Create a new PHPExcel_Reader_Excel2003XML
- */
- public function __construct() {
- $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
- }
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
+ * @throws Exception
*/
public function canRead($pFilename)
{
-// Office xmlns:o="urn:schemas-microsoft-com:office:office"
-// Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
-// XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
-// Spreadsheet component xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
-// XML schema xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
-// XML data type xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
-// MS-persist recordset xmlns:rs="urn:schemas-microsoft-com:rowset"
-// Rowset xmlns:z="#RowsetSchema"
-//
+ // Office xmlns:o="urn:schemas-microsoft-com:office:office"
+ // Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
+ // XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
+ // Spreadsheet component xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
+ // XML schema xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
+ // XML data type xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
+ // MS-persist recordset xmlns:rs="urn:schemas-microsoft-com:rowset"
+ // Rowset xmlns:z="#RowsetSchema"
+ //
$signature = array(
'/um',$data,$matches)) {
+ $this->_charSet = strtoupper($matches[1]);
+ }
+// echo 'Character Set is ',$this->_charSet,' ';
+
return $valid;
}
+
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
@@ -212,6 +235,9 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
+ if (!$this->canRead($pFilename)) {
+ throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
+ }
$worksheetNames = array();
@@ -221,7 +247,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
$xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
- $worksheetNames[] = $worksheet_ss['Name'];
+ $worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet);
}
return $worksheetNames;
@@ -229,6 +255,77 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
/**
+ * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
+ *
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetInfo($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ $worksheetInfo = array();
+
+ $xml = simplexml_load_file($pFilename);
+ $namespaces = $xml->getNamespaces(true);
+
+ $worksheetID = 1;
+ $xml_ss = $xml->children($namespaces['ss']);
+ foreach($xml_ss->Worksheet as $worksheet) {
+ $worksheet_ss = $worksheet->attributes($namespaces['ss']);
+
+ $tmpInfo = array();
+ $tmpInfo['worksheetName'] = '';
+ $tmpInfo['lastColumnLetter'] = 'A';
+ $tmpInfo['lastColumnIndex'] = 0;
+ $tmpInfo['totalRows'] = 0;
+ $tmpInfo['totalColumns'] = 0;
+
+ if (isset($worksheet_ss['Name'])) {
+ $tmpInfo['worksheetName'] = (string) $worksheet_ss['Name'];
+ } else {
+ $tmpInfo['worksheetName'] = "Worksheet_{$worksheetID}";
+ }
+
+ if (isset($worksheet->Table->Row)) {
+ $rowIndex = 0;
+
+ foreach($worksheet->Table->Row as $rowData) {
+ $columnIndex = 0;
+ $rowHasData = false;
+
+ foreach($rowData->Cell as $cell) {
+ if (isset($cell->Data)) {
+ $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
+ $rowHasData = true;
+ }
+
+ ++$columnIndex;
+ }
+
+ ++$rowIndex;
+
+ if ($rowHasData) {
+ $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
+ }
+ }
+ }
+
+ $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
+ $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
+
+ $worksheetInfo[] = $tmpInfo;
+ ++$worksheetID;
+ }
+
+ return $worksheetInfo;
+ }
+
+
+ /**
* Loads PHPExcel from file
*
* @param string $pFilename
@@ -244,6 +341,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
+
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) {
@@ -255,6 +353,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return false;
}
+
/**
* pixel units to excel width units(units of 1/256th of a character width)
* @param pxs
@@ -268,6 +367,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $widthUnits;
}
+
/**
* excel width units(units of 1/256th of a character width) to pixel units
* @param widthUnits
@@ -285,6 +385,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return chr(hexdec($hex[1]));
}
+
/**
* Loads PHPExcel from file into PHPExcel instance
*
@@ -329,6 +430,10 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
+ if (!$this->canRead($pFilename)) {
+ throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
+ }
+
$xml = simplexml_load_file($pFilename);
$namespaces = $xml->getNamespaces(true);
@@ -337,39 +442,39 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
foreach($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
switch ($propertyName) {
case 'Title' :
- $docProps->setTitle($propertyValue);
+ $docProps->setTitle(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'Subject' :
- $docProps->setSubject($propertyValue);
+ $docProps->setSubject(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'Author' :
- $docProps->setCreator($propertyValue);
+ $docProps->setCreator(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'Created' :
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
break;
case 'LastAuthor' :
- $docProps->setLastModifiedBy($propertyValue);
+ $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'LastSaved' :
$lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate);
break;
case 'Company' :
- $docProps->setCompany($propertyValue);
+ $docProps->setCompany(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'Category' :
- $docProps->setCategory($propertyValue);
+ $docProps->setCategory(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'Manager' :
- $docProps->setManager($propertyValue);
+ $docProps->setManager(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'Keywords' :
- $docProps->setKeywords($propertyValue);
+ $docProps->setKeywords(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
case 'Description' :
- $docProps->setDescription($propertyValue);
+ $docProps->setDescription(self::_convertStringEncoding($propertyValue,$this->_charSet));
break;
}
}
@@ -462,7 +567,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
break;
}
}
- if (count($thisBorder) > 0) {
+ if (!empty($thisBorder)) {
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
$this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder;
}
@@ -535,6 +640,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
$worksheetID = 0;
$xml_ss = $xml->children($namespaces['ss']);
+
foreach($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
@@ -549,8 +655,11 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheet_ss['Name'])) {
- $worksheetName = (string) $worksheet_ss['Name'];
- $objPHPExcel->getActiveSheet()->setTitle($worksheetName);
+ $worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet);
+ // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
+ // formula cells... during the load, all formulae should be correct, and we're simply bringing
+ // the worksheet name in line with the formula, not the reverse
+ $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
}
$columnID = 'A';
@@ -588,7 +697,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
}
$cellRange = $columnID.$rowID;
- if (!is_null($this->getReadFilter())) {
+ if ($this->getReadFilter() !== NULL) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue;
}
@@ -630,11 +739,12 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
const TYPE_FORMULA = 'f';
const TYPE_NUMERIC = 'n';
const TYPE_BOOL = 'b';
- const TYPE_NULL = 's';
+ const TYPE_NULL = 'null';
const TYPE_INLINE = 'inlineStr';
const TYPE_ERROR = 'e';
*/
case 'String' :
+ $cellValue = self::_convertStringEncoding($cellValue,$this->_charSet);
$type = PHPExcel_Cell_DataType::TYPE_STRING;
break;
case 'Number' :
@@ -735,14 +845,14 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
$annotation = strip_tags($node);
// echo 'Annotation: ',$annotation,' ';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
- ->setAuthor( $author )
+ ->setAuthor(self::_convertStringEncoding($author ,$this->_charSet))
->setText($this->_parseRichText($annotation) );
}
if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
$style = (string) $cell_ss['StyleID'];
// echo 'Cell style for '.$columnID.$rowID.' is '.$style.' ';
- if ((isset($this->_styles[$style])) && (count($this->_styles[$style]) > 0)) {
+ if ((isset($this->_styles[$style])) && (!empty($this->_styles[$style]))) {
// echo 'Cell '.$columnID.$rowID.' ';
// print_r($this->_styles[$style]);
// echo ' ';
@@ -776,10 +886,19 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $objPHPExcel;
}
+
+ private static function _convertStringEncoding($string,$charset) {
+ if ($charset != 'UTF-8') {
+ return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset);
+ }
+ return $string;
+ }
+
+
private function _parseRichText($is = '') {
$value = new PHPExcel_RichText();
- $value->createText($is);
+ $value->createText(self::_convertStringEncoding($is,$this->_charSet));
return $value;
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php
index ae38cbfd6c8..fbb9158ebd3 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -36,118 +36,169 @@ if (!defined('PHPEXCEL_ROOT')) {
}
/**
- * PHPExcel_Reader_Excel2007
+ * PHPExcel_Reader_Excel2007
*
- * @category PHPExcel
- * @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @category PHPExcel
+ * @package PHPExcel_Reader
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
{
/**
- * Read data only?
- * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
+ * Read data only?
+ * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
- * @var boolean
+ * @var boolean
*/
- private $_readDataOnly = false;
+ private $_readDataOnly = FALSE;
/**
- * Restrict which sheets should be loaded?
- * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
+ * Read charts that are defined in the workbook?
+ * Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
*
- * @var array of string
+ * @var boolean
*/
- private $_loadSheetsOnly = null;
+ private $_includeCharts = FALSE;
+
+ /**
+ * Restrict which sheets should be loaded?
+ * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
+ *
+ * @var array of string
+ */
+ private $_loadSheetsOnly = NULL;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
- private $_readFilter = null;
+ private $_readFilter = NULL;
/**
* PHPExcel_ReferenceHelper instance
*
* @var PHPExcel_ReferenceHelper
*/
- private $_referenceHelper = null;
+ private $_referenceHelper = NULL;
/**
* PHPExcel_Reader_Excel2007_Theme instance
*
* @var PHPExcel_Reader_Excel2007_Theme
*/
- private static $_theme = null;
+ private static $_theme = NULL;
/**
- * Read data only?
+ * Create a new PHPExcel_Reader_Excel2007 instance
+ */
+ public function __construct() {
+ $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
+ $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
+ }
+
+
+ /**
+ * Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
- * @return boolean
+ * @return boolean
*/
public function getReadDataOnly() {
return $this->_readDataOnly;
}
+
/**
- * Set read data only
+ * Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
- * @param boolean $pValue
+ * @param boolean $pValue
*
- * @return PHPExcel_Reader_Excel2007
+ * @return PHPExcel_Reader_Excel2007
*/
- public function setReadDataOnly($pValue = false) {
+ public function setReadDataOnly($pValue = FALSE) {
$this->_readDataOnly = $pValue;
return $this;
}
+
/**
- * Get which sheets to load
- * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
- * indicating that all worksheets in the workbook should be loaded.
+ * Read charts in workbook?
+ * If this is true, then the Reader will include any charts that exist in the workbook.
+ * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
+ * If false (the default) it will ignore any charts defined in the workbook file.
*
- * @return mixed
+ * @return boolean
+ */
+ public function getIncludeCharts() {
+ return $this->_includeCharts;
+ }
+
+
+ /**
+ * Set read charts in workbook
+ * Set to true, to advise the Reader to include any charts that exist in the workbook.
+ * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
+ * Set to false (the default) to discard charts.
+ *
+ * @param boolean $pValue
+ *
+ * @return PHPExcel_Reader_Excel2007
+ */
+ public function setIncludeCharts($pValue = FALSE) {
+ $this->_includeCharts = (boolean) $pValue;
+ return $this;
+ }
+
+
+ /**
+ * Get which sheets to load
+ * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
+ * indicating that all worksheets in the workbook should be loaded.
+ *
+ * @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
}
+
/**
- * Set which sheets to load
+ * Set which sheets to load
*
- * @param mixed $value
+ * @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
- * @return PHPExcel_Reader_Excel2007
+ * @return PHPExcel_Reader_Excel2007
*/
- public function setLoadSheetsOnly($value = null)
+ public function setLoadSheetsOnly($value = NULL)
{
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
return $this;
}
+
/**
- * Set all sheets to load
+ * Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
- * @return PHPExcel_Reader_Excel2007
+ * @return PHPExcel_Reader_Excel2007
*/
public function setLoadAllSheets()
{
- $this->_loadSheetsOnly = null;
+ $this->_loadSheetsOnly = NULL;
return $this;
}
+
/**
* Read filter
*
@@ -157,6 +208,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
return $this->_readFilter;
}
+
/**
* Set read filter
*
@@ -168,46 +220,42 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
return $this;
}
- /**
- * Create a new PHPExcel_Reader_Excel2007 instance
- */
- public function __construct() {
- $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
- $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
- }
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
+ * @throws Exception
*/
public function canRead($pFilename)
{
- // Check if zip class exists
- if (!class_exists('ZipArchive')) {
- return false;
- }
-
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
+ // Check if zip class exists
+ if (!class_exists('ZipArchive',FALSE)) {
+ throw new Exception("ZipArchive library is not enabled");
+ }
+
$xl = false;
// Load file
$zip = new ZipArchive;
if ($zip->open($pFilename) === true) {
// check if it is an OOXML archive
$rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"));
- foreach ($rels->Relationship as $rel) {
- switch ($rel["Type"]) {
- case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
- if (basename($rel["Target"]) == 'workbook.xml') {
- $xl = true;
- }
- break;
+ if ($rels !== false) {
+ foreach ($rels->Relationship as $rel) {
+ switch ($rel["Type"]) {
+ case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
+ if (basename($rel["Target"]) == 'workbook.xml') {
+ $xl = true;
+ }
+ break;
+ }
}
}
$zip->close();
@@ -216,31 +264,110 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
return $xl;
}
+
+ /**
+ * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
+ *
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetInfo($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ $worksheetInfo = array();
+
+ $zip = new ZipArchive;
+ $zip->open($pFilename);
+
+ $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");
+ foreach ($rels->Relationship as $rel) {
+ if ($rel["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") {
+ $dir = dirname($rel["Target"]);
+ $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");
+ $relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");
+
+ $worksheets = array();
+ foreach ($relsWorkbook->Relationship as $ele) {
+ if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") {
+ $worksheets[(string) $ele["Id"]] = $ele["Target"];
+ }
+ }
+
+ $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
+ if ($xmlWorkbook->sheets) {
+ $dir = dirname($rel["Target"]);
+ foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
+ $tmpInfo = array();
+ $tmpInfo['worksheetName'] = (string) $eleSheet["name"];
+ $tmpInfo['lastColumnLetter'] = 'A';
+ $tmpInfo['lastColumnIndex'] = 0;
+ $tmpInfo['totalRows'] = 0;
+ $tmpInfo['totalColumns'] = 0;
+
+ $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
+ $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
+ if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
+ foreach ($xmlSheet->sheetData->row as $row) {
+ foreach ($row->c as $c) {
+ $r = (string) $c["r"];
+ $coordinates = PHPExcel_Cell::coordinateFromString($r);
+
+ $rowIndex = $coordinates[1];
+ $columnIndex = PHPExcel_Cell::columnIndexFromString($coordinates[0]) - 1;
+
+ $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
+ $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
+ }
+ }
+ }
+
+ $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
+ $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
+
+ $worksheetInfo[] = $tmpInfo;
+ }
+ }
+ }
+ }
+
+ $zip->close();
+
+ return $worksheetInfo;
+ }
+
+
private static function _castToBool($c) {
// echo 'Initial Cast to Boolean ';
- $value = isset($c->v) ? (string) $c->v : null;
+ $value = isset($c->v) ? (string) $c->v : NULL;
if ($value == '0') {
- return false;
+ return FALSE;
} elseif ($value == '1') {
- return true;
+ return TRUE;
} else {
return (bool)$c->v;
}
return $value;
} // function _castToBool()
+
private static function _castToError($c) {
// echo 'Initial Cast to Error ';
- return isset($c->v) ? (string) $c->v : null;;
+ return isset($c->v) ? (string) $c->v : NULL;
} // function _castToError()
+
private static function _castToString($c) {
// echo 'Initial Cast to String ';
- return isset($c->v) ? (string) $c->v : null;;
+ return isset($c->v) ? (string) $c->v : NULL;
} // function _castToString()
+
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
-// echo 'Formula ';
+// echo 'Formula ';
// echo '$c->f is '.$c->f.' ';
$cellDataType = 'f';
$value = "={$c->f}";
@@ -248,7 +375,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// Shared formula?
if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') {
-// echo 'SHARED FORMULA ';
+// echo 'SHARED FORMULA ';
$instance = (string)$c->f['si'];
// echo 'Instance ID = '.$instance.' ';
@@ -257,7 +384,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// print_r($sharedFormulas);
// echo '';
if (!isset($sharedFormulas[(string)$c->f['si']])) {
-// echo 'SETTING NEW SHARED FORMULA ';
+// echo 'SETTING NEW SHARED FORMULA ';
// echo 'Master is '.$r.' ';
// echo 'Formula is '.$value.' ';
$sharedFormulas[$instance] = array( 'master' => $r,
@@ -267,7 +394,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// print_r($sharedFormulas);
// echo '';
} else {
-// echo 'GETTING SHARED FORMULA ';
+// echo 'GETTING SHARED FORMULA ';
// echo 'Master is '.$sharedFormulas[$instance]['master'].' ';
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].' ';
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
@@ -287,6 +414,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
+
public function _getFromZipArchive(ZipArchive $archive, $fileName = '')
{
// Root-relative paths
@@ -306,6 +434,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
return $contents;
}
+
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
@@ -491,7 +620,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if ($xmlStyles && $xmlStyles->numFmts[0]) {
$numFmts = $xmlStyles->numFmts[0];
}
- if (isset($numFmts) && !is_null($numFmts)) {
+ if (isset($numFmts) && ($numFmts !== NULL)) {
$numFmts->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
}
if (!$this->_readDataOnly && $xmlStyles) {
@@ -560,16 +689,16 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$dxfs = array();
if (!$this->_readDataOnly && $xmlStyles) {
+ // Conditional Styles
if ($xmlStyles->dxfs) {
foreach ($xmlStyles->dxfs->dxf as $dxf) {
- $style = new PHPExcel_Style;
+ $style = new PHPExcel_Style(FALSE, TRUE);
self::_readStyle($style, $dxf);
$dxfs[] = $style;
}
}
-
- if ($xmlStyles->cellStyles)
- {
+ // Cell Styles
+ if ($xmlStyles->cellStyles) {
foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) {
if (intval($cellStyle['builtinId']) == 0) {
if (isset($cellStyles[intval($cellStyle['xfId'])])) {
@@ -602,8 +731,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$countSkippedSheets = 0; // keep track of number of skipped sheets
$mapSheetId = array(); // mapping of sheet ids from old to new
- if ($xmlWorkbook->sheets)
- {
+
+ $charts = $chartDetails = array();
+
+ if ($xmlWorkbook->sheets) {
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
++$oldSheetId;
@@ -620,7 +751,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// Load sheet
$docSheet = $excel->createSheet();
- $docSheet->setTitle((string) $eleSheet["name"]);
+ // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet
+ // references in formula cells... during the load, all formulae should be correct,
+ // and we're simply bringing the worksheet name in line with the formula, not the
+ // reverse
+ $docSheet->setTitle((string) $eleSheet["name"],false);
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
@@ -639,6 +774,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']) );
}
+ if (isset($xmlSheet->sheetViews->sheetView['view'])) {
+ $docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']);
+ }
+
if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) {
$docSheet->setShowGridLines((string)$xmlSheet->sheetViews->sheetView['showGridLines'] ? true : false);
}
@@ -716,6 +855,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
$docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] );
}
+ if (isset($xmlSheet->sheetFormatPr['zeroHeight']) &&
+ ((string)$xmlSheet->sheetFormatPr['zeroHeight'] == '1')) {
+ $docSheet->getDefaultRowDimension()->setzeroHeight(true);
+ }
}
if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
@@ -787,7 +930,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$calculatedValue = null;
// Read cell?
- if (!is_null($this->getReadFilter())) {
+ if ($this->getReadFilter() !== NULL) {
$coordinates = PHPExcel_Cell::coordinateFromString($r);
if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) {
@@ -882,7 +1025,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
} else {
$cell->setValue($value);
}
- if (!is_null($calculatedValue)) {
+ if ($calculatedValue !== NULL) {
$cell->setCalculatedValue($calculatedValue);
}
@@ -962,12 +1105,111 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) {
- $docSheet->setAutoFilter((string) $xmlSheet->autoFilter["ref"]);
+ $autoFilter = $docSheet->getAutoFilter();
+ $autoFilter->setRange((string) $xmlSheet->autoFilter["ref"]);
+ foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) {
+ $column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]);
+ // Check for standard filters
+ if ($filterColumn->filters) {
+ $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER);
+ $filters = $filterColumn->filters;
+ if ((isset($filters["blank"])) && ($filters["blank"] == 1)) {
+ $column->createRule()->setRule(
+ NULL, // Operator is undefined, but always treated as EQUAL
+ ''
+ )
+ ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
+ }
+ // Standard filters are always an OR join, so no join rule needs to be set
+ // Entries can be either filter elements
+ foreach ($filters->filter as $filterRule) {
+ $column->createRule()->setRule(
+ NULL, // Operator is undefined, but always treated as EQUAL
+ (string) $filterRule["val"]
+ )
+ ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
+ }
+ // Or Date Group elements
+ foreach ($filters->dateGroupItem as $dateGroupItem) {
+ $column->createRule()->setRule(
+ NULL, // Operator is undefined, but always treated as EQUAL
+ array(
+ 'year' => (string) $dateGroupItem["year"],
+ 'month' => (string) $dateGroupItem["month"],
+ 'day' => (string) $dateGroupItem["day"],
+ 'hour' => (string) $dateGroupItem["hour"],
+ 'minute' => (string) $dateGroupItem["minute"],
+ 'second' => (string) $dateGroupItem["second"],
+ ),
+ (string) $dateGroupItem["dateTimeGrouping"]
+ )
+ ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP);
+ }
+ }
+ // Check for custom filters
+ if ($filterColumn->customFilters) {
+ $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER);
+ $customFilters = $filterColumn->customFilters;
+ // Custom filters can an AND or an OR join;
+ // and there should only ever be one or two entries
+ if ((isset($customFilters["and"])) && ($customFilters["and"] == 1)) {
+ $column->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND);
+ }
+ foreach ($customFilters->customFilter as $filterRule) {
+ $column->createRule()->setRule(
+ (string) $filterRule["operator"],
+ (string) $filterRule["val"]
+ )
+ ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
+ }
+ }
+ // Check for dynamic filters
+ if ($filterColumn->dynamicFilter) {
+ $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
+ // We should only ever have one dynamic filter
+ foreach ($filterColumn->dynamicFilter as $filterRule) {
+ $column->createRule()->setRule(
+ NULL, // Operator is undefined, but always treated as EQUAL
+ (string) $filterRule["val"],
+ (string) $filterRule["type"]
+ )
+ ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
+ if (isset($filterRule["val"])) {
+ $column->setAttribute('val',(string) $filterRule["val"]);
+ }
+ if (isset($filterRule["maxVal"])) {
+ $column->setAttribute('maxVal',(string) $filterRule["maxVal"]);
+ }
+ }
+ }
+ // Check for dynamic filters
+ if ($filterColumn->top10) {
+ $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER);
+ // We should only ever have one top10 filter
+ foreach ($filterColumn->top10 as $filterRule) {
+ $column->createRule()->setRule(
+ (((isset($filterRule["percent"])) && ($filterRule["percent"] == 1))
+ ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT
+ : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE
+ ),
+ (string) $filterRule["val"],
+ (((isset($filterRule["top"])) && ($filterRule["top"] == 1))
+ ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP
+ : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM
+ )
+ )
+ ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER);
+ }
+ }
+ }
}
if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) {
foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) {
- $docSheet->mergeCells((string) $mergeCell["ref"]);
+ $mergeRef = (string) $mergeCell["ref"];
+ if (strpos($mergeRef,':') !== FALSE) {
+ $docSheet->mergeCells((string) $mergeCell["ref"]);
+ }
}
}
@@ -1051,7 +1293,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) {
foreach ($xmlSheet->colBreaks->brk as $brk) {
if ($brk["man"]) {
- $docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex($brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN);
+ $docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex((string) $brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN);
}
}
}
@@ -1180,7 +1422,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$row = null;
$clientData = $shape->xpath('.//x:ClientData');
- if (is_array($clientData) && count($clientData) > 0) {
+ if (is_array($clientData) && !empty($clientData)) {
$clientData = $clientData[0];
if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) {
@@ -1192,9 +1434,9 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
- if (!is_null($column) && !is_null($row)) {
+ if (($column !== NULL) && ($row !== NULL)) {
// Set comment properties
- $comment = $docSheet->getCommentByColumnAndRow($column, $row + 1);
+ $comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1);
$comment->getFillColor()->setRGB( $fillColor );
// Parse style
@@ -1272,7 +1514,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
- // TODO: Make sure drawings and graph are loaded differently!
+// TODO: Autoshapes from twoCellAnchors!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
@@ -1291,6 +1533,12 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);
+ } elseif ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") {
+ if ($this->_includeCharts) {
+ $charts[self::dir_add($fileDrawing, $ele["Target"])] = array('id' => (string) $ele["Id"],
+ 'sheet' => $docSheet->getTitle()
+ );
+ }
}
}
}
@@ -1306,7 +1554,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
- $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));
+ $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false);
@@ -1326,6 +1574,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
}
$objDrawing->setWorksheet($docSheet);
+ } else {
+ // ? Can charts be positioned with a oneCellAnchor ?
+ $coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);
+ $offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);
+ $offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff);
+ $width = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx"));
+ $height = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy"));
}
}
}
@@ -1339,7 +1594,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
- $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1));
+ $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false);
@@ -1361,6 +1616,26 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
}
$objDrawing->setWorksheet($docSheet);
+ } elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
+ $fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
+ $fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
+ $fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
+ $toCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->to->col) . ($twoCellAnchor->to->row + 1);
+ $toOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->colOff);
+ $toOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->rowOff);
+ $graphic = $twoCellAnchor->graphicFrame->children("http://schemas.openxmlformats.org/drawingml/2006/main")->graphic;
+ $chartRef = $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart;
+ $thisChart = (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
+
+ $chartDetails[$docSheet->getTitle().'!'.$thisChart] =
+ array( 'fromCoordinate' => $fromCoordinate,
+ 'fromOffsetX' => $fromOffsetX,
+ 'fromOffsetY' => $fromOffsetY,
+ 'toCoordinate' => $toCoordinate,
+ 'toOffsetX' => $toOffsetX,
+ 'toOffsetY' => $toOffsetY,
+ 'worksheetTitle' => $docSheet->getTitle()
+ );
}
}
}
@@ -1382,7 +1657,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
// Valid range?
- if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') {
+ if (stripos((string)$definedName, '#REF!') !== FALSE || $extractedRange == '') {
continue;
}
@@ -1392,7 +1667,9 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
switch ((string)$definedName['name']) {
case '_xlnm._FilterDatabase':
- $docSheet->setAutoFilter($extractedRange);
+ if ((string)$definedName['hidden'] !== '1') {
+ $docSheet->getAutoFilter()->setRange($extractedRange);
+ }
break;
case '_xlnm.Print_Titles':
@@ -1495,7 +1772,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$extractedRange = isset($range[1]) ? $range[1] : $range[0];
}
- if (!is_null($locatedSheet)) {
+ if ($locatedSheet !== NULL) {
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) );
}
}
@@ -1511,8 +1788,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if (isset($mapSheetId[$activeTab]) && $mapSheetId[$activeTab] !== null) {
$excel->setActiveSheetIndex($mapSheetId[$activeTab]);
} else {
- if ($excel->getSheetCount() == 0)
- {
+ if ($excel->getSheetCount() == 0) {
$excel->createSheet();
}
$excel->setActiveSheetIndex(0);
@@ -1523,18 +1799,56 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
+
+ if (!$this->_readDataOnly) {
+ $contentTypes = simplexml_load_string($this->_getFromZipArchive($zip, "[Content_Types].xml"));
+ foreach ($contentTypes->Override as $contentType) {
+ switch ($contentType["ContentType"]) {
+ case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml":
+ if ($this->_includeCharts) {
+ $chartEntryRef = ltrim($contentType['PartName'],'/');
+ $chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef));
+ $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml'));
+
+// echo 'Chart ',$chartEntryRef,' ';
+// var_dump($charts[$chartEntryRef]);
+//
+ if (isset($charts[$chartEntryRef])) {
+ $chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id'];
+// echo 'Position Ref ',$chartPositionRef,' ';
+ if (isset($chartDetails[$chartPositionRef])) {
+// var_dump($chartDetails[$chartPositionRef]);
+
+ $excel->getSheetByName($charts[$chartEntryRef]['sheet'])->addChart($objChart);
+ $objChart->setWorksheet($excel->getSheetByName($charts[$chartEntryRef]['sheet']));
+ $objChart->setTopLeftPosition( $chartDetails[$chartPositionRef]['fromCoordinate'],
+ $chartDetails[$chartPositionRef]['fromOffsetX'],
+ $chartDetails[$chartPositionRef]['fromOffsetY']
+ );
+ $objChart->setBottomRightPosition( $chartDetails[$chartPositionRef]['toCoordinate'],
+ $chartDetails[$chartPositionRef]['toOffsetX'],
+ $chartDetails[$chartPositionRef]['toOffsetY']
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
$zip->close();
return $excel;
}
- private static function _readColor($color, $background=false) {
+
+ private static function _readColor($color, $background=FALSE) {
if (isset($color["rgb"])) {
return (string)$color["rgb"];
} else if (isset($color["indexed"])) {
- return PHPExcel_Style_Color::indexedColor($color["indexed"],$background)->getARGB();
+ return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB();
} else if (isset($color["theme"])) {
- if (!is_null(self::$_theme)) {
+ if (self::$_theme !== NULL) {
$returnColour = self::$_theme->getColourByIndex((int)$color["theme"]);
if (isset($color["tint"])) {
$tintAdjust = (float) $color["tint"];
@@ -1550,11 +1864,16 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
return 'FF000000';
}
+
private static function _readStyle($docStyle, $style) {
// format code
- if (isset($style->numFmt)) {
- $docStyle->getNumberFormat()->setFormatCode($style->numFmt);
- }
+// if (isset($style->numFmt)) {
+// if (isset($style->numFmt['formatCode'])) {
+// $docStyle->getNumberFormat()->setFormatCode((string) $style->numFmt['formatCode']);
+// } else {
+ $docStyle->getNumberFormat()->setFormatCode($style->numFmt);
+// }
+// }
// font
if (isset($style->font)) {
@@ -1677,6 +1996,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
+
private static function _readBorder($docBorder, $eleBorder) {
if (isset($eleBorder["style"])) {
$docBorder->setBorderStyle((string) $eleBorder["style"]);
@@ -1686,6 +2006,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
+
private function _parseRichText($is = null) {
$value = new PHPExcel_RichText();
@@ -1748,14 +2069,17 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
return $value;
}
+
private static function array_item($array, $key = 0) {
return (isset($array[$key]) ? $array[$key] : null);
}
+
private static function dir_add($base, $add) {
return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
}
+
private static function toCSSArray($style) {
$style = str_replace(array("\r","\n"), "", $style);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Chart.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Chart.php
new file mode 100644
index 00000000000..f4d38bdb44a
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Chart.php
@@ -0,0 +1,513 @@
+attributes();
+ if (isset($attributes[$name])) {
+ if ($format == 'string') {
+ return (string) $attributes[$name];
+ } elseif ($format == 'integer') {
+ return (integer) $attributes[$name];
+ } elseif ($format == 'boolean') {
+ return (boolean) ($attributes[$name] == '0') ? false : true;
+ } else {
+ return (float) $attributes[$name];
+ }
+ }
+ return null;
+ } // function _getAttribute()
+
+
+ private static function _readColor($color,$background=false) {
+ if (isset($color["rgb"])) {
+ return (string)$color["rgb"];
+ } else if (isset($color["indexed"])) {
+ return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB();
+ }
+ }
+
+
+ public static function readChart($chartElements,$chartName) {
+ $namespacesChartMeta = $chartElements->getNamespaces(true);
+ $chartElementsC = $chartElements->children($namespacesChartMeta['c']);
+
+ $XaxisLabel = $YaxisLabel = $legend = $title = NULL;
+ $dispBlanksAs = $plotVisOnly = NULL;
+
+ foreach($chartElementsC as $chartElementKey => $chartElement) {
+ switch ($chartElementKey) {
+ case "chart":
+ foreach($chartElement as $chartDetailsKey => $chartDetails) {
+ $chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
+ switch ($chartDetailsKey) {
+ case "plotArea":
+ $plotAreaLayout = $XaxisLable = $YaxisLable = null;
+ $plotSeries = $plotAttributes = array();
+ foreach($chartDetails as $chartDetailKey => $chartDetail) {
+ switch ($chartDetailKey) {
+ case "layout":
+ $plotAreaLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'plotArea');
+ break;
+ case "catAx":
+ if (isset($chartDetail->title)) {
+ $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
+ }
+ break;
+ case "dateAx":
+ if (isset($chartDetail->title)) {
+ $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
+ }
+ break;
+ case "valAx":
+ if (isset($chartDetail->title)) {
+ $YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
+ }
+ break;
+ case "barChart":
+ case "bar3DChart":
+ $barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
+ $plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotSer->setPlotDirection($barDirection);
+ $plotSeries[] = $plotSer;
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "lineChart":
+ case "line3DChart":
+ $plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "areaChart":
+ case "area3DChart":
+ $plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "doughnutChart":
+ case "pieChart":
+ case "pie3DChart":
+ $explosion = isset($chartDetail->ser->explosion);
+ $plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotSer->setPlotStyle($explosion);
+ $plotSeries[] = $plotSer;
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "scatterChart":
+ $scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
+ $plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotSer->setPlotStyle($scatterStyle);
+ $plotSeries[] = $plotSer;
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "bubbleChart":
+ $bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
+ $plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotSer->setPlotStyle($bubbleScale);
+ $plotSeries[] = $plotSer;
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "radarChart":
+ $radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
+ $plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotSer->setPlotStyle($radarStyle);
+ $plotSeries[] = $plotSer;
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "surfaceChart":
+ case "surface3DChart":
+ $wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
+ $plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotSer->setPlotStyle($wireFrame);
+ $plotSeries[] = $plotSer;
+ $plotAttributes = self::_readChartAttributes($chartDetail);
+ break;
+ case "stockChart":
+ $plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
+ $plotAttributes = self::_readChartAttributes($plotAreaLayout);
+ break;
+ }
+ }
+ if ($plotAreaLayout == NULL) {
+ $plotAreaLayout = new PHPExcel_Chart_Layout();
+ }
+ $plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries);
+ self::_setChartAttributes($plotAreaLayout,$plotAttributes);
+ break;
+ case "plotVisOnly":
+ $plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
+ break;
+ case "dispBlanksAs":
+ $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
+ break;
+ case "title":
+ $title = self::_chartTitle($chartDetails,$namespacesChartMeta,'title');
+ break;
+ case "legend":
+ $legendPos = 'r';
+ $legendLayout = null;
+ $legendOverlay = false;
+ foreach($chartDetails as $chartDetailKey => $chartDetail) {
+ switch ($chartDetailKey) {
+ case "legendPos":
+ $legendPos = self::_getAttribute($chartDetail, 'val', 'string');
+ break;
+ case "overlay":
+ $legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
+ break;
+ case "layout":
+ $legendLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'legend');
+ break;
+ }
+ }
+ $legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay);
+ break;
+ }
+ }
+ }
+ }
+ $chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel);
+
+ return $chart;
+ } // function readChart()
+
+
+ private static function _chartTitle($titleDetails,$namespacesChartMeta,$type) {
+ $caption = array();
+ $titleLayout = null;
+ foreach($titleDetails as $titleDetailKey => $chartDetail) {
+ switch ($titleDetailKey) {
+ case "tx":
+ $titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
+ foreach($titleDetails as $titleKey => $titleDetail) {
+ switch ($titleKey) {
+ case "p":
+ $titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
+ $caption[] = self::_parseRichText($titleDetailPart);
+ }
+ }
+ break;
+ case "layout":
+ $titleLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta);
+ break;
+ }
+ }
+
+ return new PHPExcel_Chart_Title($caption, $titleLayout);
+ } // function _chartTitle()
+
+
+ private static function _chartLayoutDetails($chartDetail,$namespacesChartMeta) {
+ if (!isset($chartDetail->manualLayout)) {
+ return null;
+ }
+ $details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
+ if (is_null($details)) {
+ return null;
+ }
+ $layout = array();
+ foreach($details as $detailKey => $detail) {
+// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL;
+ $layout[$detailKey] = self::_getAttribute($detail, 'val', 'string');
+ }
+ return new PHPExcel_Chart_Layout($layout);
+ } // function _chartLayoutDetails()
+
+
+ private static function _chartDataSeries($chartDetail,$namespacesChartMeta,$plotType) {
+ $multiSeriesType = NULL;
+ $smoothLine = false;
+ $seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
+
+ $seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
+ foreach($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
+ switch ($seriesDetailKey) {
+ case "grouping":
+ $multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
+ break;
+ case "ser":
+ $marker = NULL;
+ foreach($seriesDetails as $seriesKey => $seriesDetail) {
+ switch ($seriesKey) {
+ case "idx":
+ $seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer');
+ break;
+ case "order":
+ $seriesOrder = self::_getAttribute($seriesDetail, 'val', 'integer');
+ $plotOrder[$seriesIndex] = $seriesOrder;
+ break;
+ case "tx":
+ $seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
+ break;
+ case "marker":
+ $marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string');
+ break;
+ case "smooth":
+ $smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean');
+ break;
+ case "cat":
+ $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
+ break;
+ case "val":
+ $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
+ break;
+ case "xVal":
+ $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
+ break;
+ case "yVal":
+ $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
+ break;
+ }
+ }
+ }
+ }
+ return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine);
+ } // function _chartDataSeries()
+
+
+ private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) {
+ if (isset($seriesDetail->strRef)) {
+ $seriesSource = (string) $seriesDetail->strRef->f;
+ $seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
+
+ return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
+ } elseif (isset($seriesDetail->numRef)) {
+ $seriesSource = (string) $seriesDetail->numRef->f;
+ $seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
+
+ return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
+ } elseif (isset($seriesDetail->multiLvlStrRef)) {
+ $seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
+ $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s');
+ $seriesData['pointCount'] = count($seriesData['dataValues']);
+
+ return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
+ } elseif (isset($seriesDetail->multiLvlNumRef)) {
+ $seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
+ $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s');
+ $seriesData['pointCount'] = count($seriesData['dataValues']);
+
+ return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
+ }
+ return null;
+ } // function _chartDataSeriesValueSet()
+
+
+ private static function _chartDataSeriesValues($seriesValueSet,$dataType='n') {
+ $seriesVal = array();
+ $formatCode = '';
+ $pointCount = 0;
+
+ foreach($seriesValueSet as $seriesValueIdx => $seriesValue) {
+ switch ($seriesValueIdx) {
+ case 'ptCount':
+ $pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
+ break;
+ case 'formatCode':
+ $formatCode = (string) $seriesValue;
+ break;
+ case 'pt':
+ $pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
+ if ($dataType == 's') {
+ $seriesVal[$pointVal] = (string) $seriesValue->v;
+ } else {
+ $seriesVal[$pointVal] = (float) $seriesValue->v;
+ }
+ break;
+ }
+ }
+
+ return array( 'formatCode' => $formatCode,
+ 'pointCount' => $pointCount,
+ 'dataValues' => $seriesVal
+ );
+ } // function _chartDataSeriesValues()
+
+
+ private static function _chartDataSeriesValuesMultiLevel($seriesValueSet,$dataType='n') {
+ $seriesVal = array();
+ $formatCode = '';
+ $pointCount = 0;
+
+ foreach($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
+ foreach($seriesLevel as $seriesValueIdx => $seriesValue) {
+ switch ($seriesValueIdx) {
+ case 'ptCount':
+ $pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
+ break;
+ case 'formatCode':
+ $formatCode = (string) $seriesValue;
+ break;
+ case 'pt':
+ $pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
+ if ($dataType == 's') {
+ $seriesVal[$pointVal][] = (string) $seriesValue->v;
+ } else {
+ $seriesVal[$pointVal][] = (float) $seriesValue->v;
+ }
+ break;
+ }
+ }
+ }
+
+ return array( 'formatCode' => $formatCode,
+ 'pointCount' => $pointCount,
+ 'dataValues' => $seriesVal
+ );
+ } // function _chartDataSeriesValuesMultiLevel()
+
+ private static function _parseRichText($titleDetailPart = null) {
+ $value = new PHPExcel_RichText();
+
+ foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
+ if (isset($titleDetailElement->t)) {
+ $objText = $value->createTextRun( (string) $titleDetailElement->t );
+ }
+ if (isset($titleDetailElement->rPr)) {
+ if (isset($titleDetailElement->rPr->rFont["val"])) {
+ $objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
+ }
+
+ $fontSize = (self::_getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
+ if (!is_null($fontSize)) {
+ $objText->getFont()->setSize(floor($fontSize / 100));
+ }
+
+ $fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string'));
+ if (!is_null($fontColor)) {
+ $objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) );
+ }
+
+ $bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean');
+ if (!is_null($bold)) {
+ $objText->getFont()->setBold($bold);
+ }
+
+ $italic = self::_getAttribute($titleDetailElement->rPr, 'i', 'boolean');
+ if (!is_null($italic)) {
+ $objText->getFont()->setItalic($italic);
+ }
+
+ $baseline = self::_getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
+ if (!is_null($baseline)) {
+ if ($baseline > 0) {
+ $objText->getFont()->setSuperScript(true);
+ } elseif($baseline < 0) {
+ $objText->getFont()->setSubScript(true);
+ }
+ }
+
+ $underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string'));
+ if (!is_null($underscore)) {
+ if ($underscore == 'sng') {
+ $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
+ } elseif($underscore == 'dbl') {
+ $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
+ } else {
+ $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
+ }
+ }
+
+ $strikethrough = (self::_getAttribute($titleDetailElement->rPr, 's', 'string'));
+ if (!is_null($strikethrough)) {
+ if ($strikethrough == 'noStrike') {
+ $objText->getFont()->setStrikethrough(false);
+ } else {
+ $objText->getFont()->setStrikethrough(true);
+ }
+ }
+ }
+ }
+
+ return $value;
+ }
+
+ private static function _readChartAttributes($chartDetail) {
+ $plotAttributes = array();
+ if (isset($chartDetail->dLbls)) {
+ if (isset($chartDetail->dLbls->howLegendKey)) {
+ $plotAttributes['showLegendKey'] = self::_getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
+ }
+ if (isset($chartDetail->dLbls->showVal)) {
+ $plotAttributes['showVal'] = self::_getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
+ }
+ if (isset($chartDetail->dLbls->showCatName)) {
+ $plotAttributes['showCatName'] = self::_getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
+ }
+ if (isset($chartDetail->dLbls->showSerName)) {
+ $plotAttributes['showSerName'] = self::_getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
+ }
+ if (isset($chartDetail->dLbls->showPercent)) {
+ $plotAttributes['showPercent'] = self::_getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
+ }
+ if (isset($chartDetail->dLbls->showBubbleSize)) {
+ $plotAttributes['showBubbleSize'] = self::_getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
+ }
+ if (isset($chartDetail->dLbls->showLeaderLines)) {
+ $plotAttributes['showLeaderLines'] = self::_getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
+ }
+ }
+
+ return $plotAttributes;
+ }
+
+ private static function _setChartAttributes($plotArea,$plotAttributes)
+ {
+ foreach($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
+ switch($plotAttributeKey) {
+ case 'showLegendKey' :
+ $plotArea->setShowLegendKey($plotAttributeValue);
+ break;
+ case 'showVal' :
+ $plotArea->setShowVal($plotAttributeValue);
+ break;
+ case 'showCatName' :
+ $plotArea->setShowCatName($plotAttributeValue);
+ break;
+ case 'showSerName' :
+ $plotArea->setShowSerName($plotAttributeValue);
+ break;
+ case 'showPercent' :
+ $plotArea->setShowPercent($plotAttributeValue);
+ break;
+ case 'showBubbleSize' :
+ $plotArea->setShowBubbleSize($plotAttributeValue);
+ break;
+ case 'showLeaderLines' :
+ $plotArea->setShowLeaderLines($plotAttributeValue);
+ break;
+ }
+ }
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php
index 89e24ffea84..6b38fa79fb9 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel2007/Theme.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel2007
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2007_Theme
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php
index 227ba53a1a5..535654243c2 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
// Original file header of ParseXL (used as the base for this class):
@@ -67,13 +67,13 @@ if (!defined('PHPEXCEL_ROOT')) {
}
/**
- * PHPExcel_Reader_Excel5
+ * PHPExcel_Reader_Excel5
*
- * This class uses {@link http://sourceforge.net/projects/phpexcelreader/parseXL}
+ * This class uses {@link http://sourceforge.net/projects/phpexcelreader/parseXL}
*
- * @category PHPExcel
- * @package PHPExcel_Reader_Excel5
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @category PHPExcel
+ * @package PHPExcel_Reader_Excel5
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
{
@@ -158,20 +158,21 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
const XLS_Type_XFEXT = 0x087d;
const XLS_Type_UNKNOWN = 0xffff;
+
/**
- * Read data only?
- * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
+ * Read data only?
+ * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
- * @var boolean
+ * @var boolean
*/
private $_readDataOnly = false;
/**
- * Restrict which sheets should be loaded?
- * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
+ * Restrict which sheets should be loaded?
+ * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
*
- * @var array of string
+ * @var array of string
*/
private $_loadSheetsOnly = null;
@@ -403,25 +404,34 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
/**
- * Read data only?
+ * Create a new PHPExcel_Reader_Excel5 instance
+ */
+ public function __construct() {
+ $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
+ }
+
+
+ /**
+ * Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
- * @return boolean
+ * @return boolean
*/
public function getReadDataOnly()
{
return $this->_readDataOnly;
}
+
/**
- * Set read data only
+ * Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
- * @param boolean $pValue
+ * @param boolean $pValue
*
- * @return PHPExcel_Reader_Excel5
+ * @return PHPExcel_Reader_Excel5
*/
public function setReadDataOnly($pValue = false)
{
@@ -429,26 +439,28 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this;
}
+
/**
- * Get which sheets to load
+ * Get which sheets to load
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
* indicating that all worksheets in the workbook should be loaded.
*
- * @return mixed
+ * @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
}
+
/**
- * Set which sheets to load
+ * Set which sheets to load
*
- * @param mixed $value
+ * @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
- * @return PHPExcel_Reader_Excel5
+ * @return PHPExcel_Reader_Excel5
*/
public function setLoadSheetsOnly($value = null)
{
@@ -457,11 +469,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this;
}
+
/**
- * Set all sheets to load
+ * Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
- * @return PHPExcel_Reader_Excel5
+ * @return PHPExcel_Reader_Excel5
*/
public function setLoadAllSheets()
{
@@ -469,6 +482,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this;
}
+
/**
* Read filter
*
@@ -478,6 +492,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this->_readFilter;
}
+
/**
* Set read filter
*
@@ -489,18 +504,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this;
}
- /**
- * Create a new PHPExcel_Reader_Excel5 instance
- */
- public function __construct() {
- $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
- }
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
+ * @throws Exception
*/
public function canRead($pFilename)
{
@@ -522,6 +532,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
@@ -571,6 +582,100 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
+ /**
+ * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
+ *
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetInfo($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ $worksheetInfo = array();
+
+ // Read the OLE file
+ $this->_loadOLE($pFilename);
+
+ // total byte size of Excel data (workbook global substream + sheet substreams)
+ $this->_dataSize = strlen($this->_data);
+
+ // initialize
+ $this->_pos = 0;
+ $this->_sheets = array();
+
+ // Parse Workbook Global Substream
+ while ($this->_pos < $this->_dataSize) {
+ $code = self::_GetInt2d($this->_data, $this->_pos);
+
+ switch ($code) {
+ case self::XLS_Type_BOF: $this->_readBof(); break;
+ case self::XLS_Type_SHEET: $this->_readSheet(); break;
+ case self::XLS_Type_EOF: $this->_readDefault(); break 2;
+ default: $this->_readDefault(); break;
+ }
+ }
+
+ // Parse the individual sheets
+ foreach ($this->_sheets as $sheet) {
+
+ if ($sheet['sheetType'] != 0x00) {
+ // 0x00: Worksheet
+ // 0x02: Chart
+ // 0x06: Visual Basic module
+ continue;
+ }
+
+ $tmpInfo = array();
+ $tmpInfo['worksheetName'] = $sheet['name'];
+ $tmpInfo['lastColumnLetter'] = 'A';
+ $tmpInfo['lastColumnIndex'] = 0;
+ $tmpInfo['totalRows'] = 0;
+ $tmpInfo['totalColumns'] = 0;
+
+ $this->_pos = $sheet['offset'];
+
+ while ($this->_pos <= $this->_dataSize - 4) {
+ $code = self::_GetInt2d($this->_data, $this->_pos);
+
+ switch ($code) {
+ case self::XLS_Type_RK:
+ case self::XLS_Type_LABELSST:
+ case self::XLS_Type_NUMBER:
+ case self::XLS_Type_FORMULA:
+ case self::XLS_Type_BOOLERR:
+ case self::XLS_Type_LABEL:
+ $length = self::_GetInt2d($this->_data, $this->_pos + 2);
+ $recordData = substr($this->_data, $this->_pos + 4, $length);
+
+ // move stream pointer to next record
+ $this->_pos += 4 + $length;
+
+ $rowIndex = self::_GetInt2d($recordData, 0) + 1;
+ $columnIndex = self::_GetInt2d($recordData, 2);
+
+ $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
+ $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
+ break;
+ case self::XLS_Type_BOF: $this->_readBof(); break;
+ case self::XLS_Type_EOF: $this->_readDefault(); break 2;
+ default: $this->_readDefault(); break;
+ }
+ }
+
+ $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
+ $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
+
+ $worksheetInfo[] = $tmpInfo;
+ }
+
+ return $worksheetInfo;
+ }
+
+
/**
* Loads PHPExcel from file
*
@@ -727,7 +832,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// add sheet to PHPExcel object
$this->_phpSheet = $this->_phpExcel->createSheet();
- $this->_phpSheet->setTitle($sheet['name']);
+ // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
+ // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
+ // name in line with the formula, not the reverse
+ $this->_phpSheet->setTitle($sheet['name'],false);
$this->_phpSheet->setSheetState($sheet['sheetState']);
$this->_pos = $sheet['offset'];
@@ -836,101 +944,92 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// echo ' ';
// the first shape container never has a corresponding OBJ record, hence $n + 1
- $spContainer = $allSpContainers[$n + 1];
+ if (isset($allSpContainers[$n + 1]) && is_object($allSpContainers[$n + 1])) {
+ $spContainer = $allSpContainers[$n + 1];
- // we skip all spContainers that are a part of a group shape since we cannot yet handle those
- if ($spContainer->getNestingLevel() > 1) {
- continue;
- }
-
- // calculate the width and height of the shape
- list($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($spContainer->getStartCoordinates());
- list($endColumn, $endRow) = PHPExcel_Cell::coordinateFromString($spContainer->getEndCoordinates());
-
- $startOffsetX = $spContainer->getStartOffsetX();
- $startOffsetY = $spContainer->getStartOffsetY();
- $endOffsetX = $spContainer->getEndOffsetX();
- $endOffsetY = $spContainer->getEndOffsetY();
-
- $width = PHPExcel_Shared_Excel5::getDistanceX($this->_phpSheet, $startColumn, $startOffsetX, $endColumn, $endOffsetX);
- $height = PHPExcel_Shared_Excel5::getDistanceY($this->_phpSheet, $startRow, $startOffsetY, $endRow, $endOffsetY);
-
- // calculate offsetX and offsetY of the shape
- $offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024;
- $offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256;
-
- switch ($obj['otObjType']) {
-
- case 0x19:
- // Note
-// echo 'Cell Annotation Object ';
-// echo 'Object ID is ',$obj['idObjID'],' ';
-//
- if (isset($this->_cellNotes[$obj['idObjID']])) {
- $cellNote = $this->_cellNotes[$obj['idObjID']];
-
-// echo '_cellNotes[',$obj['idObjID'],']: ';
-// var_dump($cellNote);
-// echo ' ';
-//
- if (isset($this->_textObjects[$obj['idObjID']])) {
- $textObject = $this->_textObjects[$obj['idObjID']];
-// echo '_textObject: ';
-// var_dump($textObject);
-// echo ' ';
-//
- $this->_cellNotes[$obj['idObjID']]['objTextData'] = $textObject;
- $text = $textObject['text'];
- }
-// echo $text,' ';
- }
- break;
-
- case 0x08:
-// echo 'Picture Object ';
- // picture
-
- // get index to BSE entry (1-based)
- $BSEindex = $spContainer->getOPT(0x0104);
- $BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();
- $BSE = $BSECollection[$BSEindex - 1];
- $blipType = $BSE->getBlipType();
-
- // need check because some blip types are not supported by Escher reader such as EMF
- if ($blip = $BSE->getBlip()) {
- $ih = imagecreatefromstring($blip->getData());
- $drawing = new PHPExcel_Worksheet_MemoryDrawing();
- $drawing->setImageResource($ih);
-
- // width, height, offsetX, offsetY
- $drawing->setResizeProportional(false);
- $drawing->setWidth($width);
- $drawing->setHeight($height);
- $drawing->setOffsetX($offsetX);
- $drawing->setOffsetY($offsetY);
-
- switch ($blipType) {
- case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
- $drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
- $drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG);
- break;
-
- case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
- $drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
- $drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG);
- break;
- }
-
- $drawing->setWorksheet($this->_phpSheet);
- $drawing->setCoordinates($spContainer->getStartCoordinates());
+ // we skip all spContainers that are a part of a group shape since we cannot yet handle those
+ if ($spContainer->getNestingLevel() > 1) {
+ continue;
}
- break;
+ // calculate the width and height of the shape
+ list($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($spContainer->getStartCoordinates());
+ list($endColumn, $endRow) = PHPExcel_Cell::coordinateFromString($spContainer->getEndCoordinates());
- default:
- // other object type
- break;
+ $startOffsetX = $spContainer->getStartOffsetX();
+ $startOffsetY = $spContainer->getStartOffsetY();
+ $endOffsetX = $spContainer->getEndOffsetX();
+ $endOffsetY = $spContainer->getEndOffsetY();
+ $width = PHPExcel_Shared_Excel5::getDistanceX($this->_phpSheet, $startColumn, $startOffsetX, $endColumn, $endOffsetX);
+ $height = PHPExcel_Shared_Excel5::getDistanceY($this->_phpSheet, $startRow, $startOffsetY, $endRow, $endOffsetY);
+
+ // calculate offsetX and offsetY of the shape
+ $offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024;
+ $offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256;
+
+ switch ($obj['otObjType']) {
+ case 0x19:
+ // Note
+// echo 'Cell Annotation Object ';
+// echo 'Object ID is ',$obj['idObjID'],' ';
+//
+ if (isset($this->_cellNotes[$obj['idObjID']])) {
+ $cellNote = $this->_cellNotes[$obj['idObjID']];
+
+ if (isset($this->_textObjects[$obj['idObjID']])) {
+ $textObject = $this->_textObjects[$obj['idObjID']];
+ $this->_cellNotes[$obj['idObjID']]['objTextData'] = $textObject;
+ }
+ }
+ break;
+
+ case 0x08:
+// echo 'Picture Object ';
+ // picture
+
+ // get index to BSE entry (1-based)
+ $BSEindex = $spContainer->getOPT(0x0104);
+ $BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();
+ $BSE = $BSECollection[$BSEindex - 1];
+ $blipType = $BSE->getBlipType();
+
+ // need check because some blip types are not supported by Escher reader such as EMF
+ if ($blip = $BSE->getBlip()) {
+ $ih = imagecreatefromstring($blip->getData());
+ $drawing = new PHPExcel_Worksheet_MemoryDrawing();
+ $drawing->setImageResource($ih);
+
+ // width, height, offsetX, offsetY
+ $drawing->setResizeProportional(false);
+ $drawing->setWidth($width);
+ $drawing->setHeight($height);
+ $drawing->setOffsetX($offsetX);
+ $drawing->setOffsetY($offsetY);
+
+ switch ($blipType) {
+ case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
+ $drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
+ $drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG);
+ break;
+
+ case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
+ $drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
+ $drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG);
+ break;
+ }
+
+ $drawing->setWorksheet($this->_phpSheet);
+ $drawing->setCoordinates($spContainer->getStartCoordinates());
+ }
+
+ break;
+
+ default:
+ // other object type
+ break;
+
+ }
}
}
@@ -938,15 +1037,23 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
if ($this->_version == self::XLS_BIFF8) {
foreach ($this->_sharedFormulaParts as $cell => $baseCell) {
list($column, $row) = PHPExcel_Cell::coordinateFromString($cell);
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle()) ) {
$formula = $this->_getFormulaFromStructure($this->_sharedFormulas[$baseCell], $cell);
$this->_phpSheet->getCell($cell)->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
}
}
}
- if (count($this->_cellNotes) > 0) {
+ if (!empty($this->_cellNotes)) {
foreach($this->_cellNotes as $note => $noteDetails) {
+ if (!isset($noteDetails['objTextData'])) {
+ if (isset($this->_textObjects[$note])) {
+ $textObject = $this->_textObjects[$note];
+ $noteDetails['objTextData'] = $textObject;
+ } else {
+ $noteDetails['objTextData']['text'] = '';
+ }
+ }
// echo 'Cell annotation ',$note,' ';
// var_dump($noteDetails);
// echo ' ';
@@ -1038,16 +1145,21 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$explodes = explode('!', $definedName['formula']);
if (count($explodes) == 2) {
- if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
+ if (($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) ||
+ ($docSheet = $this->_phpExcel->getSheetByName(trim($explodes[0],"'")))) {
$extractedRange = $explodes[1];
$extractedRange = str_replace('$', '', $extractedRange);
$localOnly = ($definedName['scope'] == 0) ? false : true;
+
$scope = ($definedName['scope'] == 0) ?
null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']);
$this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope) );
}
+ } else {
+ // Named Value
+ // TODO Provide support for named values
}
}
}
@@ -1055,6 +1167,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this->_phpExcel;
}
+
/**
* Use OLE reader to extract the relevant data streams from the OLE file
*
@@ -1080,6 +1193,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// $this->_userDefinedProperties = $ole->getUserDefinedProperties();
}
+
/**
* Read summary information
*/
@@ -1239,6 +1353,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read additional document summary information
*/
@@ -1302,6 +1417,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$value = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
break;
+ case 0x0B: // Boolean
+ $value = self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
+ $value = ($value == 0 ? false : true);
+ break;
+
case 0x13: // 4 byte unsigned integer
// not needed yet, fix later if necessary
break;
@@ -1392,6 +1512,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record.
*/
@@ -1468,6 +1589,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
+
/**
* The TEXT Object record contains the text associated with a cell annotation.
*/
@@ -1507,6 +1629,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// echo ' ';
}
+
/**
* Read BOF
*/
@@ -1546,6 +1669,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* FILEPASS
*
@@ -1568,6 +1692,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
throw new Exception('Cannot read encrypted file');
}
+
/**
* CODEPAGE
*
@@ -1591,6 +1716,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_codepage = PHPExcel_Shared_CodePage::NumberToName($codepage);
}
+
/**
* DATEMODE
*
@@ -1618,6 +1744,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read a FONT record
*/
@@ -1704,6 +1831,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* FORMAT
*
@@ -1741,6 +1869,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* XF - Extended Format
*
@@ -2034,6 +2163,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
*
*/
@@ -2210,6 +2340,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
+
/**
* Read STYLE record
*/
@@ -2250,6 +2381,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read PALETTE record
*/
@@ -2273,6 +2405,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* SHEET
*
@@ -2324,6 +2457,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Read EXTERNALBOOK record
*/
@@ -2387,6 +2521,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read EXTERNNAME record.
*/
@@ -2421,6 +2556,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read EXTERNSHEET record
*/
@@ -2449,6 +2585,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* DEFINEDNAME
*
@@ -2511,6 +2648,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read MSODRAWINGGROUP record
*/
@@ -2525,6 +2663,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_drawingGroupData .= $recordData;
}
+
/**
* SST - Shared String Table
*
@@ -2716,6 +2855,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// _getSplicedRecordData() takes care of moving current position in data stream
}
+
/**
* Read PRINTGRIDLINES record
*/
@@ -2734,6 +2874,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read DEFAULTROWHEIGHT record
*/
@@ -2751,6 +2892,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
}
+
/**
* Read SHEETPR record
*/
@@ -2777,6 +2919,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_isFitToPages = (bool) ((0x0100 & self::_GetInt2d($recordData, 0)) >> 8);
}
+
/**
* Read HORIZONTALPAGEBREAKS record
*/
@@ -2805,6 +2948,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read VERTICALPAGEBREAKS record
*/
@@ -2832,6 +2976,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read HEADER record
*/
@@ -2859,6 +3004,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read FOOTER record
*/
@@ -2885,6 +3031,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read HCENTER record
*/
@@ -2904,6 +3051,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read VCENTER record
*/
@@ -2923,6 +3071,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read LEFTMARGIN record
*/
@@ -2940,6 +3089,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read RIGHTMARGIN record
*/
@@ -2957,6 +3107,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read TOPMARGIN record
*/
@@ -2974,6 +3125,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read BOTTOMMARGIN record
*/
@@ -2991,6 +3143,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read PAGESETUP record
*/
@@ -3047,6 +3200,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* PROTECT - Sheet protection (BIFF2 through BIFF8)
* if this record is omitted, then it also means no sheet protection
@@ -3070,6 +3224,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_phpSheet->getProtection()->setSheet((bool)$bool);
}
+
/**
* SCENPROTECT
*/
@@ -3093,6 +3248,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_phpSheet->getProtection()->setScenarios((bool)$bool);
}
+
/**
* OBJECTPROTECT
*/
@@ -3116,6 +3272,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_phpSheet->getProtection()->setObjects((bool)$bool);
}
+
/**
* PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8)
*/
@@ -3134,6 +3291,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read DEFCOLWIDTH record
*/
@@ -3152,6 +3310,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read COLINFO record
*/
@@ -3203,6 +3362,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* ROW
*
@@ -3231,15 +3391,15 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 6; size: 2;
- // bit: 14-0; mask: 0x7FFF; height of the row, in twips = 1/20 of a point
- $height = (0x7FFF & self::_GetInt2d($recordData, 6)) >> 0;
+ // bit: 14-0; mask: 0x7FFF; height of the row, in twips = 1/20 of a point
+ $height = (0x7FFF & self::_GetInt2d($recordData, 6)) >> 0;
- // bit: 15: mask: 0x8000; 0 = row has custom height; 1= row has default height
- $useDefaultHeight = (0x8000 & self::_GetInt2d($recordData, 6)) >> 15;
+ // bit: 15: mask: 0x8000; 0 = row has custom height; 1= row has default height
+ $useDefaultHeight = (0x8000 & self::_GetInt2d($recordData, 6)) >> 15;
- if (!$useDefaultHeight) {
- $this->_phpSheet->getRowDimension($r + 1)->setRowHeight($height / 20);
- }
+ if (!$useDefaultHeight) {
+ $this->_phpSheet->getRowDimension($r + 1)->setRowHeight($height / 20);
+ }
// offset: 8; size: 2; not used
@@ -3247,30 +3407,31 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 12; size: 4; option flags and default row formatting
- // bit: 2-0: mask: 0x00000007; outline level of the row
- $level = (0x00000007 & self::_GetInt4d($recordData, 12)) >> 0;
- $this->_phpSheet->getRowDimension($r + 1)->setOutlineLevel($level);
+ // bit: 2-0: mask: 0x00000007; outline level of the row
+ $level = (0x00000007 & self::_GetInt4d($recordData, 12)) >> 0;
+ $this->_phpSheet->getRowDimension($r + 1)->setOutlineLevel($level);
- // bit: 4; mask: 0x00000010; 1 = outline group start or ends here... and is collapsed
- $isCollapsed = (0x00000010 & self::_GetInt4d($recordData, 12)) >> 4;
- $this->_phpSheet->getRowDimension($r + 1)->setCollapsed($isCollapsed);
+ // bit: 4; mask: 0x00000010; 1 = outline group start or ends here... and is collapsed
+ $isCollapsed = (0x00000010 & self::_GetInt4d($recordData, 12)) >> 4;
+ $this->_phpSheet->getRowDimension($r + 1)->setCollapsed($isCollapsed);
- // bit: 5; mask: 0x00000020; 1 = row is hidden
- $isHidden = (0x00000020 & self::_GetInt4d($recordData, 12)) >> 5;
- $this->_phpSheet->getRowDimension($r + 1)->setVisible(!$isHidden);
+ // bit: 5; mask: 0x00000020; 1 = row is hidden
+ $isHidden = (0x00000020 & self::_GetInt4d($recordData, 12)) >> 5;
+ $this->_phpSheet->getRowDimension($r + 1)->setVisible(!$isHidden);
- // bit: 7; mask: 0x00000080; 1 = row has explicit format
- $hasExplicitFormat = (0x00000080 & self::_GetInt4d($recordData, 12)) >> 7;
+ // bit: 7; mask: 0x00000080; 1 = row has explicit format
+ $hasExplicitFormat = (0x00000080 & self::_GetInt4d($recordData, 12)) >> 7;
- // bit: 27-16; mask: 0x0FFF0000; only applies when hasExplicitFormat = 1; index to XF record
- $xfIndex = (0x0FFF0000 & self::_GetInt4d($recordData, 12)) >> 16;
+ // bit: 27-16; mask: 0x0FFF0000; only applies when hasExplicitFormat = 1; index to XF record
+ $xfIndex = (0x0FFF0000 & self::_GetInt4d($recordData, 12)) >> 16;
- if ($hasExplicitFormat) {
- $this->_phpSheet->getRowDimension($r + 1)->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
- }
+ if ($hasExplicitFormat) {
+ $this->_phpSheet->getRowDimension($r + 1)->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ }
}
}
+
/**
* Read RK record
* This record represents a cell that contains an RK value
@@ -3298,7 +3459,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
@@ -3317,6 +3478,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read LABELSST record
* This record represents a cell that contains a string. It
@@ -3342,7 +3504,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
@@ -3395,6 +3557,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read MULRK record
* This record represents a cell range containing RK value
@@ -3428,7 +3591,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($colFirst + $i);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: var; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, $offset);
@@ -3449,6 +3612,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read NUMBER record
* This record represents a cell that contains a
@@ -3473,7 +3637,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
@@ -3490,6 +3654,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read FORMULA record + perhaps a following STRING record if formula result is a string
* This record contains the token array and the result of a
@@ -3539,7 +3704,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
if ($isPartOfSharedFormula) {
// formula is added to this cell after the sheet has been read
@@ -3633,6 +3798,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read a SHAREDFMLA record. This function just stores the binary shared formula in the reader,
* which usually contains relative references.
@@ -3663,6 +3829,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
+
/**
* Read a STRING record from current stream position and advance the stream pointer to next record
* This record is used for storing result from FORMULA record when it is a string, and
@@ -3689,6 +3856,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $value;
}
+
/**
* Read BOOLERR record
* This record represents a Boolean value or error value
@@ -3713,7 +3881,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
@@ -3747,6 +3915,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read MULBLANK record
* This record represents a cell range of empty cells. All
@@ -3776,7 +3945,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($fc + $i);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
$xfIndex = self::_GetInt2d($recordData, 4 + 2 * $i);
$this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
@@ -3786,6 +3955,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 6; size 2; index to last column (not needed)
}
+
/**
* Read LABEL record
* This record represents a cell that contains a string. In
@@ -3812,7 +3982,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; XF index
$xfIndex = self::_GetInt2d($recordData, 4);
@@ -3835,6 +4005,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read BLANK record
*/
@@ -3854,7 +4025,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$columnString = PHPExcel_Cell::stringFromColumnIndex($col);
// Read cell?
- if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
+ if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; XF index
$xfIndex = self::_GetInt2d($recordData, 4);
@@ -3866,6 +4037,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
+
/**
* Read MSODRAWING record
*/
@@ -3880,6 +4052,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_drawingData .= $recordData;
}
+
/**
* Read OBJ record
*/
@@ -3924,6 +4097,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// echo ' ';
}
+
/**
* Read WINDOW2 record
*/
@@ -3959,6 +4133,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read SCL record
*/
@@ -3980,6 +4155,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_phpSheet->getSheetView()->setZoomScale($numerator * 100 / $denumerator);
}
+
/**
* Read PANE record
*/
@@ -4007,6 +4183,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read SELECTION record. There is one such record for each pane in the sheet.
*/
@@ -4057,10 +4234,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
private function _includeCellRangeFiltered($cellRangeAddress)
{
$includeCellRange = true;
- if (!is_null($this->getReadFilter())) {
+ if ($this->getReadFilter() !== NULL) {
$includeCellRange = false;
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($cellRangeAddress);
$rangeBoundaries[1][0]++;
@@ -4076,6 +4254,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $includeCellRange;
}
+
/**
* MERGEDCELLS
*
@@ -4096,13 +4275,15 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
$cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData);
foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) {
- if ($this->_includeCellRangeFiltered($cellRangeAddress)) {
+ if ((strpos($cellRangeAddress,':') !== FALSE) &&
+ ($this->_includeCellRangeFiltered($cellRangeAddress))) {
$this->_phpSheet->mergeCells($cellRangeAddress);
}
}
}
}
+
/**
* Read HYPERLINK record
*/
@@ -4278,6 +4459,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read DATAVALIDATIONS record
*/
@@ -4290,6 +4472,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_pos += 4 + $length;
}
+
/**
* Read DATAVALIDATION record
*/
@@ -4449,6 +4632,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
+
/**
* Read SHEETLAYOUT record. Stores sheet tab color information.
*/
@@ -4488,6 +4672,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read SHEETPROTECTION record (FEATHEADR)
*/
@@ -4586,6 +4771,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 21; size: 2; not used
}
+
/**
* Read RANGEPROTECTION record
* Reading of this record is based on Microsoft Office Excel 97-2000 Binary File Format Specification,
@@ -4648,6 +4834,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Read IMDATA record
*/
@@ -4728,6 +4915,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// _getSplicedRecordData() takes care of moving current position in data stream
}
+
/**
* Read a free CONTINUE record. Free CONTINUE record may be a camouflaged MSODRAWING record
* When MSODRAWING data on a sheet exceeds 8224 bytes, CONTINUE records are used instead. Undocumented.
@@ -4819,6 +5007,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
+
/**
* Convert formula structure into human readable Excel formula like 'A3+A5*5'
*
@@ -4857,6 +5046,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this->_getFormulaFromData($formulaData, $additionalData, $baseCell);
}
+
/**
* Take formula data and additional data for formula and return human readable formula
*
@@ -4883,6 +5073,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $formulaString;
}
+
/**
* Take array of tokens together with additional data for formula and return human readable formula
*
@@ -4894,7 +5085,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
private function _createFormulaFromTokens($tokens, $additionalData)
{
// empty formula?
- if (count($tokens) == 0) {
+ if (empty($tokens)) {
return '';
}
@@ -5046,6 +5237,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $formulaString;
}
+
/**
* Fetch next token from binary formula data
*
@@ -5611,6 +5803,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Reads a cell address in BIFF8 e.g. 'A2' or '$A$2'
* section 3.3.4
@@ -5640,6 +5833,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $column . $row;
}
+
/**
* Reads a cell address in BIFF8 for shared formulas. Uses positive and negative values for row and column
* to indicate offsets from a base cell
@@ -5683,6 +5877,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $column . $row;
}
+
/**
* Reads a cell range address in BIFF5 e.g. 'A2:B6' or 'A1'
* always fixed range
@@ -5721,6 +5916,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return "$fc$fr:$lc$lr";
}
+
/**
* Reads a cell range address in BIFF8 e.g. 'A2:B6' or 'A1'
* always fixed range
@@ -5759,6 +5955,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return "$fc$fr:$lc$lr";
}
+
/**
* Reads a cell range address in BIFF8 e.g. 'A2:B6' or '$A$2:$B$6'
* there are flags indicating whether column/row index is relative
@@ -5780,37 +5977,38 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 4; size: 2; index to first column or column offset + relative flags
- // bit: 7-0; mask 0x00FF; column index
- $fc = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($subData, 4));
+ // bit: 7-0; mask 0x00FF; column index
+ $fc = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($subData, 4));
- // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
- if (!(0x4000 & self::_GetInt2d($subData, 4))) {
- $fc = '$' . $fc;
- }
+ // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
+ if (!(0x4000 & self::_GetInt2d($subData, 4))) {
+ $fc = '$' . $fc;
+ }
- // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
- if (!(0x8000 & self::_GetInt2d($subData, 4))) {
- $fr = '$' . $fr;
- }
+ // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
+ if (!(0x8000 & self::_GetInt2d($subData, 4))) {
+ $fr = '$' . $fr;
+ }
// offset: 6; size: 2; index to last column or column offset + relative flags
- // bit: 7-0; mask 0x00FF; column index
- $lc = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($subData, 6));
+ // bit: 7-0; mask 0x00FF; column index
+ $lc = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($subData, 6));
- // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
- if (!(0x4000 & self::_GetInt2d($subData, 6))) {
- $lc = '$' . $lc;
- }
+ // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
+ if (!(0x4000 & self::_GetInt2d($subData, 6))) {
+ $lc = '$' . $lc;
+ }
- // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
- if (!(0x8000 & self::_GetInt2d($subData, 6))) {
- $lr = '$' . $lr;
- }
+ // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
+ if (!(0x8000 & self::_GetInt2d($subData, 6))) {
+ $lr = '$' . $lr;
+ }
return "$fc$fr:$lc$lr";
}
+
/**
* Reads a cell range address in BIFF8 for shared formulas. Uses positive and negative values for row and column
* to indicate offsets from a base cell
@@ -5836,63 +6034,64 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 4; size: 2; first column with relative/absolute flags
- // bit: 7-0; mask 0x00FF; column index
- $fcIndex = 0x00FF & self::_GetInt2d($subData, 4);
+ // bit: 7-0; mask 0x00FF; column index
+ $fcIndex = 0x00FF & self::_GetInt2d($subData, 4);
- // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
- if (!(0x4000 & self::_GetInt2d($subData, 4))) {
- // absolute column index
- $fc = PHPExcel_Cell::stringFromColumnIndex($fcIndex);
- $fc = '$' . $fc;
- } else {
- // column offset
- $fcIndex = ($fcIndex <= 127) ? $fcIndex : $fcIndex - 256;
- $fc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $fcIndex);
- }
+ // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
+ if (!(0x4000 & self::_GetInt2d($subData, 4))) {
+ // absolute column index
+ $fc = PHPExcel_Cell::stringFromColumnIndex($fcIndex);
+ $fc = '$' . $fc;
+ } else {
+ // column offset
+ $fcIndex = ($fcIndex <= 127) ? $fcIndex : $fcIndex - 256;
+ $fc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $fcIndex);
+ }
- // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
- if (!(0x8000 & self::_GetInt2d($subData, 4))) {
- // absolute row index
- $fr = $frIndex + 1;
- $fr = '$' . $fr;
- } else {
- // row offset
- $frIndex = ($frIndex <= 32767) ? $frIndex : $frIndex - 65536;
- $fr = $baseRow + $frIndex;
- }
+ // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
+ if (!(0x8000 & self::_GetInt2d($subData, 4))) {
+ // absolute row index
+ $fr = $frIndex + 1;
+ $fr = '$' . $fr;
+ } else {
+ // row offset
+ $frIndex = ($frIndex <= 32767) ? $frIndex : $frIndex - 65536;
+ $fr = $baseRow + $frIndex;
+ }
// offset: 6; size: 2; last column with relative/absolute flags
- // bit: 7-0; mask 0x00FF; column index
- $lcIndex = 0x00FF & self::_GetInt2d($subData, 6);
+ // bit: 7-0; mask 0x00FF; column index
+ $lcIndex = 0x00FF & self::_GetInt2d($subData, 6);
+ $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
+ $lc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $lcIndex);
+
+ // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
+ if (!(0x4000 & self::_GetInt2d($subData, 6))) {
+ // absolute column index
+ $lc = PHPExcel_Cell::stringFromColumnIndex($lcIndex);
+ $lc = '$' . $lc;
+ } else {
+ // column offset
$lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
$lc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $lcIndex);
+ }
- // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
- if (!(0x4000 & self::_GetInt2d($subData, 6))) {
- // absolute column index
- $lc = PHPExcel_Cell::stringFromColumnIndex($lcIndex);
- $lc = '$' . $lc;
- } else {
- // column offset
- $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
- $lc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $lcIndex);
- }
-
- // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
- if (!(0x8000 & self::_GetInt2d($subData, 6))) {
- // absolute row index
- $lr = $lrIndex + 1;
- $lr = '$' . $lr;
- } else {
- // row offset
- $lrIndex = ($lrIndex <= 32767) ? $lrIndex : $lrIndex - 65536;
- $lr = $baseRow + $lrIndex;
- }
+ // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
+ if (!(0x8000 & self::_GetInt2d($subData, 6))) {
+ // absolute row index
+ $lr = $lrIndex + 1;
+ $lr = '$' . $lr;
+ } else {
+ // row offset
+ $lrIndex = ($lrIndex <= 32767) ? $lrIndex : $lrIndex - 65536;
+ $lr = $baseRow + $lrIndex;
+ }
return "$fc$fr:$lc$lr";
}
+
/**
* Read BIFF8 cell range address list
* section 2.5.15
@@ -5920,6 +6119,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Read BIFF5 cell range address list
* section 2.5.15
@@ -5947,6 +6147,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Get a sheet range like Sheet1:Sheet3 from REF index
* Note: If there is only one sheet in the range, one gets e.g Sheet1
@@ -6004,6 +6205,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return false;
}
+
/**
* read BIFF8 constant value array from array data
* returns e.g. array('value' => '{1,2;3,4}', 'size' => 40}
@@ -6042,6 +6244,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* read BIFF8 constant value which may be 'Empty Value', 'Number', 'String Value', 'Boolean Value', 'Error Value'
* section 2.5.7
@@ -6092,6 +6295,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Extract RGB color
* OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.4
@@ -6116,6 +6320,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return array('rgb' => $rgb);
}
+
/**
* Read byte string (8-bit string length)
* OpenOffice documentation: 2.5.2
@@ -6137,6 +6342,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Read byte string (16-bit string length)
* OpenOffice documentation: 2.5.2
@@ -6159,6 +6365,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Extracts an Excel Unicode short string (8-bit string length)
* OpenOffice documentation: 2.5.3
@@ -6182,6 +6389,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $string;
}
+
/**
* Extracts an Excel Unicode long string (16-bit string length)
* OpenOffice documentation: 2.5.3
@@ -6205,6 +6413,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $string;
}
+
/**
* Read Unicode string with no string length field, but with known character count
* this function is under construction, needs to support rich text, and Asian phonetic settings
@@ -6240,6 +6449,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
);
}
+
/**
* Convert UTF-8 string to string surounded by double quotes. Used for explicit string tokens in formulas.
* Example: hello"world --> "hello""world"
@@ -6252,6 +6462,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return '"' . str_replace('"', '""', $value) . '"';
}
+
/**
* Reads first 8 bytes of a string and return IEEE 754 float
*
@@ -6275,18 +6486,18 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$value += $mantissalow2 / pow (2 , (52 - $exp));
if ($sign) {
- $value = -1 * $value;
+ $value *= -1;
}
return $value;
}
+
private static function _GetIEEE754($rknum)
{
if (($rknum & 0x02) != 0) {
$value = $rknum >> 2;
- }
- else {
+ } else {
// changes by mmp, info on IEEE754 encoding from
// research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html
// The RK format calls for using only the most significant 30 bits
@@ -6307,6 +6518,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $value;
}
+
/**
* Get UTF-8 string from (compressed or uncompressed) UTF-16 string
*
@@ -6323,6 +6535,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE');
}
+
/**
* Convert UTF-16 string in compressed notation to uncompressed form. Only used for BIFF8.
*
@@ -6340,6 +6553,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $uncompressedString;
}
+
/**
* Convert string to UTF-8. Only used for BIFF5.
*
@@ -6351,6 +6565,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage);
}
+
/**
* Read 16-bit unsigned integer
*
@@ -6360,9 +6575,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
*/
public static function _GetInt2d($data, $pos)
{
- return ord($data[$pos]) | (ord($data[$pos + 1]) << 8);
+ return ord($data[$pos]) | (ord($data[$pos+1]) << 8);
}
+
/**
* Read 32-bit signed integer
*
@@ -6382,9 +6598,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
} else {
$_ord_24 = ($_or_24 & 127) << 24;
}
- return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24;
+ return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24;
}
+
/**
* Read color
*
@@ -6442,6 +6659,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Get fill pattern from index
* OpenOffice documentation: 2.5.12
@@ -6475,6 +6693,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Map error code, e.g. '#N/A'
*
@@ -6495,6 +6714,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Map built-in color to RGB value
*
@@ -6518,6 +6738,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Map color array from BIFF5 built-in color index
*
@@ -6587,6 +6808,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
/**
* Map color array from BIFF8 built-in color index
*
@@ -6656,6 +6878,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+
private function _parseRichText($is = '') {
$value = new PHPExcel_RichText();
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php
index e1a25bb47ac..e167655ffd6 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Excel5/Escher.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel5_Escher
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php b/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php
index af0b5fe4643..5d82f22924f 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/Gnumeric.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -36,28 +36,28 @@ if (!defined('PHPEXCEL_ROOT')) {
}
/**
- * PHPExcel_Reader_Gnumeric
+ * PHPExcel_Reader_Gnumeric
*
- * @category PHPExcel
- * @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @category PHPExcel
+ * @package PHPExcel_Reader
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
{
/**
- * Read data only?
- * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
+ * Read data only?
+ * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
- * @var boolean
+ * @var boolean
*/
private $_readDataOnly = false;
/**
- * Restrict which sheets should be loaded?
- * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
+ * Restrict which sheets should be loaded?
+ * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
*
- * @var array of string
+ * @var array of string
*/
private $_loadSheetsOnly = null;
@@ -86,50 +86,62 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
/**
- * Read data only?
+ * Create a new PHPExcel_Reader_Gnumeric
+ */
+ public function __construct() {
+ $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
+ $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
+ }
+
+
+ /**
+ * Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
- * @return boolean
+ * @return boolean
*/
public function getReadDataOnly() {
return $this->_readDataOnly;
}
+
/**
- * Set read data only
+ * Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
- * @param boolean $pValue
+ * @param boolean $pValue
*
- * @return PHPExcel_Reader_Gnumeric
+ * @return PHPExcel_Reader_Gnumeric
*/
public function setReadDataOnly($pValue = false) {
$this->_readDataOnly = $pValue;
return $this;
}
+
/**
- * Get which sheets to load
- * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
- * indicating that all worksheets in the workbook should be loaded.
+ * Get which sheets to load
+ * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
+ * indicating that all worksheets in the workbook should be loaded.
*
- * @return mixed
+ * @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
}
+
/**
- * Set which sheets to load
+ * Set which sheets to load
*
- * @param mixed $value
+ * @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
- * @return PHPExcel_Reader_Gnumeric
+ * @return PHPExcel_Reader_Gnumeric
*/
public function setLoadSheetsOnly($value = null)
{
@@ -138,11 +150,12 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $this;
}
+
/**
- * Set all sheets to load
+ * Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
- * @return PHPExcel_Reader_Gnumeric
+ * @return PHPExcel_Reader_Gnumeric
*/
public function setLoadAllSheets()
{
@@ -150,6 +163,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $this;
}
+
/**
* Read filter
*
@@ -159,6 +173,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $this->_readFilter;
}
+
/**
* Set read filter
*
@@ -170,32 +185,26 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $this;
}
- /**
- * Create a new PHPExcel_Reader_Gnumeric
- */
- public function __construct() {
- $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
- $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
- }
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
+ * @throws Exception
*/
public function canRead($pFilename)
{
- // Check if gzlib functions are available
- if (!function_exists('gzread')) {
- return false;
- }
-
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
+ // Check if gzlib functions are available
+ if (!function_exists('gzread')) {
+ throw new Exception("gzlib library is not enabled");
+ }
+
// Read signature data (first 3 bytes)
$fh = fopen($pFilename, 'r');
$data = fread($fh, 2);
@@ -208,6 +217,70 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return true;
}
+
+ /**
+ * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
+ *
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetInfo($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ $gFileData = $this->_gzfileGetContents($pFilename);
+
+ $xml = simplexml_load_string($gFileData);
+ $namespacesMeta = $xml->getNamespaces(true);
+
+ $gnmXML = $xml->children($namespacesMeta['gnm']);
+
+ $worksheetInfo = array();
+
+ foreach ($gnmXML->Sheets->Sheet as $sheet) {
+ $tmpInfo = array();
+ $tmpInfo['worksheetName'] = (string) $sheet->Name;
+ $tmpInfo['lastColumnLetter'] = 'A';
+ $tmpInfo['lastColumnIndex'] = 0;
+ $tmpInfo['totalRows'] = 0;
+ $tmpInfo['totalColumns'] = 0;
+
+ foreach ($sheet->Cells->Cell as $cell) {
+ $cellAttributes = $cell->attributes();
+
+ $rowIndex = (int) $cellAttributes->Row + 1;
+ $columnIndex = (int) $cellAttributes->Col;
+
+ $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
+ $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
+ }
+
+ $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
+ $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
+
+ $worksheetInfo[] = $tmpInfo;
+ }
+
+ return $worksheetInfo;
+ }
+
+
+ private function _gzfileGetContents($filename) {
+ $file = @gzopen($filename, 'rb');
+ if ($file !== false) {
+ $data = '';
+ while (!gzeof($file)) {
+ $data .= gzread($file, 1024);
+ }
+ gzclose($file);
+ }
+ return $data;
+ }
+
+
/**
* Loads PHPExcel from file
*
@@ -224,17 +297,6 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
- private function _gzfileGetContents($filename) {
- $file = @gzopen($filename, 'rb');
- if ($file !== false) {
- $data = '';
- while (!gzeof($file)) {
- $data .= gzread($file, 1024);
- }
- gzclose($file);
- }
- return $data;
- }
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
@@ -414,7 +476,10 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
// Create new Worksheet
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID);
- $objPHPExcel->getActiveSheet()->setTitle($worksheetName);
+ // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
+ // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
+ // name in line with the formula, not the reverse
+ $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) {
if (isset($sheet->PrintInformation->Margins)) {
@@ -461,7 +526,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
$column = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
- if (!is_null($this->getReadFilter())) {
+ if ($this->getReadFilter() !== NULL) {
if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) {
continue;
}
@@ -536,16 +601,13 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
//
foreach($sheet->Styles->StyleRegion as $styleRegion) {
$styleAttributes = $styleRegion->attributes();
-// var_dump($styleAttributes);
-// echo ' ';
-
if (($styleAttributes['startRow'] <= $maxRow) &&
($styleAttributes['startCol'] <= $maxCol)) {
- $startColumn = PHPExcel_Cell::stringFromColumnIndex($styleAttributes['startCol']);
+ $startColumn = PHPExcel_Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
$startRow = $styleAttributes['startRow'] + 1;
- $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : $styleAttributes['endCol'];
+ $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol'];
$endColumn = PHPExcel_Cell::stringFromColumnIndex($endColumn);
$endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow'];
$endRow += 1;
@@ -808,7 +870,9 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
// Handle Merged Cells in this worksheet
if (isset($sheet->MergedRegions)) {
foreach($sheet->MergedRegions->Merge as $mergeCells) {
- $objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
+ if (strpos($mergeCells,':') !== FALSE) {
+ $objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
+ }
}
}
@@ -838,7 +902,9 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $objPHPExcel;
}
- private static function _parseBorderAttributes($borderAttributes) {
+
+ private static function _parseBorderAttributes($borderAttributes)
+ {
$styleArray = array();
if (isset($borderAttributes["Color"])) {
@@ -893,6 +959,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $styleArray;
}
+
private function _parseRichText($is = '') {
$value = new PHPExcel_RichText();
@@ -901,6 +968,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
return $value;
}
+
private static function _parseGnumericColour($gnmColour) {
list($gnmR,$gnmG,$gnmB) = explode(':',$gnmColour);
$gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/HTML.php b/htdocs/includes/phpexcel/PHPExcel/Reader/HTML.php
new file mode 100644
index 00000000000..d6068eaa4f4
--- /dev/null
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/HTML.php
@@ -0,0 +1,499 @@
+ array( 'font' => array( 'bold' => true,
+ 'size' => 24,
+ ),
+ ), // Bold, 24pt
+ 'h2' => array( 'font' => array( 'bold' => true,
+ 'size' => 18,
+ ),
+ ), // Bold, 18pt
+ 'h3' => array( 'font' => array( 'bold' => true,
+ 'size' => 13.5,
+ ),
+ ), // Bold, 13.5pt
+ 'h4' => array( 'font' => array( 'bold' => true,
+ 'size' => 12,
+ ),
+ ), // Bold, 12pt
+ 'h5' => array( 'font' => array( 'bold' => true,
+ 'size' => 10,
+ ),
+ ), // Bold, 10pt
+ 'h6' => array( 'font' => array( 'bold' => true,
+ 'size' => 7.5,
+ ),
+ ), // Bold, 7.5pt
+ 'a' => array( 'font' => array( 'underline' => true,
+ 'color' => array( 'argb' => PHPExcel_Style_Color::COLOR_BLUE,
+ ),
+ ),
+ ), // Blue underlined
+ 'hr' => array( 'borders' => array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => array( PHPExcel_Style_Color::COLOR_BLACK,
+ ),
+ ),
+ ),
+ ), // Bottom border
+ );
+
+ /**
+ * PHPExcel_Reader_IReadFilter instance
+ *
+ * @var PHPExcel_Reader_IReadFilter
+ */
+ private $_readFilter = null;
+
+
+ /**
+ * Create a new PHPExcel_Reader_HTML
+ */
+ public function __construct() {
+ $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
+ }
+
+ /**
+ * Can the current PHPExcel_Reader_IReader read the file?
+ *
+ * @param string $pFileName
+ * @return boolean
+ * @throws Exception
+ */
+ public function canRead($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ // Read sample data (first 2 KB will do)
+ $fh = fopen($pFilename, 'r');
+ $data = fread($fh, 2048);
+ fclose($fh);
+
+ return true;
+ }
+
+ /**
+ * Loads PHPExcel from file
+ *
+ * @param string $pFilename
+ * @return PHPExcel
+ * @throws Exception
+ */
+ public function load($pFilename)
+ {
+ // Create new PHPExcel
+ $objPHPExcel = new PHPExcel();
+
+ // Load into this instance
+ return $this->loadIntoExisting($pFilename, $objPHPExcel);
+ }
+
+ /**
+ * Read filter
+ *
+ * @return PHPExcel_Reader_IReadFilter
+ */
+ public function getReadFilter() {
+ return $this->_readFilter;
+ }
+
+ /**
+ * Set read filter
+ *
+ * @param PHPExcel_Reader_IReadFilter $pValue
+ */
+ public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
+ $this->_readFilter = $pValue;
+ return $this;
+ }
+
+ /**
+ * Set input encoding
+ *
+ * @param string $pValue Input encoding
+ */
+ public function setInputEncoding($pValue = 'ANSI')
+ {
+ $this->_inputEncoding = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get input encoding
+ *
+ * @return string
+ */
+ public function getInputEncoding()
+ {
+ return $this->_inputEncoding;
+ }
+
+ // Data Array used for testing only, should write to PHPExcel object on completion of tests
+ private $_dataArray = array();
+
+ private $_tableLevel = 0;
+ private $_nestedColumn = array('A');
+
+ private function _setTableStartColumn($column) {
+ if ($this->_tableLevel == 0)
+ $column = 'A';
+ ++$this->_tableLevel;
+ $this->_nestedColumn[$this->_tableLevel] = $column;
+
+ return $this->_nestedColumn[$this->_tableLevel];
+ }
+
+ private function _getTableStartColumn() {
+ return $this->_nestedColumn[$this->_tableLevel];
+ }
+
+ private function _releaseTableStartColumn() {
+ --$this->_tableLevel;
+ return array_pop($this->_nestedColumn);
+ }
+
+ private function _flushCell($sheet,$column,$row,&$cellContent) {
+ if (is_string($cellContent)) {
+ // Simple String content
+ if (trim($cellContent) > '') {
+ // Only actually write it if there's content in the string
+ echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , ' ';
+ // Write to worksheet to be done here...
+ // ... we return the cell so we can mess about with styles more easily
+ $cell = $sheet->setCellValue($column.$row,$cellContent,true);
+ $this->_dataArray[$row][$column] = $cellContent;
+ }
+ } else {
+ // We have a Rich Text run
+ // TODO
+ $this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
+ }
+ $cellContent = (string) '';
+ }
+
+ private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){
+ foreach($element->childNodes as $child){
+ if ($child instanceOf DOMText) {
+ $domText = preg_replace('/\s+/',' ',trim($child->nodeValue));
+ if (is_string($cellContent)) {
+ // simply append the text if the cell content is a plain text string
+ $cellContent .= $domText;
+ } else {
+ // but if we have a rich text run instead, we need to append it correctly
+ // TODO
+ }
+ } elseif($child instanceOf DOMElement) {
+ echo 'DOM ELEMENT: ' , strtoupper($child->nodeName) , ' ';
+
+ $attributeArray = array();
+ foreach($child->attributes as $attribute) {
+ echo 'ATTRIBUTE: ' , $attribute->name , ' => ' , $attribute->value , ' ';
+ $attributeArray[$attribute->name] = $attribute->value;
+ }
+
+ switch($child->nodeName) {
+ case 'meta' :
+ foreach($attributeArray as $attributeName => $attributeValue) {
+ switch($attributeName) {
+ case 'content':
+ // TODO
+ // Extract character set, so we can convert to UTF-8 if required
+ break;
+ }
+ }
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ break;
+ case 'title' :
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ $sheet->setTitle($cellContent);
+ $cellContent = '';
+ break;
+ case 'span' :
+ case 'div' :
+ case 'font' :
+ case 'i' :
+ case 'em' :
+ case 'strong':
+ case 'b' :
+ echo 'STYLING, SPAN OR DIV ';
+ if ($cellContent > '')
+ $cellContent .= ' ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ if ($cellContent > '')
+ $cellContent .= ' ';
+ echo 'END OF STYLING, SPAN OR DIV ';
+ break;
+ case 'hr' :
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ ++$row;
+ if (isset($this->_formats[$child->nodeName])) {
+ $sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
+ } else {
+ $cellContent = '----------';
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ }
+ ++$row;
+ case 'br' :
+ if ($this->_tableLevel > 0) {
+ // If we're inside a table, replace with a \n
+ $cellContent .= "\n";
+ } else {
+ // Otherwise flush our existing content and move the row cursor on
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ ++$row;
+ }
+ echo 'HARD LINE BREAK: ' , ' ';
+ break;
+ case 'a' :
+ echo 'START OF HYPERLINK: ' , ' ';
+ foreach($attributeArray as $attributeName => $attributeValue) {
+ switch($attributeName) {
+ case 'href':
+ echo 'Link to ' , $attributeValue , ' ';
+ $sheet->getCell($column.$row)->getHyperlink()->setUrl($attributeValue);
+ if (isset($this->_formats[$child->nodeName])) {
+ $sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
+ }
+ break;
+ }
+ }
+ $cellContent .= ' ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF HYPERLINK:' , ' ';
+ break;
+ case 'h1' :
+ case 'h2' :
+ case 'h3' :
+ case 'h4' :
+ case 'h5' :
+ case 'h6' :
+ case 'ol' :
+ case 'ul' :
+ case 'p' :
+ if ($this->_tableLevel > 0) {
+ // If we're inside a table, replace with a \n
+ $cellContent .= "\n";
+ echo 'LIST ENTRY: ' , ' ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF LIST ENTRY:' , ' ';
+ } else {
+ if ($cellContent > '') {
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ $row += 2;
+ }
+ echo 'START OF PARAGRAPH: ' , ' ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF PARAGRAPH:' , ' ';
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+
+ if (isset($this->_formats[$child->nodeName])) {
+ $sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
+ }
+
+ $row += 2;
+ $column = 'A';
+ }
+ break;
+ case 'li' :
+ if ($this->_tableLevel > 0) {
+ // If we're inside a table, replace with a \n
+ $cellContent .= "\n";
+ echo 'LIST ENTRY: ' , ' ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF LIST ENTRY:' , ' ';
+ } else {
+ if ($cellContent > '') {
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ }
+ ++$row;
+ echo 'LIST ENTRY: ' , ' ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF LIST ENTRY:' , ' ';
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ $column = 'A';
+ }
+ break;
+ case 'table' :
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ $column = $this->_setTableStartColumn($column);
+ echo 'START OF TABLE LEVEL ' , $this->_tableLevel , ' ';
+ if ($this->_tableLevel > 1)
+ --$row;
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF TABLE LEVEL ' , $this->_tableLevel , ' ';
+ $column = $this->_releaseTableStartColumn();
+ if ($this->_tableLevel > 1) {
+ ++$column;
+ } else {
+ ++$row;
+ }
+ break;
+ case 'thead' :
+ case 'tbody' :
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ break;
+ case 'tr' :
+ ++$row;
+ $column = $this->_getTableStartColumn();
+ $cellContent = '';
+ echo 'START OF TABLE ' , $this->_tableLevel , ' ROW ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF TABLE ' , $this->_tableLevel , ' ROW ';
+ break;
+ case 'th' :
+ case 'td' :
+ echo 'START OF TABLE ' , $this->_tableLevel , ' CELL ';
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ echo 'END OF TABLE ' , $this->_tableLevel , ' CELL ';
+ $this->_flushCell($sheet,$column,$row,$cellContent);
+ ++$column;
+ break;
+ case 'body' :
+ $row = 1;
+ $column = 'A';
+ $content = '';
+ $this->_tableLevel = 0;
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ break;
+ default:
+ $this->_processDomElement($child,$sheet,$row,$column,$cellContent);
+ }
+ }
+ }
+ }
+
+ /**
+ * Loads PHPExcel from file into PHPExcel instance
+ *
+ * @param string $pFilename
+ * @param PHPExcel $objPHPExcel
+ * @return PHPExcel
+ * @throws Exception
+ */
+ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ if (!is_file($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! The given file is not a regular file.");
+ }
+
+ // Create new PHPExcel
+ while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
+ $objPHPExcel->createSheet();
+ }
+ $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
+
+ // Create a new DOM object
+ $dom = new domDocument;
+ // Load the HTML file into the DOM object
+ $loaded = $dom->loadHTMLFile($pFilename);
+ if ($loaded === false) {
+ throw new Exception('Failed to load ',$pFilename,' as a DOM Document');
+ }
+
+ // Discard white space
+ $dom->preserveWhiteSpace = false;
+
+
+ $row = 0;
+ $column = 'A';
+ $content = '';
+ $this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content);
+
+ echo ' ';
+ var_dump($this->_dataArray);
+
+ // Return
+ return $objPHPExcel;
+ }
+
+ /**
+ * Get sheet index
+ *
+ * @return int
+ */
+ public function getSheetIndex() {
+ return $this->_sheetIndex;
+ }
+
+ /**
+ * Set sheet index
+ *
+ * @param int $pValue Sheet index
+ * @return PHPExcel_Reader_HTML
+ */
+ public function setSheetIndex($pValue = 0) {
+ $this->_sheetIndex = $pValue;
+ return $this;
+ }
+
+}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php b/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php
index d5b0cb9c2c2..50e92c8045a 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/IReadFilter.php
@@ -2,27 +2,27 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Reader_IReadFilter
{
@@ -42,6 +42,6 @@ interface PHPExcel_Reader_IReadFilter
* @param $row Row index
* @param $worksheetName Optional worksheet name
* @return boolean
- */
+ */
public function readCell($column, $row, $worksheetName = '');
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php b/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php
index d82260a31de..1c9884730b8 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/IReader.php
@@ -2,27 +2,27 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Reader_IReader
{
@@ -40,14 +40,14 @@ interface PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
- */
+ */
public function canRead($pFilename);
-
+
/**
* Loads PHPExcel from file
*
* @param string $pFileName
* @throws Exception
- */
+ */
public function load($pFilename);
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php b/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php
index 93a376bef77..22ad1173b4f 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/OOCalc.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -36,28 +36,28 @@ if (!defined('PHPEXCEL_ROOT')) {
}
/**
- * PHPExcel_Reader_OOCalc
+ * PHPExcel_Reader_OOCalc
*
- * @category PHPExcel
- * @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @category PHPExcel
+ * @package PHPExcel_Reader
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
{
/**
- * Read data only?
- * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
+ * Read data only?
+ * Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
- * @var boolean
+ * @var boolean
*/
private $_readDataOnly = false;
/**
- * Restrict which sheets should be loaded?
- * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
+ * Restrict which sheets should be loaded?
+ * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
*
- * @var array of string
+ * @var array of string
*/
private $_loadSheetsOnly = null;
@@ -77,50 +77,60 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
/**
- * Read data only?
+ * Create a new PHPExcel_Reader_OOCalc
+ */
+ public function __construct() {
+ $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
+ }
+
+
+ /**
+ * Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
- * @return boolean
+ * @return boolean
*/
public function getReadDataOnly() {
return $this->_readDataOnly;
}
+
/**
- * Set read data only
+ * Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
- * @param boolean $pValue
- *
- * @return PHPExcel_Reader_OOCalc
+ * @param boolean $pValue
+ * @return PHPExcel_Reader_OOCalc
*/
public function setReadDataOnly($pValue = false) {
$this->_readDataOnly = $pValue;
return $this;
}
+
/**
- * Get which sheets to load
+ * Get which sheets to load
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
* indicating that all worksheets in the workbook should be loaded.
*
- * @return mixed
+ * @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
}
+
/**
- * Set which sheets to load
+ * Set which sheets to load
*
- * @param mixed $value
+ * @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
- * @return PHPExcel_Reader_OOCalc
+ * @return PHPExcel_Reader_OOCalc
*/
public function setLoadSheetsOnly($value = null)
{
@@ -129,11 +139,12 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
return $this;
}
+
/**
- * Set all sheets to load
+ * Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
- * @return PHPExcel_Reader_OOCalc
+ * @return PHPExcel_Reader_OOCalc
*/
public function setLoadAllSheets()
{
@@ -141,6 +152,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
return $this;
}
+
/**
* Read filter
*
@@ -150,6 +162,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
return $this->_readFilter;
}
+
/**
* Set read filter
*
@@ -161,45 +174,47 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
return $this;
}
- /**
- * Create a new PHPExcel_Reader_OOCalc
- */
- public function __construct() {
- $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
- }
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
+ * @throws Exception
*/
public function canRead($pFilename)
{
- // Check if zip class exists
- if (!class_exists('ZipArchive')) {
- return false;
- }
-
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
+ // Check if zip class exists
+ if (!class_exists('ZipArchive',FALSE)) {
+ throw new Exception("ZipArchive library is not enabled");
+ }
+
// Load file
$zip = new ZipArchive;
if ($zip->open($pFilename) === true) {
// check if it is an OOXML archive
- $mimeType = $zip->getFromName("mimetype");
+ $stat = $zip->statName('mimetype');
+ if ($stat && ($stat['size'] <= 255)) {
+ $mimeType = $zip->getFromName($stat['name']);
+ } else {
+ $zip->close();
+ return FALSE;
+ }
$zip->close();
return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet');
}
- return false;
+ return FALSE;
}
+
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
@@ -252,6 +267,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
+
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) {
@@ -263,6 +279,79 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
return false;
}
+
+ /**
+ * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
+ *
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetInfo($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ $worksheetInfo = array();
+
+ $zip = new ZipArchive;
+ if ($zip->open($pFilename) === true) {
+
+ $xml = simplexml_load_string($zip->getFromName("content.xml"));
+ $namespacesContent = $xml->getNamespaces(true);
+
+ $workbook = $xml->children($namespacesContent['office']);
+ foreach($workbook->body->spreadsheet as $workbookData) {
+ $workbookData = $workbookData->children($namespacesContent['table']);
+ foreach($workbookData->table as $worksheetDataSet) {
+ $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
+ $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
+
+ $tmpInfo = array();
+ $tmpInfo['worksheetName'] = (string) $worksheetDataAttributes['name'];
+ $tmpInfo['lastColumnLetter'] = 'A';
+ $tmpInfo['lastColumnIndex'] = 0;
+ $tmpInfo['totalRows'] = 0;
+ $tmpInfo['totalColumns'] = 0;
+
+ $rowIndex = 0;
+ foreach ($worksheetData as $key => $rowData) {
+ switch ($key) {
+ case 'table-row' :
+ $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
+ $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
+ $rowDataTableAttributes['number-rows-repeated'] : 1;
+ $columnIndex = 0;
+
+ foreach ($rowData as $key => $cellData) {
+ $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
+ $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
+ $cellDataTableAttributes['number-columns-repeated'] : 1;
+ $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
+ if (isset($cellDataOfficeAttributes['value-type'])) {
+ $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex + $colRepeats - 1);
+ $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex + $rowRepeats);
+ }
+ $columnIndex += $colRepeats;
+ }
+ $rowIndex += $rowRepeats;
+ break;
+ }
+ }
+
+ $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
+ $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
+
+ $worksheetInfo[] = $tmpInfo;
+ }
+ }
+ }
+
+ return $worksheetInfo;
+ }
+
+
/**
* Loads PHPExcel from file into PHPExcel instance
*
@@ -396,7 +485,10 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
$objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheetDataAttributes['name'])) {
$worksheetName = (string) $worksheetDataAttributes['name'];
- $objPHPExcel->getActiveSheet()->setTitle($worksheetName);
+ // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
+ // formula cells... during the load, all formulae should be correct, and we're simply
+ // bringing the worksheet name in line with the formula, not the reverse
+ $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
}
$rowID = 1;
@@ -409,16 +501,21 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
break;
}
case 'table-row' :
+ $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
+ $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
+ $rowDataTableAttributes['number-rows-repeated'] : 1;
$columnID = 'A';
foreach($rowData as $key => $cellData) {
- if (!is_null($this->getReadFilter())) {
+ if ($this->getReadFilter() !== NULL) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue;
}
}
// echo ''.$columnID.$rowID.' ';
- $cellDataText = $cellData->children($namespacesContent['text']);
+ $cellDataText = (isset($namespacesContent['text'])) ?
+ $cellData->children($namespacesContent['text']) :
+ '';
$cellDataOffice = $cellData->children($namespacesContent['office']);
$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
@@ -456,11 +553,31 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
}
if (isset($cellDataText->p)) {
+ // Consolidate if there are multiple p records (maybe with spans as well)
+ $dataArray = array();
+ // Text can have multiple text:p and within those, multiple text:span.
+ // text:p newlines, but text:span does not.
+ // Also, here we assume there is no text data is span fields are specified, since
+ // we have no way of knowing proper positioning anyway.
+ foreach ($cellDataText->p as $pData) {
+ if (isset($pData->span)) {
+ // span sections do not newline, so we just create one large string here
+ $spanSection = "";
+ foreach ($pData->span as $spanData) {
+ $spanSection .= $spanData;
+ }
+ array_push($dataArray, $spanSection);
+ } else {
+ array_push($dataArray, $pData);
+ }
+ }
+ $allCellDataText = implode($dataArray, "\n");
+
// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].' ';
switch ($cellDataOfficeAttributes['value-type']) {
- case 'string' :
+ case 'string' :
$type = PHPExcel_Cell_DataType::TYPE_STRING;
- $dataValue = $cellDataText->p;
+ $dataValue = $allCellDataText;
if (isset($dataValue->a)) {
$dataValue = $dataValue->a;
$cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']);
@@ -469,13 +586,32 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
break;
case 'boolean' :
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
- $dataValue = ($cellDataText->p == 'TRUE') ? True : False;
+ $dataValue = ($allCellDataText == 'TRUE') ? True : False;
+ break;
+ case 'percentage' :
+ $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
+ $dataValue = (float) $cellDataOfficeAttributes['value'];
+ if (floor($dataValue) == $dataValue) {
+ $dataValue = (integer) $dataValue;
+ }
+ $formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00;
+ break;
+ case 'currency' :
+ $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
+ $dataValue = (float) $cellDataOfficeAttributes['value'];
+ if (floor($dataValue) == $dataValue) {
+ $dataValue = (integer) $dataValue;
+ }
+ $formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break;
case 'float' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
- $dataValue = (integer) $dataValue;
+ if ($dataValue = (integer) $dataValue)
+ $dataValue = (integer) $dataValue;
+ else
+ $dataValue = (float) $dataValue;
}
break;
case 'date' :
@@ -497,9 +633,12 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
break;
}
// echo 'Data value is '.$dataValue.' ';
-// if (!is_null($hyperlink)) {
+// if ($hyperlink !== NULL) {
// echo 'Hyperlink is '.$hyperlink.' ';
// }
+ } else {
+ $type = PHPExcel_Cell_DataType::TYPE_NULL;
+ $dataValue = NULL;
}
if ($hasCalculatedValue) {
@@ -522,42 +661,53 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
// echo 'Adjusted Formula: '.$cellDataFormula.' ';
}
- if (!is_null($type)) {
- $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
- if ($hasCalculatedValue) {
-// echo 'Forumla result is '.$dataValue.' ';
- $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue);
- }
- if (($cellDataOfficeAttributes['value-type'] == 'date') ||
- ($cellDataOfficeAttributes['value-type'] == 'time')) {
- $objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting);
- }
- if (!is_null($hyperlink)) {
- $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink);
+ $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
+ $cellDataTableAttributes['number-columns-repeated'] : 1;
+ if ($type !== NULL) {
+ for ($i = 0; $i < $colRepeats; ++$i) {
+ if ($i > 0) {
+ ++$columnID;
+ }
+ if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
+ for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
+ $rID = $rowID + $rowAdjust;
+ $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
+ if ($hasCalculatedValue) {
+// echo 'Forumla result is '.$dataValue.' ';
+ $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
+ }
+ if ($formatting !== NULL) {
+ $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
+ } else {
+ $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
+ }
+ if ($hyperlink !== NULL) {
+ $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
+ }
+ }
+ }
}
}
// Merged cells
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
- $columnTo = $columnID;
- if (isset($cellDataTableAttributes['number-columns-spanned'])) {
- $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
+ if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) {
+ $columnTo = $columnID;
+ if (isset($cellDataTableAttributes['number-columns-spanned'])) {
+ $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
+ }
+ $rowTo = $rowID;
+ if (isset($cellDataTableAttributes['number-rows-spanned'])) {
+ $rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1;
+ }
+ $cellRange = $columnID.$rowID.':'.$columnTo.$rowTo;
+ $objPHPExcel->getActiveSheet()->mergeCells($cellRange);
}
- $rowTo = $rowID;
- if (isset($cellDataTableAttributes['number-rows-spanned'])) {
- $rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1;
- }
- $cellRange = $columnID.$rowID.':'.$columnTo.$rowTo;
- $objPHPExcel->getActiveSheet()->mergeCells($cellRange);
}
- if (isset($cellDataTableAttributes['number-columns-repeated'])) {
-// echo 'Repeated '.$cellDataTableAttributes['number-columns-repeated'].' times ';
- $columnID = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-repeated'] - 2);
- }
++$columnID;
}
- ++$rowID;
+ $rowID += $rowRepeats;
break;
}
}
@@ -571,6 +721,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
return $objPHPExcel;
}
+
private function _parseRichText($is = '') {
$value = new PHPExcel_RichText();
diff --git a/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php b/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php
index 5c9830aae00..47d5703f56b 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Reader/SYLK.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -40,7 +40,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Reader
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
{
@@ -79,6 +79,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
*/
private $_readFilter = null;
+
/**
* Create a new PHPExcel_Reader_SYLK
*/
@@ -86,11 +87,13 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
+
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
+ * @throws Exception
*/
public function canRead($pFilename)
{
@@ -119,6 +122,123 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
return true;
}
+
+ /**
+ * Read filter
+ *
+ * @return PHPExcel_Reader_IReadFilter
+ */
+ public function getReadFilter() {
+ return $this->_readFilter;
+ }
+
+
+ /**
+ * Set read filter
+ *
+ * @param PHPExcel_Reader_IReadFilter $pValue
+ */
+ public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
+ $this->_readFilter = $pValue;
+ return $this;
+ }
+
+
+ /**
+ * Set input encoding
+ *
+ * @param string $pValue Input encoding
+ */
+ public function setInputEncoding($pValue = 'ANSI')
+ {
+ $this->_inputEncoding = $pValue;
+ return $this;
+ }
+
+
+ /**
+ * Get input encoding
+ *
+ * @return string
+ */
+ public function getInputEncoding()
+ {
+ return $this->_inputEncoding;
+ }
+
+
+ /**
+ * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
+ *
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetInfo($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ // Open file
+ $fileHandle = fopen($pFilename, 'r');
+ if ($fileHandle === false) {
+ throw new Exception("Could not open file " . $pFilename . " for reading.");
+ }
+
+ $worksheetInfo = array();
+ $worksheetInfo[0]['worksheetName'] = 'Worksheet';
+ $worksheetInfo[0]['lastColumnLetter'] = 'A';
+ $worksheetInfo[0]['lastColumnIndex'] = 0;
+ $worksheetInfo[0]['totalRows'] = 0;
+ $worksheetInfo[0]['totalColumns'] = 0;
+
+ // Loop through file
+ $rowData = array();
+
+ // loop through one row (line) at a time in the file
+ $rowIndex = 0;
+ while (($rowData = fgets($fileHandle)) !== FALSE) {
+ $columnIndex = 0;
+
+ // convert SYLK encoded $rowData to UTF-8
+ $rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
+
+ // explode each row at semicolons while taking into account that literal semicolon (;)
+ // is escaped like this (;;)
+ $rowData = explode("\t",str_replace('?',';',str_replace(';',"\t",str_replace(';;','?',rtrim($rowData)))));
+
+ $dataType = array_shift($rowData);
+ if ($dataType == 'C') {
+ // Read cell value data
+ foreach($rowData as $rowDatum) {
+ switch($rowDatum{0}) {
+ case 'C' :
+ case 'X' :
+ $columnIndex = substr($rowDatum,1) - 1;
+ break;
+ case 'R' :
+ case 'Y' :
+ $rowIndex = substr($rowDatum,1);
+ break;
+ }
+
+ $worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
+ $worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
+ }
+ }
+ }
+
+ $worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
+ $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
+
+ // Close file
+ fclose($fileHandle);
+
+ return $worksheetInfo;
+ }
+
+
/**
* Loads PHPExcel from file
*
@@ -135,45 +255,6 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
- /**
- * Read filter
- *
- * @return PHPExcel_Reader_IReadFilter
- */
- public function getReadFilter() {
- return $this->_readFilter;
- }
-
- /**
- * Set read filter
- *
- * @param PHPExcel_Reader_IReadFilter $pValue
- */
- public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
- $this->_readFilter = $pValue;
- return $this;
- }
-
- /**
- * Set input encoding
- *
- * @param string $pValue Input encoding
- */
- public function setInputEncoding($pValue = 'ANSI')
- {
- $this->_inputEncoding = $pValue;
- return $this;
- }
-
- /**
- * Get input encoding
- *
- * @return string
- */
- public function getInputEncoding()
- {
- return $this->_inputEncoding;
- }
/**
* Loads PHPExcel from file into PHPExcel instance
@@ -354,7 +435,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
}
- if ((count($styleData) > 0) && ($column > '') && ($row > '')) {
+ if ((!empty($styleData)) && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
}
@@ -392,6 +473,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
return $objPHPExcel;
}
+
/**
* Get sheet index
*
@@ -401,6 +483,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
return $this->_sheetIndex;
}
+
/**
* Set sheet index
*
diff --git a/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php b/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php
index 74a12d20aba..9113591297a 100644
--- a/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php
+++ b/htdocs/includes/phpexcel/PHPExcel/ReferenceHelper.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_ReferenceHelper
{
@@ -55,7 +55,7 @@ class PHPExcel_ReferenceHelper
* @return PHPExcel_ReferenceHelper
*/
public static function getInstance() {
- if (!isset(self::$_instance) || is_null(self::$_instance)) {
+ if (!isset(self::$_instance) || (self::$_instance === NULL)) {
self::$_instance = new PHPExcel_ReferenceHelper();
}
@@ -214,7 +214,7 @@ class PHPExcel_ReferenceHelper
// Update worksheet: column dimensions
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
- if (count($aColumnDimensions) > 0) {
+ if (!empty($aColumnDimensions)) {
foreach ($aColumnDimensions as $objColumnDimension) {
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
list($newReference) = PHPExcel_Cell::coordinateFromString($newReference);
@@ -228,7 +228,7 @@ class PHPExcel_ReferenceHelper
// Update worksheet: row dimensions
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
- if (count($aRowDimensions) > 0) {
+ if (!empty($aRowDimensions)) {
foreach ($aRowDimensions as $objRowDimension) {
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference);
@@ -312,8 +312,61 @@ class PHPExcel_ReferenceHelper
// Update worksheet: autofilter
- if ($pSheet->getAutoFilter() != '') {
- $pSheet->setAutoFilter( $this->updateCellReference($pSheet->getAutoFilter(), $pBefore, $pNumCols, $pNumRows) );
+ $autoFilter = $pSheet->getAutoFilter();
+ $autoFilterRange = $autoFilter->getRange();
+ if (!empty($autoFilterRange)) {
+ if ($pNumCols != 0) {
+ $autoFilterColumns = array_keys($autoFilter->getColumns());
+ if (count($autoFilterColumns) > 0) {
+ list($column,$row) = sscanf($pBefore,'%[A-Z]%d');
+ $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
+ list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
+ if ($columnIndex <= $rangeEnd[0]) {
+ if ($pNumCols < 0) {
+ // If we're actually deleting any columns that fall within the autofilter range,
+ // then we delete any rules for those columns
+ $deleteColumn = $columnIndex + $pNumCols - 1;
+ $deleteCount = abs($pNumCols);
+ for ($i = 1; $i <= $deleteCount; ++$i) {
+ if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) {
+ $autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn));
+ }
+ ++$deleteColumn;
+ }
+ }
+ $startCol = ($columnIndex > $rangeStart[0]) ? $columnIndex : $rangeStart[0];
+
+ // Shuffle columns in autofilter range
+ if ($pNumCols > 0) {
+ // For insert, we shuffle from end to beginning to avoid overwriting
+ $startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
+ $toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
+ $endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
+
+ $startColRef = $startCol;
+ $endColRef = $rangeEnd[0];
+ $toColRef = $rangeEnd[0]+$pNumCols;
+
+ do {
+ $autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1),PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
+ --$endColRef;
+ --$toColRef;
+ } while ($startColRef <= $endColRef);
+ } else {
+ // For delete, we shuffle from beginning to end to avoid overwriting
+ $startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
+ $toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
+ $endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
+ do {
+ $autoFilter->shiftColumn($startColID,$toColID);
+ ++$startColID;
+ ++$toColID;
+ } while ($startColID != $endColID);
+ }
+ }
+ }
+ }
+ $pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) );
}
@@ -530,7 +583,7 @@ class PHPExcel_ReferenceHelper
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
- if (!is_null($cell) && $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
+ if (($cell !== NULL) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) {
$formula = $cell->getValue();
if (strpos($formula, $oldName) !== false) {
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText.php b/htdocs/includes/phpexcel/PHPExcel/RichText.php
index 57d3ce4d190..17af169cdd6 100644
--- a/htdocs/includes/phpexcel/PHPExcel/RichText.php
+++ b/htdocs/includes/phpexcel/PHPExcel/RichText.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText implements PHPExcel_IComparable
{
@@ -54,7 +54,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$this->_richTextElements = array();
// Rich-Text string attached to cell?
- if (!is_null($pCell)) {
+ if ($pCell !== NULL) {
// Add cell text and style
if ($pCell->getValue() != "") {
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php b/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php
index e355f8bb20c..4c658637f62 100644
--- a/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php
+++ b/htdocs/includes/phpexcel/PHPExcel/RichText/ITextElement.php
@@ -18,9 +18,9 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -29,7 +29,7 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_RichText_ITextElement
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php b/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php
index 55b59270236..9e33786c195 100644
--- a/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php
+++ b/htdocs/includes/phpexcel/PHPExcel/RichText/Run.php
@@ -18,9 +18,9 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -29,7 +29,7 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php b/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php
index a9a2c05b1c6..5b9edd07ee4 100644
--- a/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php
+++ b/htdocs/includes/phpexcel/PHPExcel/RichText/TextElement.php
@@ -18,9 +18,9 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -29,7 +29,7 @@
*
* @category PHPExcel
* @package PHPExcel_RichText
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Settings.php b/htdocs/includes/phpexcel/PHPExcel/Settings.php
index f1967cd1a7b..6659b90e956 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Settings.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Settings.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Settings
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/** PHPExcel root directory */
@@ -38,56 +38,295 @@ if (!defined('PHPEXCEL_ROOT')) {
class PHPExcel_Settings
{
/** constants */
+ /** Available Zip library classes */
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
const ZIPARCHIVE = 'ZipArchive';
+ /** Optional Chart Rendering libraries */
+ const CHART_RENDERER_JPGRAPH = 'jpgraph';
+ /** Optional PDF Rendering libraries */
+ const PDF_RENDERER_TCPDF = 'tcPDF';
+ const PDF_RENDERER_DOMPDF = 'DomPDF';
+ const PDF_RENDERER_MPDF = 'mPDF';
+
+
+ private static $_chartRenderers = array(
+ self::CHART_RENDERER_JPGRAPH,
+ );
+
+ private static $_pdfRenderers = array(
+ self::PDF_RENDERER_TCPDF,
+ self::PDF_RENDERER_DOMPDF,
+ self::PDF_RENDERER_MPDF,
+ );
+
+
+ /**
+ * Name of the class used for Zip file management
+ * e.g.
+ * ZipArchive
+ *
+ * @var string
+ */
private static $_zipClass = self::ZIPARCHIVE;
/**
- * Set the Zip Class to use (PCLZip or ZipArchive)
+ * Name of the external Library used for rendering charts
+ * e.g.
+ * jpgraph
*
- * @param string $zipClass PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
+ * @var string
+ */
+ private static $_chartRendererName = NULL;
+
+ /**
+ * Directory Path to the external Library used for rendering charts
+ *
+ * @var string
+ */
+ private static $_chartRendererPath = NULL;
+
+
+ /**
+ * Name of the external Library used for rendering PDF files
+ * e.g.
+ * mPDF
+ *
+ * @var string
+ */
+ private static $_pdfRendererName = NULL;
+
+ /**
+ * Directory Path to the external Library used for rendering PDF files
+ *
+ * @var string
+ */
+ private static $_pdfRendererPath = NULL;
+
+
+ /**
+ * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
+ *
+ * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
+ * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
* @return boolean Success or failure
*/
public static function setZipClass($zipClass) {
- if (($zipClass == self::PCLZIP) ||
- ($zipClass == self::ZIPARCHIVE)) {
+ if (($zipClass === self::PCLZIP) ||
+ ($zipClass === self::ZIPARCHIVE)) {
self::$_zipClass = $zipClass;
- return True;
+ return TRUE;
}
- return False;
+ return FALSE;
} // function setZipClass()
/**
- * Return the Zip Class to use (PCLZip or ZipArchive)
+ * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
+ * for Zip file management
*
- * @return string Zip Class to use - PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
+ * @return string Name of the Zip handler Class that PHPExcel is configured to use
+ * for Zip file management
+ * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
*/
public static function getZipClass() {
return self::$_zipClass;
} // function getZipClass()
+ /**
+ * Return the name of the method that is currently configured for cell cacheing
+ *
+ * @return string Name of the cacheing method
+ */
public static function getCacheStorageMethod() {
- return PHPExcel_CachedObjectStorageFactory::$_cacheStorageMethod;
+ return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
} // function getCacheStorageMethod()
+ /**
+ * Return the name of the class that is currently being used for cell cacheing
+ *
+ * @return string Name of the class currently being used for cacheing
+ */
public static function getCacheStorageClass() {
- return PHPExcel_CachedObjectStorageFactory::$_cacheStorageClass;
+ return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
} // function getCacheStorageClass()
- public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array()) {
- return PHPExcel_CachedObjectStorageFactory::initialize($method,$arguments);
+ /**
+ * Set the method that should be used for cell cacheing
+ *
+ * @param string $method Name of the cacheing method
+ * @param array $arguments Optional configuration arguments for the cacheing method
+ * @return boolean Success or failure
+ */
+ public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
+ $arguments = array()) {
+ return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
} // function setCacheStorageMethod()
- public static function setLocale($locale){
+ /**
+ * Set the locale code to use for formula translations and any special formatting
+ *
+ * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
+ * @return boolean Success or failure
+ */
+ public static function setLocale($locale='en_us') {
return PHPExcel_Calculation::getInstance()->setLocale($locale);
} // function setLocale()
+
+ /**
+ * Set details of the external library that PHPExcel should use for rendering charts
+ *
+ * @param string $libraryName Internal reference name of the library
+ * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
+ * @param string $libraryBaseDir Directory path to the library's base folder
+ * @return boolean Success or failure
+ */
+ public static function setChartRenderer($libraryName, $libraryBaseDir) {
+ if (!self::setChartRendererName($libraryName))
+ return FALSE;
+ return self::setChartRendererPath($libraryBaseDir);
+ } // function setChartRenderer()
+
+
+ /**
+ * Identify to PHPExcel the external library to use for rendering charts
+ *
+ * @param string $libraryName Internal reference name of the library
+ * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
+ * @return boolean Success or failure
+ */
+ public static function setChartRendererName($libraryName) {
+ if (!in_array($libraryName,self::$_chartRenderers)) {
+ return FALSE;
+ }
+
+ self::$_chartRendererName = $libraryName;
+
+ return TRUE;
+ } // function setChartRendererName()
+
+
+ /**
+ * Tell PHPExcel where to find the external library to use for rendering charts
+ *
+ * @param string $libraryBaseDir Directory path to the library's base folder
+ * @return boolean Success or failure
+ */
+ public static function setChartRendererPath($libraryBaseDir) {
+ if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
+ return FALSE;
+ }
+ self::$_chartRendererPath = $libraryBaseDir;
+
+ return TRUE;
+ } // function setChartRendererPath()
+
+
+ /**
+ * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
+ *
+ * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
+ * currently configured to use
+ * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
+ */
+ public static function getChartRendererName() {
+ return self::$_chartRendererName;
+ } // function getChartRendererName()
+
+
+ /**
+ * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
+ *
+ * @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
+ * currently configured to use
+ */
+ public static function getChartRendererPath() {
+ return self::$_chartRendererPath;
+ } // function getChartRendererPath()
+
+
+ /**
+ * Set details of the external library that PHPExcel should use for rendering PDF files
+ *
+ * @param string $libraryName Internal reference name of the library
+ * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
+ * PHPExcel_Settings::PDF_RENDERER_DOMPDF
+ * or PHPExcel_Settings::PDF_RENDERER_MPDF
+ * @param string $libraryBaseDir Directory path to the library's base folder
+ * @return boolean Success or failure
+ */
+ public static function setPdfRenderer($libraryName, $libraryBaseDir) {
+ if (!self::setPdfRendererName($libraryName))
+ return FALSE;
+ return self::setPdfRendererPath($libraryBaseDir);
+ } // function setPdfRenderer()
+
+
+ /**
+ * Identify to PHPExcel the external library to use for rendering PDF files
+ *
+ * @param string $libraryName Internal reference name of the library
+ * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
+ * PHPExcel_Settings::PDF_RENDERER_DOMPDF
+ * or PHPExcel_Settings::PDF_RENDERER_MPDF
+ * @return boolean Success or failure
+ */
+ public static function setPdfRendererName($libraryName) {
+ if (!in_array($libraryName,self::$_pdfRenderers)) {
+ return FALSE;
+ }
+
+ self::$_pdfRendererName = $libraryName;
+
+ return TRUE;
+ } // function setPdfRendererName()
+
+
+ /**
+ * Tell PHPExcel where to find the external library to use for rendering PDF files
+ *
+ * @param string $libraryBaseDir Directory path to the library's base folder
+ * @return boolean Success or failure
+ */
+ public static function setPdfRendererPath($libraryBaseDir) {
+ if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
+ return FALSE;
+ }
+ self::$_pdfRendererPath = $libraryBaseDir;
+
+ return TRUE;
+ } // function setPdfRendererPath()
+
+
+ /**
+ * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
+ *
+ * @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
+ * currently configured to use
+ * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
+ * PHPExcel_Settings::PDF_RENDERER_DOMPDF
+ * or PHPExcel_Settings::PDF_RENDERER_MPDF
+ */
+ public static function getPdfRendererName() {
+ return self::$_pdfRendererName;
+ } // function getPdfRendererName()
+
+
+ /**
+ * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
+ *
+ * @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
+ * currently configured to use
+ */
+ public static function getPdfRendererPath() {
+ return self::$_pdfRendererPath;
+ } // function getPdfRendererPath()
+
}
\ No newline at end of file
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php b/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php
index 7c8854b860f..5660e116ce0 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/CodePage.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_CodePage
{
@@ -46,47 +46,53 @@ class PHPExcel_Shared_CodePage
public static function NumberToName($codePage = '1252')
{
switch ($codePage) {
- case 367: return 'ASCII'; break; // ASCII
- case 437: return 'CP437'; break; // OEM US
+ case 367: return 'ASCII'; break; // ASCII
+ case 437: return 'CP437'; break; // OEM US
case 720: throw new Exception('Code page 720 not supported.');
- break; // OEM Arabic
- case 737: return 'CP737'; break; // OEM Greek
- case 775: return 'CP775'; break; // OEM Baltic
- case 850: return 'CP850'; break; // OEM Latin I
- case 852: return 'CP852'; break; // OEM Latin II (Central European)
- case 855: return 'CP855'; break; // OEM Cyrillic
- case 857: return 'CP857'; break; // OEM Turkish
- case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro
- case 860: return 'CP860'; break; // OEM Portugese
- case 861: return 'CP861'; break; // OEM Icelandic
- case 862: return 'CP862'; break; // OEM Hebrew
- case 863: return 'CP863'; break; // OEM Canadian (French)
- case 864: return 'CP864'; break; // OEM Arabic
- case 865: return 'CP865'; break; // OEM Nordic
- case 866: return 'CP866'; break; // OEM Cyrillic (Russian)
- case 869: return 'CP869'; break; // OEM Greek (Modern)
- case 874: return 'CP874'; break; // ANSI Thai
- case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS
- case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK
- case 949: return 'CP949'; break; // ANSI Korean (Wansung)
- case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5
- case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8)
- case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
- case 1251: return 'CP1251'; break; // ANSI Cyrillic
- case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
- case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7)
- case 1253: return 'CP1253'; break; // ANSI Greek
- case 1254: return 'CP1254'; break; // ANSI Turkish
- case 1255: return 'CP1255'; break; // ANSI Hebrew
- case 1256: return 'CP1256'; break; // ANSI Arabic
- case 1257: return 'CP1257'; break; // ANSI Baltic
- case 1258: return 'CP1258'; break; // ANSI Vietnamese
- case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
- case 10000: return 'MAC'; break; // Apple Roman
- case 32768: return 'MAC'; break; // Apple Roman
+ break; // OEM Arabic
+ case 737: return 'CP737'; break; // OEM Greek
+ case 775: return 'CP775'; break; // OEM Baltic
+ case 850: return 'CP850'; break; // OEM Latin I
+ case 852: return 'CP852'; break; // OEM Latin II (Central European)
+ case 855: return 'CP855'; break; // OEM Cyrillic
+ case 857: return 'CP857'; break; // OEM Turkish
+ case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro
+ case 860: return 'CP860'; break; // OEM Portugese
+ case 861: return 'CP861'; break; // OEM Icelandic
+ case 862: return 'CP862'; break; // OEM Hebrew
+ case 863: return 'CP863'; break; // OEM Canadian (French)
+ case 864: return 'CP864'; break; // OEM Arabic
+ case 865: return 'CP865'; break; // OEM Nordic
+ case 866: return 'CP866'; break; // OEM Cyrillic (Russian)
+ case 869: return 'CP869'; break; // OEM Greek (Modern)
+ case 874: return 'CP874'; break; // ANSI Thai
+ case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS
+ case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK
+ case 949: return 'CP949'; break; // ANSI Korean (Wansung)
+ case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5
+ case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8)
+ case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
+ case 1251: return 'CP1251'; break; // ANSI Cyrillic
+ case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
+ case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7)
+ case 1253: return 'CP1253'; break; // ANSI Greek
+ case 1254: return 'CP1254'; break; // ANSI Turkish
+ case 1255: return 'CP1255'; break; // ANSI Hebrew
+ case 1256: return 'CP1256'; break; // ANSI Arabic
+ case 1257: return 'CP1257'; break; // ANSI Baltic
+ case 1258: return 'CP1258'; break; // ANSI Vietnamese
+ case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
+ case 10000: return 'MAC'; break; // Apple Roman
+ case 10006: return 'MACGREEK'; break; // Macintosh Greek
+ case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
+ case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
+ case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
+ case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
+ case 32768: return 'MAC'; break; // Apple Roman
case 32769: throw new Exception('Code page 32769 not supported.');
- break; // ANSI Latin I (BIFF2-BIFF3)
- case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
+ break; // ANSI Latin I (BIFF2-BIFF3)
+ case 65000: return 'UTF-7'; break; // Unicode (UTF-7)
+ case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
}
throw new Exception('Unknown codepage: ' . $codePage);
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php
index 16cf6a19ef4..2c1ab0088ba 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Date.php
@@ -3,7 +3,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,9 +21,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -32,7 +32,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Date
{
@@ -40,8 +40,41 @@ class PHPExcel_Shared_Date
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
+ /*
+ * Names of the months of the year, indexed by shortname
+ * Planned usage for locale settings
+ *
+ * @public
+ * @var string[]
+ */
+ public static $_monthNames = array( 'Jan' => 'January',
+ 'Feb' => 'February',
+ 'Mar' => 'March',
+ 'Apr' => 'April',
+ 'May' => 'May',
+ 'Jun' => 'June',
+ 'Jul' => 'July',
+ 'Aug' => 'August',
+ 'Sep' => 'September',
+ 'Oct' => 'October',
+ 'Nov' => 'November',
+ 'Dec' => 'December'
+ );
+
+ /*
+ * Base calendar year to use for calculations
+ *
+ * @private
+ * @var int
+ */
private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900;
+ /*
+ * Object type for PHP Date/Time values
+ *
+ * @private
+ * @var string
+ */
public static $dateTimeObjectType = 'DateTime';
@@ -55,9 +88,9 @@ class PHPExcel_Shared_Date
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)) {
self::$ExcelBaseDate = $baseDate;
- return True;
+ return TRUE;
}
- return False;
+ return FALSE;
} // function setExcelCalendar()
@@ -91,14 +124,14 @@ class PHPExcel_Shared_Date
// Perform conversion
if ($dateValue >= 1) {
$utcDays = $dateValue - $myExcelBaseDate;
- $returnValue = round($utcDays * 24 * 60 * 60);
+ $returnValue = round($utcDays * 86400);
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
$returnValue = (integer) $returnValue;
}
} else {
$hours = round($dateValue * 24);
- $mins = round($dateValue * 24 * 60) - round($hours * 60);
- $secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
+ $mins = round($dateValue * 1440) - round($hours * 60);
+ $secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
$returnValue = (integer) gmmktime($hours, $mins, $secs);
}
@@ -133,12 +166,12 @@ class PHPExcel_Shared_Date
*
* @param mixed $dateValue PHP serialized date/time or date object
* @return mixed Excel date/time value
- * or boolean False on failure
+ * or boolean FALSE on failure
*/
public static function PHPToExcel($dateValue = 0) {
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
- $retValue = False;
+ $retValue = FALSE;
if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
@@ -171,19 +204,19 @@ class PHPExcel_Shared_Date
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
// This affects every date following 28th February 1900
//
- $excel1900isLeapYear = True;
- if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = False; }
+ $excel1900isLeapYear = TRUE;
+ if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; }
$myExcelBaseDate = 2415020;
} else {
$myExcelBaseDate = 2416481;
- $excel1900isLeapYear = False;
+ $excel1900isLeapYear = FALSE;
}
// Julian base date Adjustment
if ($month > 2) {
- $month = $month - 3;
+ $month -= 3;
} else {
- $month = $month + 9;
+ $month += 9;
--$year;
}
@@ -205,7 +238,11 @@ class PHPExcel_Shared_Date
* @return boolean
*/
public static function isDateTime(PHPExcel_Cell $pCell) {
- return self::isDateTimeFormat($pCell->getParent()->getStyle($pCell->getCoordinate())->getNumberFormat());
+ return self::isDateTimeFormat(
+ $pCell->getParent()->getStyle(
+ $pCell->getCoordinate()
+ )->getNumberFormat()
+ );
} // function isDateTime()
@@ -220,7 +257,7 @@ class PHPExcel_Shared_Date
} // function isDateTimeFormat()
- private static $possibleDateFormatCharacters = 'ymdHs';
+ private static $possibleDateFormatCharacters = 'eymdHs';
/**
* Is a given number format code a date/time?
@@ -231,6 +268,10 @@ class PHPExcel_Shared_Date
public static function isDateTimeFormatCode($pFormatCode = '') {
// Switch on formatcode
switch ($pFormatCode) {
+ // General contains an epoch letter 'e', so we trap for it explicitly here
+ case PHPExcel_Style_NumberFormat::FORMAT_GENERAL:
+ return FALSE;
+ // Explicitly defined date formats
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
@@ -253,32 +294,32 @@ class PHPExcel_Shared_Date
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
- return true;
+ return TRUE;
}
// Typically number, currency or accounting (or occasionally fraction) formats
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
- return false;
+ return FALSE;
}
// Try checking for any of the date formatting characters that don't appear within square braces
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
// We might also have a format mask containing quoted strings...
// we don't want to test for any of our characters within the quoted blocks
- if (strpos($pFormatCode,'"') !== false) {
- $i = false;
+ if (strpos($pFormatCode,'"') !== FALSE) {
+ $i = FALSE;
foreach(explode('"',$pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks)
if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
- return true;
+ return TRUE;
}
}
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
// No date...
- return false;
+ return FALSE;
} // function isDateTimeFormatCode()
@@ -286,23 +327,23 @@ class PHPExcel_Shared_Date
* Convert a date/time string to Excel time
*
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
- * @return float|false Excel date/time serial value
+ * @return float|FALSE Excel date/time serial value
*/
public static function stringToExcel($dateValue = '') {
if (strlen($dateValue) < 2)
- return false;
+ return FALSE;
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue))
- return false;
+ return FALSE;
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
- return false;
+ return FALSE;
} else {
- if (strpos($dateValue, ':') !== false) {
+ if (strpos($dateValue, ':') !== FALSE) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
- return false;
+ return FALSE;
}
$dateValueNew += $timeValue;
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php
index 3367f272b6b..9401000dd8a 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Drawing.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Drawing
{
@@ -183,35 +183,35 @@ class PHPExcel_Shared_Drawing
$read = fread($file,10);
while(!feof($file)&&($read<>""))
$read .= fread($file,1024);
-
+
$temp = unpack("H*",$read);
$hex = $temp[1];
$header = substr($hex,0,108);
-
+
// Process the header
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
if (substr($header,0,4)=="424d")
{
// Cut it in parts of 2 bytes
$header_parts = str_split($header,2);
-
+
// Get the width 4 bytes
$width = hexdec($header_parts[19].$header_parts[18]);
-
+
// Get the height 4 bytes
$height = hexdec($header_parts[23].$header_parts[22]);
-
+
// Unset the header params
unset($header_parts);
}
-
+
// Define starting X and Y
$x = 0;
$y = 1;
-
+
// Create newimage
$image = imagecreatetruecolor($width,$height);
-
+
// Grab the body from the image
$body = substr($hex,108);
@@ -223,7 +223,7 @@ class PHPExcel_Shared_Drawing
// Use end-line padding? Only when needed
$usePadding = ($body_size>($header_size*3)+4);
-
+
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
// Calculate the next DWORD-position in the body
for ($i=0;$i<$body_size;$i+=3)
@@ -235,36 +235,36 @@ class PHPExcel_Shared_Drawing
// Shift i to the ending of the current 32-bit-block
if ($usePadding)
$i += $width%4;
-
+
// Reset horizontal position
$x = 0;
-
+
// Raise the height-position (bottom-up)
$y++;
-
+
// Reached the image-height? Break the for-loop
if ($y>$height)
break;
}
-
+
// Calculation of the RGB-pixel (defined as BGR in image-data)
// Define $i_pos as absolute position in the body
$i_pos = $i*2;
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
-
+
// Calculate and draw the pixel
$color = imagecolorallocate($image,$r,$g,$b);
imagesetpixel($image,$x,$height-$y,$color);
-
+
// Raise the horizontal position
$x++;
}
-
+
// Unset the body / free the memory
unset($body);
-
+
// Return image-object
return $image;
}
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php
index 55470960717..ecd8216aa4c 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php
index 7e17e464a35..adbe429dbbc 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DgContainer
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
index c11d7657126..ea0235e8bfa 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
index a3bd3cd65b1..cb4988c8494 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
{
@@ -55,6 +55,13 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
*/
private $_spType;
+ /**
+ * Shape flag
+ *
+ * @var int
+ */
+ private $_spFlag;
+
/**
* Shape index (usually group shape has index 0, and the rest: 1,2,3...)
*
@@ -171,6 +178,26 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
return $this->_spType;
}
+ /**
+ * Set the shape flag
+ *
+ * @param int $value
+ */
+ public function setSpFlag($value)
+ {
+ $this->_spFlag = $value;
+ }
+
+ /**
+ * Get the shape flag
+ *
+ * @return int
+ */
+ public function getSpFlag()
+ {
+ return $this->_spFlag;
+ }
+
/**
* Set the shape index
*
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php
index 39b57d02070..4fddbdf3fd6 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
index 8ac8f556abe..428c76e6a41 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
index 9b31bb5e2e0..1f10ae1767d 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php
index 4a6d4e4c4f2..0d28a6bf561 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php
index f6bced5034c..629f621c8e3 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Excel5.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
/**
@@ -30,7 +30,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Excel5
{
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/File.php b/htdocs/includes/phpexcel/PHPExcel/Shared/File.php
index 75532f6c78e..575ac3cd22c 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/File.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/File.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_File
{
@@ -80,7 +80,7 @@ class PHPExcel_Shared_File
}
// Found something?
- if ($returnValue == '' || is_null($returnValue)) {
+ if ($returnValue == '' || ($returnValue === NULL)) {
$pathArray = explode('/' , $pFilename);
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
for ($i = 0; $i < count($pathArray); ++$i) {
@@ -110,13 +110,13 @@ class PHPExcel_Shared_File
if ( !function_exists('sys_get_temp_dir')) {
if ($temp = getenv('TMP') ) {
- if (file_exists($temp)) { return realpath($temp); }
+ if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
}
if ($temp = getenv('TEMP') ) {
- if (file_exists($temp)) { return realpath($temp); }
+ if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
}
if ($temp = getenv('TMPDIR') ) {
- if (file_exists($temp)) { return realpath($temp); }
+ if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
}
// trick for creating a file in system's temporary dir
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php b/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php
index a0535688ac9..3d0662e8830 100644
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php
+++ b/htdocs/includes/phpexcel/PHPExcel/Shared/Font.php
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2011 PHPExcel
+ * Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.6, 2011-02-27
+ * @version 1.7.8, 2012-10-12
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Shared
- * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Font
{
@@ -39,6 +39,11 @@ class PHPExcel_Shared_Font
const AUTOSIZE_METHOD_APPROX = 'approx';
const AUTOSIZE_METHOD_EXACT = 'exact';
+ private static $_autoSizeMethods = array(
+ self::AUTOSIZE_METHOD_APPROX,
+ self::AUTOSIZE_METHOD_EXACT,
+ );
+
/** Character set codes used by BIFF5-8 in Font records */
const CHARSET_ANSI_LATIN = 0x00;
const CHARSET_SYSTEM_DEFAULT = 0x01;
@@ -47,8 +52,8 @@ class PHPExcel_Shared_Font
const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80;
const CHARSET_ANSI_KOREAN_HANGUL = 0x81;
const CHARSET_ANSI_KOREAN_JOHAB = 0x82;
- const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86;
- const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88;
+ const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86; // gb2312
+ const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88; // big5
const CHARSET_ANSI_GREEK = 0xA1;
const CHARSET_ANSI_TURKISH = 0xA2;
const CHARSET_ANSI_VIETNAMESE = 0xA3;
@@ -56,7 +61,7 @@ class PHPExcel_Shared_Font
const CHARSET_ANSI_ARABIC = 0xB2;
const CHARSET_ANSI_BALTIC = 0xBA;
const CHARSET_ANSI_CYRILLIC = 0xCC;
- const CHARSET_ANSI_THAI = 0xDE;
+ const CHARSET_ANSI_THAI = 0xDD;
const CHARSET_ANSI_LATIN_II = 0xEE;
const CHARSET_OEM_LATIN_I = 0xFF;
@@ -187,10 +192,17 @@ class PHPExcel_Shared_Font
* Set autoSize method
*
* @param string $pValue
+ * @return boolean Success or failure
*/
- public static function setAutoSizeMethod($pValue = 'approx')
+ public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX)
{
+ if (!in_array($pValue,self::$_autoSizeMethods)) {
+ return FALSE;
+ }
+
self::$autoSizeMethod = $pValue;
+
+ return TRUE;
}
/**
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/docs.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/docs.php
deleted file mode 100644
index d27a42f76ea..00000000000
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/docs.php
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/download.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/download.php
deleted file mode 100644
index 2df6e0c94e0..00000000000
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/download.php
+++ /dev/null
@@ -1,65 +0,0 @@
-create($files);
-
- // create the download url
- $webDir = substr($_SERVER['PHP_SELF'], 0, -18);
- $urlPath = "http://".$_SERVER['HTTP_HOST'].$webDir."/downloads";
-
- // redirect to download url
- header("Location: $urlPath/$tarName");
-
-}
-
-include_once "includes/header.php";
-include_once "includes/navbar.php";
-?>
-
-Download current version:
-
-
-
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/example.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/example.php
deleted file mode 100644
index d76c0f5f43a..00000000000
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/example.php
+++ /dev/null
@@ -1,166 +0,0 @@
-
-Magic Square Example
-
-The Jama distribution comes with a magic square example that is used to
-test and benchmark the LU, QR, SVD and symmetric Eig decompositions.
-The example outputs a multi-column table with these column headings:
-
-
-
-
- n
- Order of magic square.
-
-
- trace
- Diagonal sum, should be the magic sum, (n^3 + n)/2.
-
-
- max_eig
- Maximum eigenvalue of (A + A')/2, should equal trace.
-
-
- rank
- Linear algebraic rank, should equal n if n is odd, be less than n if n is even.
-
-
- cond
- L_2 condition number, ratio of singular values.
-
-
- lu_res
- test of LU factorization, norm1(L*U-A(p,:))/(n*eps).
-
-
- qr_res
- test of QR factorization, norm1(Q*R-A)/(n*eps).
-
-
-
-Running the Java-based version of the matix square example produces these results:
-
-
-
-
- n
- trace
- max_eig
- rank
- cond
- lu_res
- qr_res
-
-
- 3 15 15.000 3 4.330 0.000 11.333
-
-
- 4 34 34.000 3 Inf 0.000 13.500
-
- 5 65 65.000 5 5.462 0.000 14.400
-
-
- 6 111 111.000 5 Inf 5.333 16.000
-
-
- 7 175 175.000 7 7.111 2.286 37.714
-
-
- 8 260 260.000 3 Inf 0.000 59.000
-
-
- 9 369 369.000 9 9.102 7.111 53.333
-
-
- 10 505 505.000 7 Inf 3.200 159.200
-
-
- 11 671 671.000 11 11.102 2.909 215.273
-
-
- 12 870 870.000 3 Inf 0.000 185.333
-
-
- 13 1105 1105.000 13 13.060 4.923 313.846
-
-
- 14 1379 1379.000 9 Inf 4.571 540.571
-
-
- 15 1695 1695.000 15 15.062 4.267 242.133
-
-
- 16 2056 2056.000 3 Inf 0.000 488.500
-
-
- 17 2465 2465.000 17 17.042 7.529 267.294
-
-
- 18 2925 2925.000 11 Inf 7.111 520.889
-
-
- 19 3439 3439.000 19 19.048 16.842 387.368
-
-
- 20 4010 4010.000 3 Inf 14.400 584.800
-
-
- 21 4641 4641.000 21 21.035 6.095 1158.095
-
-
- 22 5335 5335.000 13 Inf 6.545 1132.364
-
-
- 23 6095 6095.000 23 23.037 11.130 1268.870
-
-
- 24 6924 6924.000 3 Inf 10.667 827.500
-
-
- 25 7825 7825.000 25 25.029 35.840 1190.400
-
-
- 26 8801 8801.000 15 Inf 4.923 1859.077
-
-
- 27 9855 9855.000 27 27.032 37.926 1365.333
-
-
- 28 10990 10990.000 3 Inf 34.286 1365.714
-
-
- 29 12209 12209.000 29 29.025 30.897 1647.448
-
-
- 30 13515 13515.000 17 Inf 8.533 2571.733
-
-
- 31 14911 14911.000 31 31.027 33.032 1426.581
-
-
- 32 16400 16400.000 3 Inf 0.000 1600.125
-
-
-Elapsed Time = 0.710 seconds
-
-
-The magic square example does not fare well when run as a PHP script . For a 32x32 matrix array
-it takes around a second to complete just the last row of computations in the above table.
-Hopefully this result will spur PHP developers to find optimizations and better attuned algorithms
-to speed things up. Matrix algebra is a great testing ground for ideas about time and memory
-performance optimation. Keep in perspective that PHP JAMA scripts are still plenty fast for use as
-a tool for learning about matrix algebra and quickly extending your knowledge with new scripts
-to apply knowledge.
-
-
-
-To learn more about the subject of magic squares you can visit the Drexel Math Forum on Magic Squares .
-You can also learn more by carefully examining the MagicSquareExample.php source code below.
-
-
-
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/includes/credits.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/includes/credits.php
deleted file mode 100644
index efc91c228c2..00000000000
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/includes/credits.php
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- Brought to you by:
-
-
-
diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/includes/footer.php b/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/includes/footer.php
deleted file mode 100644
index 7fb2bd61bf2..00000000000
--- a/htdocs/includes/phpexcel/PHPExcel/Shared/JAMA/docs/includes/footer.php
+++ /dev/null
@@ -1,2 +0,0 @@
-