diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php index 5a792217..e13b9358 100644 --- a/Classes/PHPExcel/Calculation.php +++ b/Classes/PHPExcel/Calculation.php @@ -270,1444 +270,1800 @@ class PHPExcel_Calculation ); // PHPExcel functions - private static $PHPExcelFunctions = array( // PHPExcel functions - 'ABS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'abs', - 'argumentCount' => '1' - ), - 'ACCRINT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::ACCRINT', - 'argumentCount' => '4-7' - ), - 'ACCRINTM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::ACCRINTM', - 'argumentCount' => '3-5' - ), - 'ACOS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'acos', - 'argumentCount' => '1' - ), - 'ACOSH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'acosh', - 'argumentCount' => '1' - ), - 'ADDRESS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::CELL_ADDRESS', - 'argumentCount' => '2-5' - ), - 'AMORDEGRC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::AMORDEGRC', - 'argumentCount' => '6,7' - ), - 'AMORLINC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::AMORLINC', - 'argumentCount' => '6,7' - ), - 'AND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, - 'functionCall' => 'PHPExcel_Calculation_Logical::LOGICAL_AND', - 'argumentCount' => '1+' - ), - 'AREAS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1' - ), - 'ASC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1' - ), - 'ASIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'asin', - 'argumentCount' => '1' - ), - 'ASINH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'asinh', - 'argumentCount' => '1' - ), - 'ATAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'atan', - 'argumentCount' => '1' - ), - 'ATAN2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::ATAN2', - 'argumentCount' => '2' - ), - 'ATANH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'atanh', - 'argumentCount' => '1' - ), - 'AVEDEV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::AVEDEV', - 'argumentCount' => '1+' - ), - 'AVERAGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::AVERAGE', - 'argumentCount' => '1+' - ), - 'AVERAGEA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::AVERAGEA', - 'argumentCount' => '1+' - ), - 'AVERAGEIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::AVERAGEIF', - 'argumentCount' => '2,3' - ), - 'AVERAGEIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '3+' - ), - 'BAHTTEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1' - ), - 'BESSELI' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELI', - 'argumentCount' => '2' - ), - 'BESSELJ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELJ', - 'argumentCount' => '2' - ), - 'BESSELK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELK', - 'argumentCount' => '2' - ), - 'BESSELY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELY', - 'argumentCount' => '2' - ), - 'BETADIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::BETADIST', - 'argumentCount' => '3-5' - ), - 'BETAINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::BETAINV', - 'argumentCount' => '3-5' - ), - 'BIN2DEC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::BINTODEC', - 'argumentCount' => '1' - ), - 'BIN2HEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::BINTOHEX', - 'argumentCount' => '1,2' - ), - 'BIN2OCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::BINTOOCT', - 'argumentCount' => '1,2' - ), - 'BINOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::BINOMDIST', - 'argumentCount' => '4' - ), - 'CEILING' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::CEILING', - 'argumentCount' => '2' - ), - 'CELL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1,2' - ), - 'CHAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::CHARACTER', - 'argumentCount' => '1' - ), - 'CHIDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::CHIDIST', - 'argumentCount' => '2' - ), - 'CHIINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::CHIINV', - 'argumentCount' => '2' - ), - 'CHITEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2' - ), - 'CHOOSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::CHOOSE', - 'argumentCount' => '2+' - ), - 'CLEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::TRIMNONPRINTABLE', - 'argumentCount' => '1' - ), - 'CODE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::ASCIICODE', - 'argumentCount' => '1' - ), - 'COLUMN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMN', - 'argumentCount' => '-1', - 'passByReference' => array(true) - ), - 'COLUMNS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMNS', - 'argumentCount' => '1' - ), - 'COMBIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::COMBIN', - 'argumentCount' => '2' - ), - 'COMPLEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::COMPLEX', - 'argumentCount' => '2,3' - ), - 'CONCATENATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::CONCATENATE', - 'argumentCount' => '1+' - ), - 'CONFIDENCE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::CONFIDENCE', - 'argumentCount' => '3' - ), - 'CONVERT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::CONVERTUOM', - 'argumentCount' => '3' - ), - 'CORREL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::CORREL', - 'argumentCount' => '2' - ), - 'COS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'cos', - 'argumentCount' => '1' - ), - 'COSH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'cosh', - 'argumentCount' => '1' - ), - 'COUNT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNT', - 'argumentCount' => '1+' - ), - 'COUNTA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNTA', - 'argumentCount' => '1+' - ), - 'COUNTBLANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNTBLANK', - 'argumentCount' => '1' - ), - 'COUNTIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNTIF', - 'argumentCount' => '2' - ), - 'COUNTIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2' - ), - 'COUPDAYBS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::COUPDAYBS', - 'argumentCount' => '3,4' - ), - 'COUPDAYS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::COUPDAYS', - 'argumentCount' => '3,4' - ), - 'COUPDAYSNC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::COUPDAYSNC', - 'argumentCount' => '3,4' - ), - 'COUPNCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::COUPNCD', - 'argumentCount' => '3,4' - ), - 'COUPNUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::COUPNUM', - 'argumentCount' => '3,4' - ), - 'COUPPCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::COUPPCD', - 'argumentCount' => '3,4' - ), - 'COVAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::COVAR', - 'argumentCount' => '2' - ), - 'CRITBINOM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::CRITBINOM', - 'argumentCount' => '3' - ), - 'CUBEKPIMEMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'CUBEMEMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'CUBEMEMBERPROPERTY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'CUBERANKEDMEMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'CUBESET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'CUBESETCOUNT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'CUBEVALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'CUMIPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::CUMIPMT', - 'argumentCount' => '6' - ), - 'CUMPRINC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::CUMPRINC', - 'argumentCount' => '6' - ), - 'DATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DATE', - 'argumentCount' => '3' - ), - 'DATEDIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DATEDIF', - 'argumentCount' => '2,3' - ), - 'DATEVALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DATEVALUE', - 'argumentCount' => '1' - ), - 'DAVERAGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DAVERAGE', - 'argumentCount' => '3' - ), - 'DAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DAYOFMONTH', - 'argumentCount' => '1' - ), - 'DAYS360' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DAYS360', - 'argumentCount' => '2,3' - ), - 'DB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::DB', - 'argumentCount' => '4,5' - ), - 'DCOUNT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DCOUNT', - 'argumentCount' => '3' - ), - 'DCOUNTA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DCOUNTA', - 'argumentCount' => '3' - ), - 'DDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::DDB', - 'argumentCount' => '4,5' - ), - 'DEC2BIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::DECTOBIN', - 'argumentCount' => '1,2' - ), - 'DEC2HEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::DECTOHEX', - 'argumentCount' => '1,2' - ), - 'DEC2OCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::DECTOOCT', - 'argumentCount' => '1,2' - ), - 'DEGREES' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'rad2deg', - 'argumentCount' => '1' - ), - 'DELTA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::DELTA', - 'argumentCount' => '1,2' - ), - 'DEVSQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::DEVSQ', - 'argumentCount' => '1+' - ), - 'DGET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DGET', - 'argumentCount' => '3' - ), - 'DISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::DISC', - 'argumentCount' => '4,5' - ), - 'DMAX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DMAX', - 'argumentCount' => '3' - ), - 'DMIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DMIN', - 'argumentCount' => '3' - ), - 'DOLLAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::DOLLAR', - 'argumentCount' => '1,2' - ), - 'DOLLARDE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::DOLLARDE', - 'argumentCount' => '2' - ), - 'DOLLARFR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::DOLLARFR', - 'argumentCount' => '2' - ), - 'DPRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DPRODUCT', - 'argumentCount' => '3' - ), - 'DSTDEV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DSTDEV', - 'argumentCount' => '3' - ), - 'DSTDEVP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DSTDEVP', - 'argumentCount' => '3' - ), - 'DSUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DSUM', - 'argumentCount' => '3' - ), - 'DURATION' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '5,6' - ), - 'DVAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DVAR', - 'argumentCount' => '3' - ), - 'DVARP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, - 'functionCall' => 'PHPExcel_Calculation_Database::DVARP', - 'argumentCount' => '3' - ), - 'EDATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::EDATE', - 'argumentCount' => '2' - ), - 'EFFECT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::EFFECT', - 'argumentCount' => '2' - ), - 'EOMONTH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::EOMONTH', - 'argumentCount' => '2' - ), - 'ERF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::ERF', - 'argumentCount' => '1,2' - ), - 'ERFC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::ERFC', - 'argumentCount' => '1' - ), - 'ERROR.TYPE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::ERROR_TYPE', - 'argumentCount' => '1' - ), - 'EVEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::EVEN', - 'argumentCount' => '1' - ), - 'EXACT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2' - ), - 'EXP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'exp', - 'argumentCount' => '1' - ), - 'EXPONDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::EXPONDIST', - 'argumentCount' => '3' - ), - 'FACT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::FACT', - 'argumentCount' => '1' - ), - 'FACTDOUBLE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::FACTDOUBLE', - 'argumentCount' => '1' - ), - 'FALSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, - 'functionCall' => 'PHPExcel_Calculation_Logical::FALSE', - 'argumentCount' => '0' - ), - 'FDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '3' - ), - 'FIND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHSENSITIVE', - 'argumentCount' => '2,3' - ), - 'FINDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHSENSITIVE', - 'argumentCount' => '2,3' - ), - 'FINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '3' - ), - 'FISHER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::FISHER', - 'argumentCount' => '1' - ), - 'FISHERINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::FISHERINV', - 'argumentCount' => '1' - ), - 'FIXED' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::FIXEDFORMAT', - 'argumentCount' => '1-3' - ), - 'FLOOR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::FLOOR', - 'argumentCount' => '2' - ), - 'FORECAST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::FORECAST', - 'argumentCount' => '3' - ), - 'FREQUENCY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2' - ), - 'FTEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2' - ), - 'FV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::FV', - 'argumentCount' => '3-5' - ), - 'FVSCHEDULE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::FVSCHEDULE', - 'argumentCount' => '2' - ), - 'GAMMADIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::GAMMADIST', - 'argumentCount' => '4' - ), - 'GAMMAINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::GAMMAINV', - 'argumentCount' => '3' - ), - 'GAMMALN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::GAMMALN', - 'argumentCount' => '1' - ), - 'GCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::GCD', - 'argumentCount' => '1+' - ), - 'GEOMEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::GEOMEAN', - 'argumentCount' => '1+' - ), - 'GESTEP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::GESTEP', - 'argumentCount' => '1,2' - ), - 'GETPIVOTDATA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2+' - ), - 'GROWTH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::GROWTH', - 'argumentCount' => '1-4' - ), - 'HARMEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::HARMEAN', - 'argumentCount' => '1+' - ), - 'HEX2BIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::HEXTOBIN', - 'argumentCount' => '1,2' - ), - 'HEX2DEC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::HEXTODEC', - 'argumentCount' => '1' - ), - 'HEX2OCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::HEXTOOCT', - 'argumentCount' => '1,2' - ), - 'HLOOKUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::HLOOKUP', - 'argumentCount' => '3,4' - ), - 'HOUR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::HOUROFDAY', - 'argumentCount' => '1' - ), - 'HYPERLINK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::HYPERLINK', - 'argumentCount' => '1,2', - 'passCellReference'=> true - ), - 'HYPGEOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::HYPGEOMDIST', - 'argumentCount' => '4' - ), - 'IF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, - 'functionCall' => 'PHPExcel_Calculation_Logical::STATEMENT_IF', - 'argumentCount' => '1-3' - ), - 'IFERROR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, - 'functionCall' => 'PHPExcel_Calculation_Logical::IFERROR', - 'argumentCount' => '2' - ), - 'IMABS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMABS', - 'argumentCount' => '1' - ), - 'IMAGINARY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMAGINARY', - 'argumentCount' => '1' - ), - 'IMARGUMENT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMARGUMENT', - 'argumentCount' => '1' - ), - 'IMCONJUGATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMCONJUGATE', - 'argumentCount' => '1' - ), - 'IMCOS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMCOS', - 'argumentCount' => '1' - ), - 'IMDIV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMDIV', - 'argumentCount' => '2' - ), - 'IMEXP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMEXP', - 'argumentCount' => '1' - ), - 'IMLN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMLN', - 'argumentCount' => '1' - ), - 'IMLOG10' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMLOG10', - 'argumentCount' => '1' - ), - 'IMLOG2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMLOG2', - 'argumentCount' => '1' - ), - 'IMPOWER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMPOWER', - 'argumentCount' => '2' - ), - 'IMPRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMPRODUCT', - 'argumentCount' => '1+' - ), - 'IMREAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMREAL', - 'argumentCount' => '1' - ), - 'IMSIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSIN', - 'argumentCount' => '1' - ), - 'IMSQRT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSQRT', - 'argumentCount' => '1' - ), - 'IMSUB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSUB', - 'argumentCount' => '2' - ), - 'IMSUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSUM', - 'argumentCount' => '1+' - ), - 'INDEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::INDEX', - 'argumentCount' => '1-4' - ), - 'INDIRECT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::INDIRECT', - 'argumentCount' => '1,2', - 'passCellReference'=> true - ), - 'INFO' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1' - ), - 'INT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::INT', - 'argumentCount' => '1' - ), - 'INTERCEPT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::INTERCEPT', - 'argumentCount' => '2' - ), - 'INTRATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::INTRATE', - 'argumentCount' => '4,5' - ), - 'IPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::IPMT', - 'argumentCount' => '4-6' - ), - 'IRR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::IRR', - 'argumentCount' => '1,2' - ), - 'ISBLANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_BLANK', - 'argumentCount' => '1' - ), - 'ISERR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ERR', - 'argumentCount' => '1' - ), - 'ISERROR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ERROR', - 'argumentCount' => '1' - ), - 'ISEVEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_EVEN', - 'argumentCount' => '1' - ), - 'ISLOGICAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_LOGICAL', - 'argumentCount' => '1' - ), - 'ISNA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NA', - 'argumentCount' => '1' - ), - 'ISNONTEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NONTEXT', - 'argumentCount' => '1' - ), - 'ISNUMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NUMBER', - 'argumentCount' => '1' - ), - 'ISODD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ODD', - 'argumentCount' => '1' - ), - 'ISPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::ISPMT', - 'argumentCount' => '4' - ), - 'ISREF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1' - ), - 'ISTEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::IS_TEXT', - 'argumentCount' => '1' - ), - 'JIS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1' - ), - 'KURT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::KURT', - 'argumentCount' => '1+' - ), - 'LARGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::LARGE', - 'argumentCount' => '2' - ), - 'LCM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::LCM', - 'argumentCount' => '1+' - ), - 'LEFT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::LEFT', - 'argumentCount' => '1,2' - ), - 'LEFTB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::LEFT', - 'argumentCount' => '1,2' - ), - 'LEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::STRINGLENGTH', - 'argumentCount' => '1' - ), - 'LENB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::STRINGLENGTH', - 'argumentCount' => '1' - ), - 'LINEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::LINEST', - 'argumentCount' => '1-4' - ), - 'LN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'log', - 'argumentCount' => '1' - ), - 'LOG' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::LOG_BASE', - 'argumentCount' => '1,2' - ), - 'LOG10' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'log10', - 'argumentCount' => '1' - ), - 'LOGEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::LOGEST', - 'argumentCount' => '1-4' - ), - 'LOGINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::LOGINV', - 'argumentCount' => '3' - ), - 'LOGNORMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::LOGNORMDIST', - 'argumentCount' => '3' - ), - 'LOOKUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::LOOKUP', - 'argumentCount' => '2,3' - ), - 'LOWER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::LOWERCASE', - 'argumentCount' => '1' - ), - 'MATCH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::MATCH', - 'argumentCount' => '2,3' - ), - 'MAX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MAX', - 'argumentCount' => '1+' - ), - 'MAXA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MAXA', - 'argumentCount' => '1+' - ), - 'MAXIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MAXIF', - 'argumentCount' => '2+' - ), - 'MDETERM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::MDETERM', - 'argumentCount' => '1' - ), - 'MDURATION' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '5,6' - ), - 'MEDIAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MEDIAN', - 'argumentCount' => '1+' - ), - 'MEDIANIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2+' - ), - 'MID' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::MID', - 'argumentCount' => '3' - ), - 'MIDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::MID', - 'argumentCount' => '3' - ), - 'MIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MIN', - 'argumentCount' => '1+' - ), - 'MINA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MINA', - 'argumentCount' => '1+' - ), - 'MINIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MINIF', - 'argumentCount' => '2+' - ), - 'MINUTE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::MINUTEOFHOUR', - 'argumentCount' => '1' - ), - 'MINVERSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::MINVERSE', - 'argumentCount' => '1' - ), - 'MIRR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::MIRR', - 'argumentCount' => '3' - ), - 'MMULT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::MMULT', - 'argumentCount' => '2' - ), - 'MOD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::MOD', - 'argumentCount' => '2' - ), - 'MODE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::MODE', - 'argumentCount' => '1+' - ), - 'MONTH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::MONTHOFYEAR', - 'argumentCount' => '1' - ), - 'MROUND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::MROUND', - 'argumentCount' => '2' - ), - 'MULTINOMIAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::MULTINOMIAL', - 'argumentCount' => '1+' - ), - 'N' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::N', - 'argumentCount' => '1' - ), - 'NA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::NA', - 'argumentCount' => '0' - ), - 'NEGBINOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::NEGBINOMDIST', - 'argumentCount' => '3' - ), - 'NETWORKDAYS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::NETWORKDAYS', - 'argumentCount' => '2+' - ), - 'NOMINAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::NOMINAL', - 'argumentCount' => '2' - ), - 'NORMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMDIST', - 'argumentCount' => '4' - ), - 'NORMINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMINV', - 'argumentCount' => '3' - ), - 'NORMSDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMSDIST', - 'argumentCount' => '1' - ), - 'NORMSINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMSINV', - 'argumentCount' => '1' - ), - 'NOT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, - 'functionCall' => 'PHPExcel_Calculation_Logical::NOT', - 'argumentCount' => '1' - ), - 'NOW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DATETIMENOW', - 'argumentCount' => '0' - ), - 'NPER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::NPER', - 'argumentCount' => '3-5' - ), - 'NPV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::NPV', - 'argumentCount' => '2+' - ), - 'OCT2BIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::OCTTOBIN', - 'argumentCount' => '1,2' - ), - 'OCT2DEC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::OCTTODEC', - 'argumentCount' => '1' - ), - 'OCT2HEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, - 'functionCall' => 'PHPExcel_Calculation_Engineering::OCTTOHEX', - 'argumentCount' => '1,2' - ), - 'ODD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::ODD', - 'argumentCount' => '1' - ), - 'ODDFPRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '8,9' - ), - 'ODDFYIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '8,9' - ), - 'ODDLPRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '7,8' - ), - 'ODDLYIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '7,8' - ), - 'OFFSET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET', - 'argumentCount' => '3,5', - 'passCellReference'=> true, - 'passByReference' => array(true) - ), - 'OR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, - 'functionCall' => 'PHPExcel_Calculation_Logical::LOGICAL_OR', - 'argumentCount' => '1+' - ), - 'PEARSON' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::CORREL', - 'argumentCount' => '2' - ), - 'PERCENTILE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::PERCENTILE', - 'argumentCount' => '2' - ), - 'PERCENTRANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::PERCENTRANK', - 'argumentCount' => '2,3' - ), - 'PERMUT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::PERMUT', - 'argumentCount' => '2' - ), - 'PHONETIC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1' - ), - 'PI' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'pi', - 'argumentCount' => '0' - ), - 'PMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::PMT', - 'argumentCount' => '3-5' - ), - 'POISSON' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::POISSON', - 'argumentCount' => '3' - ), - 'POWER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::POWER', - 'argumentCount' => '2' - ), - 'PPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::PPMT', - 'argumentCount' => '4-6' - ), - 'PRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::PRICE', - 'argumentCount' => '6,7' - ), - 'PRICEDISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::PRICEDISC', - 'argumentCount' => '4,5' - ), - 'PRICEMAT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::PRICEMAT', - 'argumentCount' => '5,6' - ), - 'PROB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '3,4' - ), - 'PRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::PRODUCT', - 'argumentCount' => '1+' - ), - 'PROPER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::PROPERCASE', - 'argumentCount' => '1' - ), - 'PV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::PV', - 'argumentCount' => '3-5' - ), - 'QUARTILE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::QUARTILE', - 'argumentCount' => '2' - ), - 'QUOTIENT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::QUOTIENT', - 'argumentCount' => '2' - ), - 'RADIANS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'deg2rad', - 'argumentCount' => '1' - ), - 'RAND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::RAND', - 'argumentCount' => '0' - ), - 'RANDBETWEEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::RAND', - 'argumentCount' => '2' - ), - 'RANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::RANK', - 'argumentCount' => '2,3' - ), - 'RATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::RATE', - 'argumentCount' => '3-6' - ), - 'RECEIVED' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::RECEIVED', - 'argumentCount' => '4-5' - ), - 'REPLACE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::REPLACE', - 'argumentCount' => '4' - ), - 'REPLACEB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::REPLACE', - 'argumentCount' => '4' - ), - 'REPT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'str_repeat', - 'argumentCount' => '2' - ), - 'RIGHT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::RIGHT', - 'argumentCount' => '1,2' - ), - 'RIGHTB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::RIGHT', - 'argumentCount' => '1,2' - ), - 'ROMAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::ROMAN', - 'argumentCount' => '1,2' - ), - 'ROUND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'round', - 'argumentCount' => '2' - ), - 'ROUNDDOWN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::ROUNDDOWN', - 'argumentCount' => '2' - ), - 'ROUNDUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::ROUNDUP', - 'argumentCount' => '2' - ), - 'ROW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::ROW', - 'argumentCount' => '-1', - 'passByReference' => array(true) - ), - 'ROWS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::ROWS', - 'argumentCount' => '1' - ), - 'RSQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::RSQ', - 'argumentCount' => '2' - ), - 'RTD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '1+' - ), - 'SEARCH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE', - 'argumentCount' => '2,3' - ), - 'SEARCHB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE', - 'argumentCount' => '2,3' - ), - 'SECOND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::SECONDOFMINUTE', - 'argumentCount' => '1' - ), - 'SERIESSUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SERIESSUM', - 'argumentCount' => '4' - ), - 'SIGN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SIGN', - 'argumentCount' => '1' - ), - 'SIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'sin', - 'argumentCount' => '1' - ), - 'SINH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'sinh', - 'argumentCount' => '1' - ), - 'SKEW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::SKEW', - 'argumentCount' => '1+' - ), - 'SLN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::SLN', - 'argumentCount' => '3' - ), - 'SLOPE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::SLOPE', - 'argumentCount' => '2' - ), - 'SMALL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::SMALL', - 'argumentCount' => '2' - ), - 'SQRT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'sqrt', - 'argumentCount' => '1' - ), - 'SQRTPI' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SQRTPI', - 'argumentCount' => '1' - ), - 'STANDARDIZE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::STANDARDIZE', - 'argumentCount' => '3' - ), - 'STDEV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEV', - 'argumentCount' => '1+' - ), - 'STDEVA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEVA', - 'argumentCount' => '1+' - ), - 'STDEVP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEVP', - 'argumentCount' => '1+' - ), - 'STDEVPA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEVPA', - 'argumentCount' => '1+' - ), - 'STEYX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::STEYX', - 'argumentCount' => '2' - ), - 'SUBSTITUTE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::SUBSTITUTE', - 'argumentCount' => '3,4' - ), - 'SUBTOTAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUBTOTAL', - 'argumentCount' => '2+' - ), - 'SUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUM', - 'argumentCount' => '1+' - ), - 'SUMIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMIF', - 'argumentCount' => '2,3' - ), - 'SUMIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '?' - ), - 'SUMPRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMPRODUCT', - 'argumentCount' => '1+' - ), - 'SUMSQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMSQ', - 'argumentCount' => '1+' - ), - 'SUMX2MY2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMX2MY2', - 'argumentCount' => '2' - ), - 'SUMX2PY2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMX2PY2', - 'argumentCount' => '2' - ), - 'SUMXMY2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMXMY2', - 'argumentCount' => '2' - ), - 'SYD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::SYD', - 'argumentCount' => '4' - ), - 'T' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::RETURNSTRING', - 'argumentCount' => '1' - ), - 'TAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'tan', - 'argumentCount' => '1' - ), - 'TANH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'tanh', - 'argumentCount' => '1' - ), - 'TBILLEQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::TBILLEQ', - 'argumentCount' => '3' - ), - 'TBILLPRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::TBILLPRICE', - 'argumentCount' => '3' - ), - 'TBILLYIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::TBILLYIELD', - 'argumentCount' => '3' - ), - 'TDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::TDIST', - 'argumentCount' => '3' - ), - 'TEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::TEXTFORMAT', - 'argumentCount' => '2' - ), - 'TIME' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::TIME', - 'argumentCount' => '3' - ), - 'TIMEVALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::TIMEVALUE', - 'argumentCount' => '1' - ), - 'TINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::TINV', - 'argumentCount' => '2' - ), - 'TODAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DATENOW', - 'argumentCount' => '0' - ), - 'TRANSPOSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::TRANSPOSE', - 'argumentCount' => '1' - ), - 'TREND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::TREND', - 'argumentCount' => '1-4' - ), - 'TRIM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::TRIMSPACES', - 'argumentCount' => '1' - ), - 'TRIMMEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::TRIMMEAN', - 'argumentCount' => '2' - ), - 'TRUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, - 'functionCall' => 'PHPExcel_Calculation_Logical::TRUE', - 'argumentCount' => '0' - ), - 'TRUNC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, - 'functionCall' => 'PHPExcel_Calculation_MathTrig::TRUNC', - 'argumentCount' => '1,2' - ), - 'TTEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '4' - ), - 'TYPE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::TYPE', - 'argumentCount' => '1' - ), - 'UPPER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::UPPERCASE', - 'argumentCount' => '1' - ), - 'USDOLLAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '2' - ), - 'VALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_TextData::VALUE', - 'argumentCount' => '1' - ), - 'VAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::VARFunc', - 'argumentCount' => '1+' - ), - 'VARA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::VARA', - 'argumentCount' => '1+' - ), - 'VARP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::VARP', - 'argumentCount' => '1+' - ), - 'VARPA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::VARPA', - 'argumentCount' => '1+' - ), - 'VDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '5-7' - ), - 'VERSION' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, - 'functionCall' => 'PHPExcel_Calculation_Functions::VERSION', - 'argumentCount' => '0' - ), - 'VLOOKUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => 'PHPExcel_Calculation_LookupRef::VLOOKUP', - 'argumentCount' => '3,4' - ), - 'WEEKDAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::DAYOFWEEK', - 'argumentCount' => '1,2' - ), - 'WEEKNUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::WEEKOFYEAR', - 'argumentCount' => '1,2' - ), - 'WEIBULL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::WEIBULL', - 'argumentCount' => '4' - ), - 'WORKDAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::WORKDAY', - 'argumentCount' => '2+' - ), - 'XIRR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::XIRR', - 'argumentCount' => '2,3' - ), - 'XNPV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::XNPV', - 'argumentCount' => '3' - ), - 'YEAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::YEAR', - 'argumentCount' => '1' - ), - 'YEARFRAC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, - 'functionCall' => 'PHPExcel_Calculation_DateTime::YEARFRAC', - 'argumentCount' => '2,3' - ), - 'YIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', - 'argumentCount' => '6,7' - ), - 'YIELDDISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::YIELDDISC', - 'argumentCount' => '4,5' - ), - 'YIELDMAT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, - 'functionCall' => 'PHPExcel_Calculation_Financial::YIELDMAT', - 'argumentCount' => '5,6' - ), - 'ZTEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, - 'functionCall' => 'PHPExcel_Calculation_Statistical::ZTEST', - 'argumentCount' => '2-3' - ) - ); + private static $PHPExcelFunctions = array( + 'ABS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'abs', + 'argumentCount' => '1' + ), + 'ACCRINT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::ACCRINT', + 'argumentCount' => '4-7' + ), + 'ACCRINTM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::ACCRINTM', + 'argumentCount' => '3-5' + ), + 'ACOS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'acos', + 'argumentCount' => '1' + ), + 'ACOSH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'acosh', + 'argumentCount' => '1' + ), + 'ADDRESS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::CELL_ADDRESS', + 'argumentCount' => '2-5' + ), + 'AMORDEGRC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::AMORDEGRC', + 'argumentCount' => '6,7' + ), + 'AMORLINC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::AMORLINC', + 'argumentCount' => '6,7' + ), + 'AND' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, + 'functionCall' => 'PHPExcel_Calculation_Logical::LOGICAL_AND', + 'argumentCount' => '1+' + ), + 'AREAS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1' + ), + 'ASC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1' + ), + 'ASIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'asin', + 'argumentCount' => '1' + ), + 'ASINH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'asinh', + 'argumentCount' => '1' + ), + 'ATAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'atan', + 'argumentCount' => '1' + ), + 'ATAN2' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::ATAN2', + 'argumentCount' => '2' + ), + 'ATANH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'atanh', + 'argumentCount' => '1' + ), + 'AVEDEV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::AVEDEV', + 'argumentCount' => '1+' + ), + 'AVERAGE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::AVERAGE', + 'argumentCount' => '1+' + ), + 'AVERAGEA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::AVERAGEA', + 'argumentCount' => '1+' + ), + 'AVERAGEIF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::AVERAGEIF', + 'argumentCount' => '2,3' + ), + 'AVERAGEIFS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '3+' + ), + 'BAHTTEXT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1' + ), + 'BESSELI' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELI', + 'argumentCount' => '2' + ), + 'BESSELJ' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELJ', + 'argumentCount' => '2' + ), + 'BESSELK' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELK', + 'argumentCount' => '2' + ), + 'BESSELY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::BESSELY', + 'argumentCount' => '2' + ), + 'BETADIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::BETADIST', + 'argumentCount' => '3-5' + ), + 'BETAINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::BETAINV', + 'argumentCount' => '3-5' + ), + 'BIN2DEC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::BINTODEC', + 'argumentCount' => '1' + ), + 'BIN2HEX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::BINTOHEX', + 'argumentCount' => '1,2' + ), + 'BIN2OCT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::BINTOOCT', + 'argumentCount' => '1,2' + ), + 'BINOMDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::BINOMDIST', + 'argumentCount' => '4' + ), + 'CEILING' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::CEILING', + 'argumentCount' => '2' + ), + 'CELL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1,2' + ), + 'CHAR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::CHARACTER', + 'argumentCount' => '1' + ), + 'CHIDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::CHIDIST', + 'argumentCount' => '2' + ), + 'CHIINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::CHIINV', + 'argumentCount' => '2' + ), + 'CHITEST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2' + ), + 'CHOOSE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::CHOOSE', + 'argumentCount' => '2+' + ), + 'CLEAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::TRIMNONPRINTABLE', + 'argumentCount' => '1' + ), + 'CODE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::ASCIICODE', + 'argumentCount' => '1' + ), + 'COLUMN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMN', + 'argumentCount' => '-1', + 'passByReference' => array(true) + ), + 'COLUMNS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMNS', + 'argumentCount' => '1' + ), + 'COMBIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::COMBIN', + 'argumentCount' => '2' + ), + 'COMPLEX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::COMPLEX', + 'argumentCount' => '2,3' + ), + 'CONCATENATE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::CONCATENATE', + 'argumentCount' => '1+' + ), + 'CONFIDENCE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::CONFIDENCE', + 'argumentCount' => '3' + ), + 'CONVERT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::CONVERTUOM', + 'argumentCount' => '3' + ), + 'CORREL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::CORREL', + 'argumentCount' => '2' + ), + 'COS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'cos', + 'argumentCount' => '1' + ), + 'COSH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'cosh', + 'argumentCount' => '1' + ), + 'COUNT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNT', + 'argumentCount' => '1+' + ), + 'COUNTA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNTA', + 'argumentCount' => '1+' + ), + 'COUNTBLANK' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNTBLANK', + 'argumentCount' => '1' + ), + 'COUNTIF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::COUNTIF', + 'argumentCount' => '2' + ), + 'COUNTIFS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2' + ), + 'COUPDAYBS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::COUPDAYBS', + 'argumentCount' => '3,4' + ), + 'COUPDAYS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::COUPDAYS', + 'argumentCount' => '3,4' + ), + 'COUPDAYSNC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::COUPDAYSNC', + 'argumentCount' => '3,4' + ), + 'COUPNCD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::COUPNCD', + 'argumentCount' => '3,4' + ), + 'COUPNUM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::COUPNUM', + 'argumentCount' => '3,4' + ), + 'COUPPCD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::COUPPCD', + 'argumentCount' => '3,4' + ), + 'COVAR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::COVAR', + 'argumentCount' => '2' + ), + 'CRITBINOM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::CRITBINOM', + 'argumentCount' => '3' + ), + 'CUBEKPIMEMBER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'CUBEMEMBER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'CUBEMEMBERPROPERTY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'CUBERANKEDMEMBER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'CUBESET' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'CUBESETCOUNT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'CUBEVALUE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_CUBE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'CUMIPMT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::CUMIPMT', + 'argumentCount' => '6' + ), + 'CUMPRINC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::CUMPRINC', + 'argumentCount' => '6' + ), + 'DATE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DATE', + 'argumentCount' => '3' + ), + 'DATEDIF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DATEDIF', + 'argumentCount' => '2,3' + ), + 'DATEVALUE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DATEVALUE', + 'argumentCount' => '1' + ), + 'DAVERAGE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DAVERAGE', + 'argumentCount' => '3' + ), + 'DAY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DAYOFMONTH', + 'argumentCount' => '1' + ), + 'DAYS360' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DAYS360', + 'argumentCount' => '2,3' + ), + 'DB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::DB', + 'argumentCount' => '4,5' + ), + 'DCOUNT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DCOUNT', + 'argumentCount' => '3' + ), + 'DCOUNTA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DCOUNTA', + 'argumentCount' => '3' + ), + 'DDB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::DDB', + 'argumentCount' => '4,5' + ), + 'DEC2BIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::DECTOBIN', + 'argumentCount' => '1,2' + ), + 'DEC2HEX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::DECTOHEX', + 'argumentCount' => '1,2' + ), + 'DEC2OCT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::DECTOOCT', + 'argumentCount' => '1,2' + ), + 'DEGREES' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'rad2deg', + 'argumentCount' => '1' + ), + 'DELTA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::DELTA', + 'argumentCount' => '1,2' + ), + 'DEVSQ' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::DEVSQ', + 'argumentCount' => '1+' + ), + 'DGET' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DGET', + 'argumentCount' => '3' + ), + 'DISC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::DISC', + 'argumentCount' => '4,5' + ), + 'DMAX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DMAX', + 'argumentCount' => '3' + ), + 'DMIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DMIN', + 'argumentCount' => '3' + ), + 'DOLLAR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::DOLLAR', + 'argumentCount' => '1,2' + ), + 'DOLLARDE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::DOLLARDE', + 'argumentCount' => '2' + ), + 'DOLLARFR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::DOLLARFR', + 'argumentCount' => '2' + ), + 'DPRODUCT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DPRODUCT', + 'argumentCount' => '3' + ), + 'DSTDEV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DSTDEV', + 'argumentCount' => '3' + ), + 'DSTDEVP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DSTDEVP', + 'argumentCount' => '3' + ), + 'DSUM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DSUM', + 'argumentCount' => '3' + ), + 'DURATION' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '5,6' + ), + 'DVAR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DVAR', + 'argumentCount' => '3' + ), + 'DVARP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE, + 'functionCall' => 'PHPExcel_Calculation_Database::DVARP', + 'argumentCount' => '3' + ), + 'EDATE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::EDATE', + 'argumentCount' => '2' + ), + 'EFFECT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::EFFECT', + 'argumentCount' => '2' + ), + 'EOMONTH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::EOMONTH', + 'argumentCount' => '2' + ), + 'ERF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::ERF', + 'argumentCount' => '1,2' + ), + 'ERFC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::ERFC', + 'argumentCount' => '1' + ), + 'ERROR.TYPE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::ERROR_TYPE', + 'argumentCount' => '1' + ), + 'EVEN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::EVEN', + 'argumentCount' => '1' + ), + 'EXACT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2' + ), + 'EXP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'exp', + 'argumentCount' => '1' + ), + 'EXPONDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::EXPONDIST', + 'argumentCount' => '3' + ), + 'FACT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::FACT', + 'argumentCount' => '1' + ), + 'FACTDOUBLE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::FACTDOUBLE', + 'argumentCount' => '1' + ), + 'FALSE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, + 'functionCall' => 'PHPExcel_Calculation_Logical::FALSE', + 'argumentCount' => '0' + ), + 'FDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '3' + ), + 'FIND' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHSENSITIVE', + 'argumentCount' => '2,3' + ), + 'FINDB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHSENSITIVE', + 'argumentCount' => '2,3' + ), + 'FINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '3' + ), + 'FISHER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::FISHER', + 'argumentCount' => '1' + ), + 'FISHERINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::FISHERINV', + 'argumentCount' => '1' + ), + 'FIXED' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::FIXEDFORMAT', + 'argumentCount' => '1-3' + ), + 'FLOOR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::FLOOR', + 'argumentCount' => '2' + ), + 'FORECAST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::FORECAST', + 'argumentCount' => '3' + ), + 'FREQUENCY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2' + ), + 'FTEST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2' + ), + 'FV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::FV', + 'argumentCount' => '3-5' + ), + 'FVSCHEDULE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::FVSCHEDULE', + 'argumentCount' => '2' + ), + 'GAMMADIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::GAMMADIST', + 'argumentCount' => '4' + ), + 'GAMMAINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::GAMMAINV', + 'argumentCount' => '3' + ), + 'GAMMALN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::GAMMALN', + 'argumentCount' => '1' + ), + 'GCD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::GCD', + 'argumentCount' => '1+' + ), + 'GEOMEAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::GEOMEAN', + 'argumentCount' => '1+' + ), + 'GESTEP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::GESTEP', + 'argumentCount' => '1,2' + ), + 'GETPIVOTDATA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2+' + ), + 'GROWTH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::GROWTH', + 'argumentCount' => '1-4' + ), + 'HARMEAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::HARMEAN', + 'argumentCount' => '1+' + ), + 'HEX2BIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::HEXTOBIN', + 'argumentCount' => '1,2' + ), + 'HEX2DEC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::HEXTODEC', + 'argumentCount' => '1' + ), + 'HEX2OCT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::HEXTOOCT', + 'argumentCount' => '1,2' + ), + 'HLOOKUP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::HLOOKUP', + 'argumentCount' => '3,4' + ), + 'HOUR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::HOUROFDAY', + 'argumentCount' => '1' + ), + 'HYPERLINK' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::HYPERLINK', + 'argumentCount' => '1,2', + 'passCellReference' => true + ), + 'HYPGEOMDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::HYPGEOMDIST', + 'argumentCount' => '4' + ), + 'IF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, + 'functionCall' => 'PHPExcel_Calculation_Logical::STATEMENT_IF', + 'argumentCount' => '1-3' + ), + 'IFERROR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, + 'functionCall' => 'PHPExcel_Calculation_Logical::IFERROR', + 'argumentCount' => '2' + ), + 'IMABS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMABS', + 'argumentCount' => '1' + ), + 'IMAGINARY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMAGINARY', + 'argumentCount' => '1' + ), + 'IMARGUMENT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMARGUMENT', + 'argumentCount' => '1' + ), + 'IMCONJUGATE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMCONJUGATE', + 'argumentCount' => '1' + ), + 'IMCOS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMCOS', + 'argumentCount' => '1' + ), + 'IMDIV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMDIV', + 'argumentCount' => '2' + ), + 'IMEXP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMEXP', + 'argumentCount' => '1' + ), + 'IMLN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMLN', + 'argumentCount' => '1' + ), + 'IMLOG10' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMLOG10', + 'argumentCount' => '1' + ), + 'IMLOG2' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMLOG2', + 'argumentCount' => '1' + ), + 'IMPOWER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMPOWER', + 'argumentCount' => '2' + ), + 'IMPRODUCT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMPRODUCT', + 'argumentCount' => '1+' + ), + 'IMREAL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMREAL', + 'argumentCount' => '1' + ), + 'IMSIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSIN', + 'argumentCount' => '1' + ), + 'IMSQRT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSQRT', + 'argumentCount' => '1' + ), + 'IMSUB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSUB', + 'argumentCount' => '2' + ), + 'IMSUM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::IMSUM', + 'argumentCount' => '1+' + ), + 'INDEX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::INDEX', + 'argumentCount' => '1-4' + ), + 'INDIRECT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::INDIRECT', + 'argumentCount' => '1,2', + 'passCellReference' => true + ), + 'INFO' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1' + ), + 'INT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::INT', + 'argumentCount' => '1' + ), + 'INTERCEPT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::INTERCEPT', + 'argumentCount' => '2' + ), + 'INTRATE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::INTRATE', + 'argumentCount' => '4,5' + ), + 'IPMT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::IPMT', + 'argumentCount' => '4-6' + ), + 'IRR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::IRR', + 'argumentCount' => '1,2' + ), + 'ISBLANK' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_BLANK', + 'argumentCount' => '1' + ), + 'ISERR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ERR', + 'argumentCount' => '1' + ), + 'ISERROR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ERROR', + 'argumentCount' => '1' + ), + 'ISEVEN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_EVEN', + 'argumentCount' => '1' + ), + 'ISLOGICAL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_LOGICAL', + 'argumentCount' => '1' + ), + 'ISNA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NA', + 'argumentCount' => '1' + ), + 'ISNONTEXT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NONTEXT', + 'argumentCount' => '1' + ), + 'ISNUMBER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NUMBER', + 'argumentCount' => '1' + ), + 'ISODD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ODD', + 'argumentCount' => '1' + ), + 'ISPMT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::ISPMT', + 'argumentCount' => '4' + ), + 'ISREF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1' + ), + 'ISTEXT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::IS_TEXT', + 'argumentCount' => '1' + ), + 'JIS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1' + ), + 'KURT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::KURT', + 'argumentCount' => '1+' + ), + 'LARGE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::LARGE', + 'argumentCount' => '2' + ), + 'LCM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::LCM', + 'argumentCount' => '1+' + ), + 'LEFT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::LEFT', + 'argumentCount' => '1,2' + ), + 'LEFTB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::LEFT', + 'argumentCount' => '1,2' + ), + 'LEN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::STRINGLENGTH', + 'argumentCount' => '1' + ), + 'LENB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::STRINGLENGTH', + 'argumentCount' => '1' + ), + 'LINEST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::LINEST', + 'argumentCount' => '1-4' + ), + 'LN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'log', + 'argumentCount' => '1' + ), + 'LOG' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::LOG_BASE', + 'argumentCount' => '1,2' + ), + 'LOG10' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'log10', + 'argumentCount' => '1' + ), + 'LOGEST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::LOGEST', + 'argumentCount' => '1-4' + ), + 'LOGINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::LOGINV', + 'argumentCount' => '3' + ), + 'LOGNORMDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::LOGNORMDIST', + 'argumentCount' => '3' + ), + 'LOOKUP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::LOOKUP', + 'argumentCount' => '2,3' + ), + 'LOWER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::LOWERCASE', + 'argumentCount' => '1' + ), + 'MATCH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::MATCH', + 'argumentCount' => '2,3' + ), + 'MAX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MAX', + 'argumentCount' => '1+' + ), + 'MAXA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MAXA', + 'argumentCount' => '1+' + ), + 'MAXIF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MAXIF', + 'argumentCount' => '2+' + ), + 'MDETERM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::MDETERM', + 'argumentCount' => '1' + ), + 'MDURATION' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '5,6' + ), + 'MEDIAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MEDIAN', + 'argumentCount' => '1+' + ), + 'MEDIANIF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2+' + ), + 'MID' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::MID', + 'argumentCount' => '3' + ), + 'MIDB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::MID', + 'argumentCount' => '3' + ), + 'MIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MIN', + 'argumentCount' => '1+' + ), + 'MINA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MINA', + 'argumentCount' => '1+' + ), + 'MINIF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MINIF', + 'argumentCount' => '2+' + ), + 'MINUTE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::MINUTEOFHOUR', + 'argumentCount' => '1' + ), + 'MINVERSE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::MINVERSE', + 'argumentCount' => '1' + ), + 'MIRR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::MIRR', + 'argumentCount' => '3' + ), + 'MMULT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::MMULT', + 'argumentCount' => '2' + ), + 'MOD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::MOD', + 'argumentCount' => '2' + ), + 'MODE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::MODE', + 'argumentCount' => '1+' + ), + 'MONTH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::MONTHOFYEAR', + 'argumentCount' => '1' + ), + 'MROUND' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::MROUND', + 'argumentCount' => '2' + ), + 'MULTINOMIAL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::MULTINOMIAL', + 'argumentCount' => '1+' + ), + 'N' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::N', + 'argumentCount' => '1' + ), + 'NA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::NA', + 'argumentCount' => '0' + ), + 'NEGBINOMDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::NEGBINOMDIST', + 'argumentCount' => '3' + ), + 'NETWORKDAYS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::NETWORKDAYS', + 'argumentCount' => '2+' + ), + 'NOMINAL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::NOMINAL', + 'argumentCount' => '2' + ), + 'NORMDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMDIST', + 'argumentCount' => '4' + ), + 'NORMINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMINV', + 'argumentCount' => '3' + ), + 'NORMSDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMSDIST', + 'argumentCount' => '1' + ), + 'NORMSINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::NORMSINV', + 'argumentCount' => '1' + ), + 'NOT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, + 'functionCall' => 'PHPExcel_Calculation_Logical::NOT', + 'argumentCount' => '1' + ), + 'NOW' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DATETIMENOW', + 'argumentCount' => '0' + ), + 'NPER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::NPER', + 'argumentCount' => '3-5' + ), + 'NPV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::NPV', + 'argumentCount' => '2+' + ), + 'OCT2BIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::OCTTOBIN', + 'argumentCount' => '1,2' + ), + 'OCT2DEC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::OCTTODEC', + 'argumentCount' => '1' + ), + 'OCT2HEX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING, + 'functionCall' => 'PHPExcel_Calculation_Engineering::OCTTOHEX', + 'argumentCount' => '1,2' + ), + 'ODD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::ODD', + 'argumentCount' => '1' + ), + 'ODDFPRICE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '8,9' + ), + 'ODDFYIELD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '8,9' + ), + 'ODDLPRICE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '7,8' + ), + 'ODDLYIELD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '7,8' + ), + 'OFFSET' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET', + 'argumentCount' => '3,5', + 'passCellReference' => true, + 'passByReference' => array(true) + ), + 'OR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, + 'functionCall' => 'PHPExcel_Calculation_Logical::LOGICAL_OR', + 'argumentCount' => '1+' + ), + 'PEARSON' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::CORREL', + 'argumentCount' => '2' + ), + 'PERCENTILE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::PERCENTILE', + 'argumentCount' => '2' + ), + 'PERCENTRANK' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::PERCENTRANK', + 'argumentCount' => '2,3' + ), + 'PERMUT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::PERMUT', + 'argumentCount' => '2' + ), + 'PHONETIC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1' + ), + 'PI' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'pi', + 'argumentCount' => '0' + ), + 'PMT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::PMT', + 'argumentCount' => '3-5' + ), + 'POISSON' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::POISSON', + 'argumentCount' => '3' + ), + 'POWER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::POWER', + 'argumentCount' => '2' + ), + 'PPMT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::PPMT', + 'argumentCount' => '4-6' + ), + 'PRICE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::PRICE', + 'argumentCount' => '6,7' + ), + 'PRICEDISC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::PRICEDISC', + 'argumentCount' => '4,5' + ), + 'PRICEMAT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::PRICEMAT', + 'argumentCount' => '5,6' + ), + 'PROB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '3,4' + ), + 'PRODUCT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::PRODUCT', + 'argumentCount' => '1+' + ), + 'PROPER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::PROPERCASE', + 'argumentCount' => '1' + ), + 'PV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::PV', + 'argumentCount' => '3-5' + ), + 'QUARTILE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::QUARTILE', + 'argumentCount' => '2' + ), + 'QUOTIENT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::QUOTIENT', + 'argumentCount' => '2' + ), + 'RADIANS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'deg2rad', + 'argumentCount' => '1' + ), + 'RAND' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::RAND', + 'argumentCount' => '0' + ), + 'RANDBETWEEN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::RAND', + 'argumentCount' => '2' + ), + 'RANK' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::RANK', + 'argumentCount' => '2,3' + ), + 'RATE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::RATE', + 'argumentCount' => '3-6' + ), + 'RECEIVED' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::RECEIVED', + 'argumentCount' => '4-5' + ), + 'REPLACE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::REPLACE', + 'argumentCount' => '4' + ), + 'REPLACEB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::REPLACE', + 'argumentCount' => '4' + ), + 'REPT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'str_repeat', + 'argumentCount' => '2' + ), + 'RIGHT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::RIGHT', + 'argumentCount' => '1,2' + ), + 'RIGHTB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::RIGHT', + 'argumentCount' => '1,2' + ), + 'ROMAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::ROMAN', + 'argumentCount' => '1,2' + ), + 'ROUND' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'round', + 'argumentCount' => '2' + ), + 'ROUNDDOWN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::ROUNDDOWN', + 'argumentCount' => '2' + ), + 'ROUNDUP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::ROUNDUP', + 'argumentCount' => '2' + ), + 'ROW' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::ROW', + 'argumentCount' => '-1', + 'passByReference' => array(true) + ), + 'ROWS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::ROWS', + 'argumentCount' => '1' + ), + 'RSQ' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::RSQ', + 'argumentCount' => '2' + ), + 'RTD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '1+' + ), + 'SEARCH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE', + 'argumentCount' => '2,3' + ), + 'SEARCHB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE', + 'argumentCount' => '2,3' + ), + 'SECOND' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::SECONDOFMINUTE', + 'argumentCount' => '1' + ), + 'SERIESSUM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SERIESSUM', + 'argumentCount' => '4' + ), + 'SIGN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SIGN', + 'argumentCount' => '1' + ), + 'SIN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'sin', + 'argumentCount' => '1' + ), + 'SINH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'sinh', + 'argumentCount' => '1' + ), + 'SKEW' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::SKEW', + 'argumentCount' => '1+' + ), + 'SLN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::SLN', + 'argumentCount' => '3' + ), + 'SLOPE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::SLOPE', + 'argumentCount' => '2' + ), + 'SMALL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::SMALL', + 'argumentCount' => '2' + ), + 'SQRT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'sqrt', + 'argumentCount' => '1' + ), + 'SQRTPI' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SQRTPI', + 'argumentCount' => '1' + ), + 'STANDARDIZE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::STANDARDIZE', + 'argumentCount' => '3' + ), + 'STDEV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEV', + 'argumentCount' => '1+' + ), + 'STDEVA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEVA', + 'argumentCount' => '1+' + ), + 'STDEVP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEVP', + 'argumentCount' => '1+' + ), + 'STDEVPA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::STDEVPA', + 'argumentCount' => '1+' + ), + 'STEYX' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::STEYX', + 'argumentCount' => '2' + ), + 'SUBSTITUTE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::SUBSTITUTE', + 'argumentCount' => '3,4' + ), + 'SUBTOTAL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUBTOTAL', + 'argumentCount' => '2+' + ), + 'SUM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUM', + 'argumentCount' => '1+' + ), + 'SUMIF' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMIF', + 'argumentCount' => '2,3' + ), + 'SUMIFS' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '?' + ), + 'SUMPRODUCT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMPRODUCT', + 'argumentCount' => '1+' + ), + 'SUMSQ' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMSQ', + 'argumentCount' => '1+' + ), + 'SUMX2MY2' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMX2MY2', + 'argumentCount' => '2' + ), + 'SUMX2PY2' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMX2PY2', + 'argumentCount' => '2' + ), + 'SUMXMY2' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMXMY2', + 'argumentCount' => '2' + ), + 'SYD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::SYD', + 'argumentCount' => '4' + ), + 'T' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::RETURNSTRING', + 'argumentCount' => '1' + ), + 'TAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'tan', + 'argumentCount' => '1' + ), + 'TANH' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'tanh', + 'argumentCount' => '1' + ), + 'TBILLEQ' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::TBILLEQ', + 'argumentCount' => '3' + ), + 'TBILLPRICE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::TBILLPRICE', + 'argumentCount' => '3' + ), + 'TBILLYIELD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::TBILLYIELD', + 'argumentCount' => '3' + ), + 'TDIST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::TDIST', + 'argumentCount' => '3' + ), + 'TEXT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::TEXTFORMAT', + 'argumentCount' => '2' + ), + 'TIME' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::TIME', + 'argumentCount' => '3' + ), + 'TIMEVALUE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::TIMEVALUE', + 'argumentCount' => '1' + ), + 'TINV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::TINV', + 'argumentCount' => '2' + ), + 'TODAY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DATENOW', + 'argumentCount' => '0' + ), + 'TRANSPOSE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::TRANSPOSE', + 'argumentCount' => '1' + ), + 'TREND' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::TREND', + 'argumentCount' => '1-4' + ), + 'TRIM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::TRIMSPACES', + 'argumentCount' => '1' + ), + 'TRIMMEAN' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::TRIMMEAN', + 'argumentCount' => '2' + ), + 'TRUE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL, + 'functionCall' => 'PHPExcel_Calculation_Logical::TRUE', + 'argumentCount' => '0' + ), + 'TRUNC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, + 'functionCall' => 'PHPExcel_Calculation_MathTrig::TRUNC', + 'argumentCount' => '1,2' + ), + 'TTEST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '4' + ), + 'TYPE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::TYPE', + 'argumentCount' => '1' + ), + 'UPPER' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::UPPERCASE', + 'argumentCount' => '1' + ), + 'USDOLLAR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '2' + ), + 'VALUE' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, + 'functionCall' => 'PHPExcel_Calculation_TextData::VALUE', + 'argumentCount' => '1' + ), + 'VAR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::VARFunc', + 'argumentCount' => '1+' + ), + 'VARA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::VARA', + 'argumentCount' => '1+' + ), + 'VARP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::VARP', + 'argumentCount' => '1+' + ), + 'VARPA' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::VARPA', + 'argumentCount' => '1+' + ), + 'VDB' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '5-7' + ), + 'VERSION' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION, + 'functionCall' => 'PHPExcel_Calculation_Functions::VERSION', + 'argumentCount' => '0' + ), + 'VLOOKUP' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, + 'functionCall' => 'PHPExcel_Calculation_LookupRef::VLOOKUP', + 'argumentCount' => '3,4' + ), + 'WEEKDAY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::DAYOFWEEK', + 'argumentCount' => '1,2' + ), + 'WEEKNUM' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::WEEKOFYEAR', + 'argumentCount' => '1,2' + ), + 'WEIBULL' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::WEIBULL', + 'argumentCount' => '4' + ), + 'WORKDAY' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::WORKDAY', + 'argumentCount' => '2+' + ), + 'XIRR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::XIRR', + 'argumentCount' => '2,3' + ), + 'XNPV' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::XNPV', + 'argumentCount' => '3' + ), + 'YEAR' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::YEAR', + 'argumentCount' => '1' + ), + 'YEARFRAC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME, + 'functionCall' => 'PHPExcel_Calculation_DateTime::YEARFRAC', + 'argumentCount' => '2,3' + ), + 'YIELD' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'argumentCount' => '6,7' + ), + 'YIELDDISC' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::YIELDDISC', + 'argumentCount' => '4,5' + ), + 'YIELDMAT' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL, + 'functionCall' => 'PHPExcel_Calculation_Financial::YIELDMAT', + 'argumentCount' => '5,6' + ), + 'ZTEST' => array( + 'category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, + 'functionCall' => 'PHPExcel_Calculation_Statistical::ZTEST', + 'argumentCount' => '2-3' + ) + ); // Internal functions used for special control purposes private static $controlFunctions = array( 'MKMATRIX' => array( 'argumentCount' => '*', - 'functionCall' => 'self::_mkMatrix' + 'functionCall' => 'self::mkMatrix' ) ); @@ -2186,7 +2542,7 @@ class PHPExcel_Calculation * @param mixed $value * @return mixed */ - public static function _wrapResult($value) + public static function wrapResult($value) { if (is_string($value)) { // Error values cannot be "wrapped" @@ -2211,7 +2567,7 @@ class PHPExcel_Calculation * @param mixed $value * @return mixed */ - public static function _unwrapResult($value) + public static function unwrapResult($value) { if (is_string($value)) { if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) { @@ -2278,7 +2634,7 @@ class PHPExcel_Calculation 'cell' => $pCell->getCoordinate(), ); try { - $result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell)); + $result = self::unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell)); $cellAddress = array_pop($this->cellStack); $this->workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']); } catch (PHPExcel_Exception $e) { @@ -2370,7 +2726,7 @@ class PHPExcel_Calculation $this->calculationCacheEnabled = false; // Execute the calculation try { - $result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell)); + $result = self::unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell)); } catch (PHPExcel_Exception $e) { throw new PHPExcel_Calculation_Exception($e->getMessage()); } @@ -2420,11 +2776,11 @@ class PHPExcel_Calculation // We simply return the cell value if not $formula = trim($formula); if ($formula{0} != '=') { - return self::_wrapResult($formula); + return self::wrapResult($formula); } $formula = ltrim(substr($formula, 1)); if (!isset($formula{0})) { - return self::_wrapResult($formula); + return self::wrapResult($formula); } $pCellParent = ($pCell !== null) ? $pCell->getWorksheet() : null; @@ -2455,7 +2811,7 @@ class PHPExcel_Calculation // Parse the formula onto the token stack and calculate the value $this->cyclicReferenceStack->push($wsCellReference); - $cellValue = $this->_processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell); + $cellValue = $this->processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell); $this->cyclicReferenceStack->pop(); // Save to calculation cache @@ -2480,7 +2836,7 @@ class PHPExcel_Calculation * 1 = shrink to fit * 2 = extend to fit */ - private static function _checkMatrixOperands(&$operand1, &$operand2, $resize = 1) + private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1) { // Examine each of the two operands, and turn them into an array if they aren't one already // Note that this function should only be called if one or both of the operand is already an array @@ -2502,10 +2858,10 @@ class PHPExcel_Calculation if ($resize == 2) { // Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger - self::_resizeMatricesExtend($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); + self::resizeMatricesExtend($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); } elseif ($resize == 1) { // Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller - self::_resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); + self::resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); } return array( $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); } @@ -2544,7 +2900,7 @@ class PHPExcel_Calculation * @param integer $matrix2Rows Row size of second matrix operand * @param integer $matrix2Columns Column size of second matrix operand */ - private static function _resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) + private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Rows < $matrix1Rows) { @@ -2588,7 +2944,7 @@ class PHPExcel_Calculation * @param integer $matrix2Rows Row size of second matrix operand * @param integer $matrix2Columns Column size of second matrix operand */ - private static function _resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) + private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Columns < $matrix1Columns) { @@ -2632,7 +2988,7 @@ class PHPExcel_Calculation * @param mixed $value First matrix operand * @return mixed */ - private function _showValue($value) + private function showValue($value) { if ($this->_debugLog->getWriteDebugLog()) { $testArray = PHPExcel_Calculation_Functions::flattenArray($value); @@ -2645,10 +3001,10 @@ class PHPExcel_Calculation $pad = $rpad = ', '; foreach ($value as $row) { if (is_array($row)) { - $returnMatrix[] = implode($pad, array_map(array($this, '_showValue'), $row)); + $returnMatrix[] = implode($pad, array_map(array($this, 'showValue'), $row)); $rpad = '; '; } else { - $returnMatrix[] = $this->_showValue($row); + $returnMatrix[] = $this->showValue($row); } } return '{ '.implode($rpad, $returnMatrix).' }'; @@ -2668,7 +3024,7 @@ class PHPExcel_Calculation * @param mixed $value First matrix operand * @return mixed */ - private function _showTypeDetails($value) + private function showTypeDetails($value) { if ($this->_debugLog->getWriteDebugLog()) { $testArray = PHPExcel_Calculation_Functions::flattenArray($value); @@ -2695,12 +3051,12 @@ class PHPExcel_Calculation $typeString = 'a string'; } } - return $typeString.' with a value of '.$this->_showValue($value); + return $typeString.' with a value of '.$this->showValue($value); } } - private function _convertMatrixReferences($formula) + private function convertMatrixReferences($formula) { static $matrixReplaceFrom = array('{', ';', '}'); static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(', '),MKMATRIX(', '))'); @@ -2752,7 +3108,7 @@ class PHPExcel_Calculation } - private static function _mkMatrix() + private static function mkMatrix() { return func_get_args(); } @@ -2761,7 +3117,7 @@ class PHPExcel_Calculation // Binary Operators // These operators always work on two values // Array key is the operator, the value indicates whether this is a left or right associative operator - private static $_operatorAssociativity = array( + private static $operatorAssociativity = array( '^' => 0, // Exponentiation '*' => 0, '/' => 0, // Multiplication and Division '+' => 0, '-' => 0, // Addition and Subtraction @@ -2772,12 +3128,12 @@ class PHPExcel_Calculation // Comparison (Boolean) Operators // These operators work on two values, but always return a boolean result - private static $_comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true); + private static $comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true); // Operator Precedence // This list includes all valid operators, whether binary (including boolean) or unary (such as %) // Array key is the operator, the value is its precedence - private static $_operatorPrecedence = array( + private static $operatorPrecedence = array( ':' => 8, // Range '|' => 7, // Intersect '~' => 6, // Negation @@ -2792,7 +3148,7 @@ class PHPExcel_Calculation // Convert infix to postfix notation private function _parseFormula($formula, PHPExcel_Cell $pCell = null) { - if (($formula = $this->_convertMatrixReferences(trim($formula))) === false) { + if (($formula = $this->convertMatrixReferences(trim($formula))) === false) { return false; } @@ -2823,7 +3179,7 @@ class PHPExcel_Calculation //echo 'Assessing Expression '.substr($formula, $index), PHP_EOL; $opCharacter = $formula{$index}; // Get the first character of the value at the current index position //echo 'Initial character of expression block is '.$opCharacter, PHP_EOL; - if ((isset(self::$_comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$_comparisonOperators[$formula{$index+1}]))) { + if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula{$index+1}]))) { $opCharacter .= $formula{++$index}; //echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL; } @@ -2852,7 +3208,7 @@ class PHPExcel_Calculation while ($stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$operators[$o2['value']]) && - @(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) { + @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output } $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack @@ -3060,7 +3416,7 @@ class PHPExcel_Calculation if ($opCharacter == '"') { // echo 'Element is a String
'; // UnEscape any quotes within the string - $val = self::_wrapResult(str_replace('""', '"', self::_unwrapResult($val))); + $val = self::wrapResult(str_replace('""', '"', self::unwrapResult($val))); } elseif (is_numeric($val)) { // echo 'Element is a Number
'; if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { @@ -3128,7 +3484,7 @@ class PHPExcel_Calculation while ($stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$operators[$o2['value']]) && - @(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) { + @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output } $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack @@ -3163,7 +3519,7 @@ class PHPExcel_Calculation } // evaluate postfix notation - private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) + private function processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) { if ($tokens == false) { return false; @@ -3197,9 +3553,9 @@ class PHPExcel_Calculation // Log what we're doing if ($token == ':') { - $this->_debugLog->writeDebugLog('Evaluating Range ', $this->_showValue($operand1Data['reference']), ' ', $token, ' ', $this->_showValue($operand2Data['reference'])); + $this->_debugLog->writeDebugLog('Evaluating Range ', $this->showValue($operand1Data['reference']), ' ', $token, ' ', $this->showValue($operand2Data['reference'])); } else { - $this->_debugLog->writeDebugLog('Evaluating ', $this->_showValue($operand1), ' ', $token, ' ', $this->_showValue($operand2)); + $this->_debugLog->writeDebugLog('Evaluating ', $this->showValue($operand1), ' ', $token, ' ', $this->showValue($operand2)); } // Process the operation in the appropriate manner @@ -3291,7 +3647,7 @@ class PHPExcel_Calculation } if ((is_array($operand1)) || (is_array($operand2))) { // Ensure that both operands are arrays/matrices - self::_checkMatrixOperands($operand1, $operand2, 2); + self::checkMatrixOperands($operand1, $operand2, 2); try { // Convert operand 1 from a PHP array to a matrix $matrix = new PHPExcel_Shared_JAMA_Matrix($operand1); @@ -3303,9 +3659,9 @@ class PHPExcel_Calculation $result = '#VALUE!'; } } else { - $result = '"'.str_replace('""', '"', self::_unwrapResult($operand1, '"').self::_unwrapResult($operand2, '"')).'"'; + $result = '"'.str_replace('""', '"', self::unwrapResult($operand1, '"').self::unwrapResult($operand2, '"')).'"'; } - $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); $stack->push('Value', $result); break; case '|': // Intersect @@ -3319,7 +3675,7 @@ class PHPExcel_Calculation } } $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow); - $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($cellIntersect)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect)); $stack->push('Value', $cellIntersect, $cellRef); break; } @@ -3333,15 +3689,15 @@ class PHPExcel_Calculation $arg = $arg['value']; if ($token === '~') { // echo 'Token is a negation operator
'; - $this->_debugLog->writeDebugLog('Evaluating Negation of ', $this->_showValue($arg)); + $this->_debugLog->writeDebugLog('Evaluating Negation of ', $this->showValue($arg)); $multiplier = -1; } else { // echo 'Token is a percentile operator
'; - $this->_debugLog->writeDebugLog('Evaluating Percentile of ', $this->_showValue($arg)); + $this->_debugLog->writeDebugLog('Evaluating Percentile of ', $this->showValue($arg)); $multiplier = 0.01; } if (is_array($arg)) { - self::_checkMatrixOperands($arg, $multiplier, 2); + self::checkMatrixOperands($arg, $multiplier, 2); try { $matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg); $matrixResult = $matrix1->arrayTimesEquals($multiplier); @@ -3350,7 +3706,7 @@ class PHPExcel_Calculation $this->_debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage()); $result = '#VALUE!'; } - $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); $stack->push('Value', $result); } else { $this->executeNumericBinaryOperation($cellID, $multiplier, $arg, '*', 'arrayTimesEquals', $stack); @@ -3380,7 +3736,7 @@ class PHPExcel_Calculation } else { return $this->raiseFormulaError('Unable to access Cell Reference'); } - $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->showTypeDetails($cellValue)); // $cellRef = $matches[2].'!'.$cellRef; } else { // echo '$cellRef='.$cellRef.' in current worksheet
'; @@ -3390,7 +3746,7 @@ class PHPExcel_Calculation } else { return $this->raiseFormulaError('Unable to access Cell Reference'); } - $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' is ', $this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' is ', $this->showTypeDetails($cellValue)); } } } else { @@ -3419,7 +3775,7 @@ class PHPExcel_Calculation } else { return $this->raiseFormulaError('Unable to access Cell Reference'); } - $this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->showTypeDetails($cellValue)); // $cellRef = $matches[2].'!'.$cellRef; } else { // echo '$cellRef='.$cellRef.' in current worksheet
'; @@ -3430,7 +3786,7 @@ class PHPExcel_Calculation } else { $cellValue = null; } - $this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' is ', $this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' is ', $this->showTypeDetails($cellValue)); } } } @@ -3467,18 +3823,18 @@ class PHPExcel_Calculation if ($arg['reference'] === null) { $args[] = $cellID; if ($functionName != 'MKMATRIX') { - $argArrayVals[] = $this->_showValue($cellID); + $argArrayVals[] = $this->showValue($cellID); } } else { $args[] = $arg['reference']; if ($functionName != 'MKMATRIX') { - $argArrayVals[] = $this->_showValue($arg['reference']); + $argArrayVals[] = $this->showValue($arg['reference']); } } } else { - $args[] = self::_unwrapResult($arg['value']); + $args[] = self::unwrapResult($arg['value']); if ($functionName != 'MKMATRIX') { - $argArrayVals[] = $this->_showValue($arg['value']); + $argArrayVals[] = $this->showValue($arg['value']); } } } @@ -3486,7 +3842,7 @@ class PHPExcel_Calculation krsort($args); if (($passByReference) && ($argCount == 0)) { $args[] = $cellID; - $argArrayVals[] = $this->_showValue($cellID); + $argArrayVals[] = $this->showValue($cellID); } // echo 'Arguments are: '; // print_r($args); @@ -3500,22 +3856,22 @@ class PHPExcel_Calculation // Process each argument in turn, building the return value as an array // if (($argCount == 1) && (is_array($args[1])) && ($functionName != 'MKMATRIX')) { // $operand1 = $args[1]; -// $this->_debugLog->writeDebugLog('Argument is a matrix: ', $this->_showValue($operand1)); +// $this->_debugLog->writeDebugLog('Argument is a matrix: ', $this->showValue($operand1)); // $result = array(); // $row = 0; // foreach($operand1 as $args) { // if (is_array($args)) { // foreach($args as $arg) { -// $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', $this->_showValue($arg), ' )'); +// $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', $this->showValue($arg), ' )'); // $r = call_user_func_array($functionCall, $arg); -// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r)); +// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->showTypeDetails($r)); // $result[$row][] = $r; // } // ++$row; // } else { -// $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', $this->_showValue($args), ' )'); +// $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', $this->showValue($args), ' )'); // $r = call_user_func_array($functionCall, $args); -// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r)); +// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->showTypeDetails($r)); // $result[] = $r; // } // } @@ -3534,9 +3890,9 @@ class PHPExcel_Calculation $result = call_user_func_array($functionCall, $args); } if ($functionName != 'MKMATRIX') { - $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->showTypeDetails($result)); } - $stack->push('Value', self::_wrapResult($result)); + $stack->push('Value', self::wrapResult($result)); } } else { @@ -3545,7 +3901,7 @@ class PHPExcel_Calculation $excelConstant = strtoupper($token); // echo 'Token is a PHPExcel constant: '.$excelConstant.'
'; $stack->push('Constant Value', self::$excelConstants[$excelConstant]); - $this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->_showTypeDetails(self::$excelConstants[$excelConstant])); + $this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant])); } 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); @@ -3557,7 +3913,7 @@ class PHPExcel_Calculation $this->_debugLog->writeDebugLog('Evaluating Named Range ', $namedRange); $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellWorksheet : null), false); $pCell->attach($pCellParent); - $this->_debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->_showTypeDetails($cellValue)); + $this->_debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->showTypeDetails($cellValue)); $stack->push('Named Range', $cellValue, $namedRange); } else { return $this->raiseFormulaError("undefined variable '$token'"); @@ -3592,19 +3948,19 @@ class PHPExcel_Calculation // We only need special validations for the operand if it is a string // Start by stripping off the quotation marks we use to identify true excel string values internally if ($operand > '' && $operand{0} == '"') { - $operand = self::_unwrapResult($operand); + $operand = self::unwrapResult($operand); } // If the string is a numeric value, we treat it as a numeric, so no further testing if (!is_numeric($operand)) { // If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations if ($operand > '' && $operand{0} == '#') { $stack->push('Value', $operand); - $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($operand)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($operand)); return false; } elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) { // If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations $stack->push('Value', '#VALUE!'); - $this->_debugLog->writeDebugLog('Evaluation Result is a ', $this->_showTypeDetails('#VALUE!')); + $this->_debugLog->writeDebugLog('Evaluation Result is a ', $this->showTypeDetails('#VALUE!')); return false; } } @@ -3622,31 +3978,31 @@ class PHPExcel_Calculation $result = array(); if ((is_array($operand1)) && (!is_array($operand2))) { foreach ($operand1 as $x => $operandData) { - $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2)); + $this->_debugLog->writeDebugLog('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->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operand1), ' ', $operation, ' ', $this->_showValue($operandData)); + $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->showValue($operand1), ' ', $operation, ' ', $this->showValue($operandData)); $this->executeBinaryComparisonOperation($cellID, $operand1, $operandData, $operation, $stack); $r = $stack->pop(); $result[$x] = $r['value']; } } else { if (!$recursingArrays) { - self::_checkMatrixOperands($operand1, $operand2, 2); + self::checkMatrixOperands($operand1, $operand2, 2); } foreach ($operand1 as $x => $operandData) { - $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2[$x])); + $this->_debugLog->writeDebugLog('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->_debugLog->writeDebugLog('Comparison Evaluation Result is ', $this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Comparison Evaluation Result is ', $this->showTypeDetails($result)); // And push the result onto the stack $stack->push('Array', $result); return true; @@ -3654,10 +4010,10 @@ class PHPExcel_Calculation // Simple validate the two operands if they are string values if (is_string($operand1) && $operand1 > '' && $operand1{0} == '"') { - $operand1 = self::_unwrapResult($operand1); + $operand1 = self::unwrapResult($operand1); } if (is_string($operand2) && $operand2 > '' && $operand2{0} == '"') { - $operand2 = self::_unwrapResult($operand2); + $operand2 = self::unwrapResult($operand2); } // Use case insensitive comparaison if not OpenOffice mode @@ -3729,7 +4085,7 @@ class PHPExcel_Calculation } // Log the result details - $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); // And push the result onto the stack $stack->push('Value', $result); return true; @@ -3764,7 +4120,7 @@ class PHPExcel_Calculation // matrix operation if ((is_array($operand1)) || (is_array($operand2))) { // Ensure that both operands are arrays/matrices of the same size - self::_checkMatrixOperands($operand1, $operand2, 2); + self::checkMatrixOperands($operand1, $operand2, 2); try { // Convert operand 1 from a PHP array to a matrix @@ -3801,7 +4157,7 @@ class PHPExcel_Calculation if ($operand2 == 0) { // Trap for Divide by Zero error $stack->push('Value', '#DIV/0!'); - $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails('#DIV/0!')); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails('#DIV/0!')); return false; } else { $result = $operand1 / $operand2; @@ -3816,7 +4172,7 @@ class PHPExcel_Calculation } // Log the result details - $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); + $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); // And push the result onto the stack $stack->push('Value', $result); return true; diff --git a/Classes/PHPExcel/Calculation/Database.php b/Classes/PHPExcel/Calculation/Database.php index af150fe0..b8d91cb6 100644 --- a/Classes/PHPExcel/Calculation/Database.php +++ b/Classes/PHPExcel/Calculation/Database.php @@ -126,7 +126,7 @@ class PHPExcel_Calculation_Database $k = array_search($criteriaName, $fieldNames); if (isset($dataValues[$k])) { $dataValue = $dataValues[$k]; - $dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue; + $dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::wrapResult(strtoupper($dataValue)) : $dataValue; $testConditionList = str_replace('[:' . $criteriaName . ']', $dataValue, $testConditionList); } } diff --git a/Classes/PHPExcel/Calculation/Functions.php b/Classes/PHPExcel/Calculation/Functions.php index 4d1771b9..9e7a5db1 100644 --- a/Classes/PHPExcel/Calculation/Functions.php +++ b/Classes/PHPExcel/Calculation/Functions.php @@ -323,7 +323,7 @@ class PHPExcel_Calculation_Functions } if (!in_array($condition{0}, array('>', '<', '='))) { if (!is_numeric($condition)) { - $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); + $condition = PHPExcel_Calculation::wrapResult(strtoupper($condition)); } return '=' . $condition; } else { @@ -332,7 +332,7 @@ class PHPExcel_Calculation_Functions if (!is_numeric($operand)) { $operand = str_replace('"', '""', $operand); - $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); + $operand = PHPExcel_Calculation::wrapResult(strtoupper($operand)); } return $operator.$operand; diff --git a/Classes/PHPExcel/Calculation/MathTrig.php b/Classes/PHPExcel/Calculation/MathTrig.php index 9d5a439e..dae2aa1e 100644 --- a/Classes/PHPExcel/Calculation/MathTrig.php +++ b/Classes/PHPExcel/Calculation/MathTrig.php @@ -1206,7 +1206,7 @@ class PHPExcel_Calculation_MathTrig foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { $arg = str_replace('"', '""', $arg); - $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); + $arg = PHPExcel_Calculation::wrapResult(strtoupper($arg)); } $testCondition = '='.$arg.$condition; diff --git a/Classes/PHPExcel/Calculation/Statistical.php b/Classes/PHPExcel/Calculation/Statistical.php index cd43dd6c..500f9509 100644 --- a/Classes/PHPExcel/Calculation/Statistical.php +++ b/Classes/PHPExcel/Calculation/Statistical.php @@ -877,7 +877,7 @@ class PHPExcel_Calculation_Statistical $aCount = 0; foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { - $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); + $arg = PHPExcel_Calculation::wrapResult(strtoupper($arg)); } $testCondition = '='.$arg.$condition; if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { @@ -1298,7 +1298,7 @@ class PHPExcel_Calculation_Statistical // Loop through arguments foreach ($aArgs as $arg) { if (!is_numeric($arg)) { - $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); + $arg = PHPExcel_Calculation::wrapResult(strtoupper($arg)); } $testCondition = '='.$arg.$condition; if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { @@ -2290,7 +2290,7 @@ class PHPExcel_Calculation_Statistical // Loop through arguments foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { - $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); + $arg = PHPExcel_Calculation::wrapResult(strtoupper($arg)); } $testCondition = '='.$arg.$condition; if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { @@ -2449,7 +2449,7 @@ class PHPExcel_Calculation_Statistical // Loop through arguments foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { - $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); + $arg = PHPExcel_Calculation::wrapResult(strtoupper($arg)); } $testCondition = '='.$arg.$condition; if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php index 8bc5dac9..c99a3c8b 100644 --- a/Classes/PHPExcel/Cell.php +++ b/Classes/PHPExcel/Cell.php @@ -27,7 +27,6 @@ */ class PHPExcel_Cell { - /** * Default range variable constant * @@ -227,6 +226,7 @@ class PHPExcel_Cell break; case PHPExcel_Cell_DataType::TYPE_STRING2: $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; + // no break case PHPExcel_Cell_DataType::TYPE_STRING: // Synonym for string case PHPExcel_Cell_DataType::TYPE_INLINE: diff --git a/Classes/PHPExcel/Chart.php b/Classes/PHPExcel/Chart.php index 326eac54..d7799935 100644 --- a/Classes/PHPExcel/Chart.php +++ b/Classes/PHPExcel/Chart.php @@ -32,98 +32,98 @@ class PHPExcel_Chart * * @var string */ - private $_name = ''; + private $name = ''; /** * Worksheet * * @var PHPExcel_Worksheet */ - private $_worksheet = null; + private $worksheet; /** * Chart Title * * @var PHPExcel_Chart_Title */ - private $_title = null; + private $title; /** * Chart Legend * * @var PHPExcel_Chart_Legend */ - private $_legend = null; + private $legend; /** * X-Axis Label * * @var PHPExcel_Chart_Title */ - private $_xAxisLabel = null; + private $xAxisLabel; /** * Y-Axis Label * * @var PHPExcel_Chart_Title */ - private $_yAxisLabel = null; + private $yAxisLabel; /** * Chart Plot Area * * @var PHPExcel_Chart_PlotArea */ - private $_plotArea = null; + private $plotArea; /** * Plot Visible Only * * @var boolean */ - private $_plotVisibleOnly = true; + private $plotVisibleOnly = true; /** * Display Blanks as * * @var string */ - private $_displayBlanksAs = '0'; + private $displayBlanksAs = '0'; /** * Chart Asix Y as * * @var PHPExcel_Chart_Axis */ - private $_yAxis = null; + private $yAxis; /** * Chart Asix X as * * @var PHPExcel_Chart_Axis */ - private $_xAxis = null; + private $xAxis; /** * Chart Major Gridlines as * * @var PHPExcel_Chart_GridLines */ - private $_majorGridlines = null; + private $majorGridlines; /** * Chart Minor Gridlines as * * @var PHPExcel_Chart_GridLines */ - private $_minorGridlines = null; + private $minorGridlines; /** * Top-Left Cell Position * * @var string */ - private $_topLeftCellRef = 'A1'; + private $topLeftCellRef = 'A1'; /** @@ -131,7 +131,7 @@ class PHPExcel_Chart * * @var integer */ - private $_topLeftXOffset = 0; + private $topLeftXOffset = 0; /** @@ -139,7 +139,7 @@ class PHPExcel_Chart * * @var integer */ - private $_topLeftYOffset = 0; + private $topLeftYOffset = 0; /** @@ -147,7 +147,7 @@ class PHPExcel_Chart * * @var string */ - private $_bottomRightCellRef = 'A1'; + private $bottomRightCellRef = 'A1'; /** @@ -155,7 +155,7 @@ class PHPExcel_Chart * * @var integer */ - private $_bottomRightXOffset = 10; + private $bottomRightXOffset = 10; /** @@ -163,7 +163,7 @@ class PHPExcel_Chart * * @var integer */ - private $_bottomRightYOffset = 10; + private $bottomRightYOffset = 10; /** @@ -171,18 +171,18 @@ class PHPExcel_Chart */ public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null) { - $this->_name = $name; - $this->_title = $title; - $this->_legend = $legend; - $this->_xAxisLabel = $xAxisLabel; - $this->_yAxisLabel = $yAxisLabel; - $this->_plotArea = $plotArea; - $this->_plotVisibleOnly = $plotVisibleOnly; - $this->_displayBlanksAs = $displayBlanksAs; - $this->_xAxis = $xAxis; - $this->_yAxis = $yAxis; - $this->_majorGridlines = $majorGridlines; - $this->_minorGridlines = $minorGridlines; + $this->name = $name; + $this->title = $title; + $this->legend = $legend; + $this->xAxisLabel = $xAxisLabel; + $this->yAxisLabel = $yAxisLabel; + $this->plotArea = $plotArea; + $this->plotVisibleOnly = $plotVisibleOnly; + $this->displayBlanksAs = $displayBlanksAs; + $this->xAxis = $xAxis; + $this->yAxis = $yAxis; + $this->majorGridlines = $majorGridlines; + $this->minorGridlines = $minorGridlines; } /** @@ -192,7 +192,7 @@ class PHPExcel_Chart */ public function getName() { - return $this->_name; + return $this->name; } /** @@ -202,7 +202,7 @@ class PHPExcel_Chart */ public function getWorksheet() { - return $this->_worksheet; + return $this->worksheet; } /** @@ -214,7 +214,7 @@ class PHPExcel_Chart */ public function setWorksheet(PHPExcel_Worksheet $pValue = null) { - $this->_worksheet = $pValue; + $this->worksheet = $pValue; return $this; } @@ -226,7 +226,7 @@ class PHPExcel_Chart */ public function getTitle() { - return $this->_title; + return $this->title; } /** @@ -237,7 +237,7 @@ class PHPExcel_Chart */ public function setTitle(PHPExcel_Chart_Title $title) { - $this->_title = $title; + $this->title = $title; return $this; } @@ -249,7 +249,7 @@ class PHPExcel_Chart */ public function getLegend() { - return $this->_legend; + return $this->legend; } /** @@ -260,7 +260,7 @@ class PHPExcel_Chart */ public function setLegend(PHPExcel_Chart_Legend $legend) { - $this->_legend = $legend; + $this->legend = $legend; return $this; } @@ -272,7 +272,7 @@ class PHPExcel_Chart */ public function getXAxisLabel() { - return $this->_xAxisLabel; + return $this->xAxisLabel; } /** @@ -283,7 +283,7 @@ class PHPExcel_Chart */ public function setXAxisLabel(PHPExcel_Chart_Title $label) { - $this->_xAxisLabel = $label; + $this->xAxisLabel = $label; return $this; } @@ -295,7 +295,7 @@ class PHPExcel_Chart */ public function getYAxisLabel() { - return $this->_yAxisLabel; + return $this->yAxisLabel; } /** @@ -306,7 +306,7 @@ class PHPExcel_Chart */ public function setYAxisLabel(PHPExcel_Chart_Title $label) { - $this->_yAxisLabel = $label; + $this->yAxisLabel = $label; return $this; } @@ -318,7 +318,7 @@ class PHPExcel_Chart */ public function getPlotArea() { - return $this->_plotArea; + return $this->plotArea; } /** @@ -328,7 +328,7 @@ class PHPExcel_Chart */ public function getPlotVisibleOnly() { - return $this->_plotVisibleOnly; + return $this->plotVisibleOnly; } /** @@ -339,7 +339,7 @@ class PHPExcel_Chart */ public function setPlotVisibleOnly($plotVisibleOnly = true) { - $this->_plotVisibleOnly = $plotVisibleOnly; + $this->plotVisibleOnly = $plotVisibleOnly; return $this; } @@ -351,7 +351,7 @@ class PHPExcel_Chart */ public function getDisplayBlanksAs() { - return $this->_displayBlanksAs; + return $this->displayBlanksAs; } /** @@ -362,7 +362,7 @@ class PHPExcel_Chart */ public function setDisplayBlanksAs($displayBlanksAs = '0') { - $this->_displayBlanksAs = $displayBlanksAs; + $this->displayBlanksAs = $displayBlanksAs; } @@ -373,8 +373,8 @@ class PHPExcel_Chart */ public function getChartAxisY() { - if ($this->_yAxis !== null) { - return $this->_yAxis; + if ($this->yAxis !== null) { + return $this->yAxis; } return new PHPExcel_Chart_Axis(); @@ -387,8 +387,8 @@ class PHPExcel_Chart */ public function getChartAxisX() { - if ($this->_xAxis !== null) { - return $this->_xAxis; + if ($this->xAxis !== null) { + return $this->xAxis; } return new PHPExcel_Chart_Axis(); @@ -401,8 +401,8 @@ class PHPExcel_Chart */ public function getMajorGridlines() { - if ($this->_majorGridlines !== null) { - return $this->_majorGridlines; + if ($this->majorGridlines !== null) { + return $this->majorGridlines; } return new PHPExcel_Chart_GridLines(); @@ -415,8 +415,8 @@ class PHPExcel_Chart */ public function getMinorGridlines() { - if ($this->_minorGridlines !== null) { - return $this->_minorGridlines; + if ($this->minorGridlines !== null) { + return $this->minorGridlines; } return new PHPExcel_Chart_GridLines(); @@ -433,7 +433,7 @@ class PHPExcel_Chart */ public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null) { - $this->_topLeftCellRef = $cell; + $this->topLeftCellRef = $cell; if (!is_null($xOffset)) { $this->setTopLeftXOffset($xOffset); } @@ -452,9 +452,9 @@ class PHPExcel_Chart public function getTopLeftPosition() { return array( - 'cell' => $this->_topLeftCellRef, - 'xOffset' => $this->_topLeftXOffset, - 'yOffset' => $this->_topLeftYOffset + 'cell' => $this->topLeftCellRef, + 'xOffset' => $this->topLeftXOffset, + 'yOffset' => $this->topLeftYOffset ); } @@ -465,7 +465,7 @@ class PHPExcel_Chart */ public function getTopLeftCell() { - return $this->_topLeftCellRef; + return $this->topLeftCellRef; } /** @@ -476,7 +476,7 @@ class PHPExcel_Chart */ public function setTopLeftCell($cell) { - $this->_topLeftCellRef = $cell; + $this->topLeftCellRef = $cell; return $this; } @@ -508,33 +508,33 @@ class PHPExcel_Chart public function getTopLeftOffset() { return array( - 'X' => $this->_topLeftXOffset, - 'Y' => $this->_topLeftYOffset + 'X' => $this->topLeftXOffset, + 'Y' => $this->topLeftYOffset ); } public function setTopLeftXOffset($xOffset) { - $this->_topLeftXOffset = $xOffset; + $this->topLeftXOffset = $xOffset; return $this; } public function getTopLeftXOffset() { - return $this->_topLeftXOffset; + return $this->topLeftXOffset; } public function setTopLeftYOffset($yOffset) { - $this->_topLeftYOffset = $yOffset; + $this->topLeftYOffset = $yOffset; return $this; } public function getTopLeftYOffset() { - return $this->_topLeftYOffset; + return $this->topLeftYOffset; } /** @@ -547,7 +547,7 @@ class PHPExcel_Chart */ public function setBottomRightPosition($cell, $xOffset = null, $yOffset = null) { - $this->_bottomRightCellRef = $cell; + $this->bottomRightCellRef = $cell; if (!is_null($xOffset)) { $this->setBottomRightXOffset($xOffset); } @@ -566,15 +566,15 @@ class PHPExcel_Chart public function getBottomRightPosition() { return array( - 'cell' => $this->_bottomRightCellRef, - 'xOffset' => $this->_bottomRightXOffset, - 'yOffset' => $this->_bottomRightYOffset + 'cell' => $this->bottomRightCellRef, + 'xOffset' => $this->bottomRightXOffset, + 'yOffset' => $this->bottomRightYOffset ); } public function setBottomRightCell($cell) { - $this->_bottomRightCellRef = $cell; + $this->bottomRightCellRef = $cell; return $this; } @@ -586,7 +586,7 @@ class PHPExcel_Chart */ public function getBottomRightCell() { - return $this->_bottomRightCellRef; + return $this->bottomRightCellRef; } /** @@ -616,40 +616,40 @@ class PHPExcel_Chart public function getBottomRightOffset() { return array( - 'X' => $this->_bottomRightXOffset, - 'Y' => $this->_bottomRightYOffset + 'X' => $this->bottomRightXOffset, + 'Y' => $this->bottomRightYOffset ); } public function setBottomRightXOffset($xOffset) { - $this->_bottomRightXOffset = $xOffset; + $this->bottomRightXOffset = $xOffset; return $this; } public function getBottomRightXOffset() { - return $this->_bottomRightXOffset; + return $this->bottomRightXOffset; } public function setBottomRightYOffset($yOffset) { - $this->_bottomRightYOffset = $yOffset; + $this->bottomRightYOffset = $yOffset; return $this; } public function getBottomRightYOffset() { - return $this->_bottomRightYOffset; + return $this->bottomRightYOffset; } public function refresh() { - if ($this->_worksheet !== null) { - $this->_plotArea->refresh($this->_worksheet); + if ($this->worksheet !== null) { + $this->plotArea->refresh($this->worksheet); } } diff --git a/Classes/PHPExcel/Chart/DataSeriesValues.php b/Classes/PHPExcel/Chart/DataSeriesValues.php index 23d185de..ea57e52a 100644 --- a/Classes/PHPExcel/Chart/DataSeriesValues.php +++ b/Classes/PHPExcel/Chart/DataSeriesValues.php @@ -288,7 +288,7 @@ class PHPExcel_Chart_DataSeriesValues { if ($this->dataSource !== null) { $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent()); - $newDataValues = PHPExcel_Calculation::_unwrapResult( + $newDataValues = PHPExcel_Calculation::unwrapResult( $calcEngine->_calculateFormulaValue( '='.$this->dataSource, null, diff --git a/Classes/PHPExcel/Comment.php b/Classes/PHPExcel/Comment.php index 0546f4ae..d55363fd 100644 --- a/Classes/PHPExcel/Comment.php +++ b/Classes/PHPExcel/Comment.php @@ -32,63 +32,63 @@ class PHPExcel_Comment implements PHPExcel_IComparable * * @var string */ - private $_author; + private $author; /** * Rich text comment * * @var PHPExcel_RichText */ - private $_text; + private $text; /** * Comment width (CSS style, i.e. XXpx or YYpt) * * @var string */ - private $_width = '96pt'; + private $width = '96pt'; /** * Left margin (CSS style, i.e. XXpx or YYpt) * * @var string */ - private $_marginLeft = '59.25pt'; + private $marginLeft = '59.25pt'; /** * Top margin (CSS style, i.e. XXpx or YYpt) * * @var string */ - private $_marginTop = '1.5pt'; + private $marginTop = '1.5pt'; /** * Visible * * @var boolean */ - private $_visible = false; + private $visible = false; /** * Comment height (CSS style, i.e. XXpx or YYpt) * * @var string */ - private $_height = '55.5pt'; + private $height = '55.5pt'; /** * Comment fill color * * @var PHPExcel_Style_Color */ - private $_fillColor; + private $fillColor; /** * Alignment * * @var string */ - private $_alignment; + private $alignment; /** * Create a new PHPExcel_Comment @@ -98,10 +98,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable public function __construct() { // Initialise variables - $this->_author = 'Author'; - $this->_text = new PHPExcel_RichText(); - $this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1'); - $this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; + $this->author = 'Author'; + $this->text = new PHPExcel_RichText(); + $this->fillColor = new PHPExcel_Style_Color('FFFFFFE1'); + $this->alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; } /** @@ -111,7 +111,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getAuthor() { - return $this->_author; + return $this->author; } /** @@ -122,7 +122,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setAuthor($pValue = '') { - $this->_author = $pValue; + $this->author = $pValue; return $this; } @@ -133,7 +133,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getText() { - return $this->_text; + return $this->text; } /** @@ -144,7 +144,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setText(PHPExcel_RichText $pValue) { - $this->_text = $pValue; + $this->text = $pValue; return $this; } @@ -155,7 +155,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getWidth() { - return $this->_width; + return $this->width; } /** @@ -166,7 +166,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setWidth($value = '96pt') { - $this->_width = $value; + $this->width = $value; return $this; } @@ -177,7 +177,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getHeight() { - return $this->_height; + return $this->height; } /** @@ -188,7 +188,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setHeight($value = '55.5pt') { - $this->_height = $value; + $this->height = $value; return $this; } @@ -199,7 +199,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getMarginLeft() { - return $this->_marginLeft; + return $this->marginLeft; } /** @@ -210,7 +210,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setMarginLeft($value = '59.25pt') { - $this->_marginLeft = $value; + $this->marginLeft = $value; return $this; } @@ -221,7 +221,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getMarginTop() { - return $this->_marginTop; + return $this->marginTop; } /** @@ -232,7 +232,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setMarginTop($value = '1.5pt') { - $this->_marginTop = $value; + $this->marginTop = $value; return $this; } @@ -243,7 +243,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getVisible() { - return $this->_visible; + return $this->visible; } /** @@ -254,7 +254,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setVisible($value = false) { - $this->_visible = $value; + $this->visible = $value; return $this; } @@ -265,7 +265,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getFillColor() { - return $this->_fillColor; + return $this->fillColor; } /** @@ -276,7 +276,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { - $this->_alignment = $pValue; + $this->alignment = $pValue; return $this; } @@ -287,7 +287,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function getAlignment() { - return $this->_alignment; + return $this->alignment; } /** @@ -298,16 +298,16 @@ class PHPExcel_Comment implements PHPExcel_IComparable public function getHashCode() { return md5( - $this->_author - . $this->_text->getHashCode() - . $this->_width - . $this->_height - . $this->_marginLeft - . $this->_marginTop - . ($this->_visible ? 1 : 0) - . $this->_fillColor->getHashCode() - . $this->_alignment - . __CLASS__ + $this->author . + $this->text->getHashCode() . + $this->width . + $this->height . + $this->marginLeft . + $this->marginTop . + ($this->visible ? 1 : 0) . + $this->fillColor->getHashCode() . + $this->alignment . + __CLASS__ ); } @@ -333,6 +333,6 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function __toString() { - return $this->_text->getPlainText(); + return $this->text->getPlainText(); } } diff --git a/Classes/PHPExcel/DocumentProperties.php b/Classes/PHPExcel/DocumentProperties.php index f52059f5..2395ba98 100644 --- a/Classes/PHPExcel/DocumentProperties.php +++ b/Classes/PHPExcel/DocumentProperties.php @@ -40,84 +40,84 @@ class PHPExcel_DocumentProperties * * @var string */ - private $_creator = 'Unknown Creator'; + private $creator = 'Unknown Creator'; /** * LastModifiedBy * * @var string */ - private $_lastModifiedBy; + private $lastModifiedBy; /** * Created * * @var datetime */ - private $_created; + private $created; /** * Modified * * @var datetime */ - private $_modified; + private $modified; /** * Title * * @var string */ - private $_title = 'Untitled Spreadsheet'; + private $title = 'Untitled Spreadsheet'; /** * Description * * @var string */ - private $_description = ''; + private $description = ''; /** * Subject * * @var string */ - private $_subject = ''; + private $subject = ''; /** * Keywords * * @var string */ - private $_keywords = ''; + private $keywords = ''; /** * Category * * @var string */ - private $_category = ''; + private $category = ''; /** * Manager * * @var string */ - private $_manager = ''; + private $manager = ''; /** * Company * * @var string */ - private $_company = 'Microsoft Corporation'; + private $company = 'Microsoft Corporation'; /** * Custom Properties * * @var string */ - private $_customProperties = array(); + private $customProperties = array(); /** @@ -126,9 +126,9 @@ class PHPExcel_DocumentProperties public function __construct() { // Initialise values - $this->_lastModifiedBy = $this->_creator; - $this->_created = time(); - $this->_modified = time(); + $this->lastModifiedBy = $this->creator; + $this->created = time(); + $this->modified = time(); } /** @@ -138,7 +138,7 @@ class PHPExcel_DocumentProperties */ public function getCreator() { - return $this->_creator; + return $this->creator; } /** @@ -149,7 +149,7 @@ class PHPExcel_DocumentProperties */ public function setCreator($pValue = '') { - $this->_creator = $pValue; + $this->creator = $pValue; return $this; } @@ -160,7 +160,7 @@ class PHPExcel_DocumentProperties */ public function getLastModifiedBy() { - return $this->_lastModifiedBy; + return $this->lastModifiedBy; } /** @@ -171,7 +171,7 @@ class PHPExcel_DocumentProperties */ public function setLastModifiedBy($pValue = '') { - $this->_lastModifiedBy = $pValue; + $this->lastModifiedBy = $pValue; return $this; } @@ -182,7 +182,7 @@ class PHPExcel_DocumentProperties */ public function getCreated() { - return $this->_created; + return $this->created; } /** @@ -203,7 +203,7 @@ class PHPExcel_DocumentProperties } } - $this->_created = $pValue; + $this->created = $pValue; return $this; } @@ -214,7 +214,7 @@ class PHPExcel_DocumentProperties */ public function getModified() { - return $this->_modified; + return $this->modified; } /** @@ -235,7 +235,7 @@ class PHPExcel_DocumentProperties } } - $this->_modified = $pValue; + $this->modified = $pValue; return $this; } @@ -246,7 +246,7 @@ class PHPExcel_DocumentProperties */ public function getTitle() { - return $this->_title; + return $this->title; } /** @@ -257,7 +257,7 @@ class PHPExcel_DocumentProperties */ public function setTitle($pValue = '') { - $this->_title = $pValue; + $this->title = $pValue; return $this; } @@ -268,7 +268,7 @@ class PHPExcel_DocumentProperties */ public function getDescription() { - return $this->_description; + return $this->description; } /** @@ -279,7 +279,7 @@ class PHPExcel_DocumentProperties */ public function setDescription($pValue = '') { - $this->_description = $pValue; + $this->description = $pValue; return $this; } @@ -290,7 +290,7 @@ class PHPExcel_DocumentProperties */ public function getSubject() { - return $this->_subject; + return $this->subject; } /** @@ -301,7 +301,7 @@ class PHPExcel_DocumentProperties */ public function setSubject($pValue = '') { - $this->_subject = $pValue; + $this->subject = $pValue; return $this; } @@ -312,7 +312,7 @@ class PHPExcel_DocumentProperties */ public function getKeywords() { - return $this->_keywords; + return $this->keywords; } /** @@ -323,7 +323,7 @@ class PHPExcel_DocumentProperties */ public function setKeywords($pValue = '') { - $this->_keywords = $pValue; + $this->keywords = $pValue; return $this; } @@ -334,7 +334,7 @@ class PHPExcel_DocumentProperties */ public function getCategory() { - return $this->_category; + return $this->category; } /** @@ -345,7 +345,7 @@ class PHPExcel_DocumentProperties */ public function setCategory($pValue = '') { - $this->_category = $pValue; + $this->category = $pValue; return $this; } @@ -356,7 +356,7 @@ class PHPExcel_DocumentProperties */ public function getCompany() { - return $this->_company; + return $this->company; } /** @@ -367,7 +367,7 @@ class PHPExcel_DocumentProperties */ public function setCompany($pValue = '') { - $this->_company = $pValue; + $this->company = $pValue; return $this; } @@ -378,7 +378,7 @@ class PHPExcel_DocumentProperties */ public function getManager() { - return $this->_manager; + return $this->manager; } /** @@ -389,7 +389,7 @@ class PHPExcel_DocumentProperties */ public function setManager($pValue = '') { - $this->_manager = $pValue; + $this->manager = $pValue; return $this; } @@ -400,7 +400,7 @@ class PHPExcel_DocumentProperties */ public function getCustomProperties() { - return array_keys($this->_customProperties); + return array_keys($this->customProperties); } /** @@ -411,7 +411,7 @@ class PHPExcel_DocumentProperties */ public function isCustomPropertySet($propertyName) { - return isset($this->_customProperties[$propertyName]); + return isset($this->customProperties[$propertyName]); } /** @@ -422,8 +422,8 @@ class PHPExcel_DocumentProperties */ public function getCustomPropertyValue($propertyName) { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['value']; + if (isset($this->customProperties[$propertyName])) { + return $this->customProperties[$propertyName]['value']; } } @@ -436,8 +436,8 @@ class PHPExcel_DocumentProperties */ public function getCustomPropertyType($propertyName) { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['type']; + if (isset($this->customProperties[$propertyName])) { + return $this->customProperties[$propertyName]['type']; } } @@ -475,7 +475,7 @@ class PHPExcel_DocumentProperties } } - $this->_customProperties[$propertyName] = array( + $this->customProperties[$propertyName] = array( 'value' => $propertyValue, 'type' => $propertyType ); diff --git a/Classes/PHPExcel/HashTable.php b/Classes/PHPExcel/HashTable.php index f752a363..c21d18c3 100644 --- a/Classes/PHPExcel/HashTable.php +++ b/Classes/PHPExcel/HashTable.php @@ -32,14 +32,14 @@ class PHPExcel_HashTable * * @var array */ - public $_items = array(); + protected $items = array(); /** * HashTable key map * * @var array */ - public $_keyMap = array(); + protected $keyMap = array(); /** * Create a new PHPExcel_HashTable @@ -84,9 +84,9 @@ class PHPExcel_HashTable public function add(PHPExcel_IComparable $pSource = null) { $hash = $pSource->getHashCode(); - if (!isset($this->_items[$hash])) { - $this->_items[$hash] = $pSource; - $this->_keyMap[count($this->_items) - 1] = $hash; + if (!isset($this->items[$hash])) { + $this->items[$hash] = $pSource; + $this->keyMap[count($this->items) - 1] = $hash; } } @@ -99,20 +99,20 @@ class PHPExcel_HashTable public function remove(PHPExcel_IComparable $pSource = null) { $hash = $pSource->getHashCode(); - if (isset($this->_items[$hash])) { - unset($this->_items[$hash]); + if (isset($this->items[$hash])) { + unset($this->items[$hash]); $deleteKey = -1; - foreach ($this->_keyMap as $key => $value) { + foreach ($this->keyMap as $key => $value) { if ($deleteKey >= 0) { - $this->_keyMap[$key - 1] = $value; + $this->keyMap[$key - 1] = $value; } if ($value == $hash) { $deleteKey = $key; } } - unset($this->_keyMap[count($this->_keyMap) - 1]); + unset($this->keyMap[count($this->keyMap) - 1]); } } @@ -122,8 +122,8 @@ class PHPExcel_HashTable */ public function clear() { - $this->_items = array(); - $this->_keyMap = array(); + $this->items = array(); + $this->keyMap = array(); } /** @@ -133,7 +133,7 @@ class PHPExcel_HashTable */ public function count() { - return count($this->_items); + return count($this->items); } /** @@ -144,7 +144,7 @@ class PHPExcel_HashTable */ public function getIndexForHashCode($pHashCode = '') { - return array_search($pHashCode, $this->_keyMap); + return array_search($pHashCode, $this->keyMap); } /** @@ -156,8 +156,8 @@ class PHPExcel_HashTable */ public function getByIndex($pIndex = 0) { - if (isset($this->_keyMap[$pIndex])) { - return $this->getByHashCode($this->_keyMap[$pIndex]); + if (isset($this->keyMap[$pIndex])) { + return $this->getByHashCode($this->keyMap[$pIndex]); } return null; @@ -172,8 +172,8 @@ class PHPExcel_HashTable */ public function getByHashCode($pHashCode = '') { - if (isset($this->_items[$pHashCode])) { - return $this->_items[$pHashCode]; + if (isset($this->items[$pHashCode])) { + return $this->items[$pHashCode]; } return null; @@ -186,7 +186,7 @@ class PHPExcel_HashTable */ public function toArray() { - return $this->_items; + return $this->items; } /** diff --git a/Classes/PHPExcel/IOFactory.php b/Classes/PHPExcel/IOFactory.php index bc1d99e3..3ecda177 100644 --- a/Classes/PHPExcel/IOFactory.php +++ b/Classes/PHPExcel/IOFactory.php @@ -43,7 +43,7 @@ class PHPExcel_IOFactory * @access private * @static */ - private static $_searchLocations = array( + private static $searchLocations = array( array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ), array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' ) ); @@ -55,7 +55,7 @@ class PHPExcel_IOFactory * @access private * @static */ - private static $_autoResolveClasses = array( + private static $autoResolveClasses = array( 'Excel2007', 'Excel5', 'Excel2003XML', @@ -82,7 +82,7 @@ class PHPExcel_IOFactory */ public static function getSearchLocations() { - return self::$_searchLocations; + return self::$searchLocations; } /** @@ -96,7 +96,7 @@ class PHPExcel_IOFactory public static function setSearchLocations($value) { if (is_array($value)) { - self::$_searchLocations = $value; + self::$searchLocations = $value; } else { throw new PHPExcel_Reader_Exception('Invalid parameter passed.'); } @@ -113,7 +113,7 @@ class PHPExcel_IOFactory */ public static function addSearchLocation($type = '', $location = '', $classname = '') { - self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname ); + self::$searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname ); } /** @@ -132,7 +132,7 @@ class PHPExcel_IOFactory $searchType = 'IWriter'; // Include class - foreach (self::$_searchLocations as $searchLocation) { + foreach (self::$searchLocations as $searchLocation) { if ($searchLocation['type'] == $searchType) { $className = str_replace('{0}', $writerType, $searchLocation['class']); @@ -162,7 +162,7 @@ class PHPExcel_IOFactory $searchType = 'IReader'; // Include class - foreach (self::$_searchLocations as $searchLocation) { + foreach (self::$searchLocations as $searchLocation) { if ($searchLocation['type'] == $searchType) { $className = str_replace('{0}', $readerType, $searchLocation['class']); @@ -273,8 +273,8 @@ class PHPExcel_IOFactory } // If we reach here then "lucky guess" didn't give any result - // Try walking through all the options in self::$_autoResolveClasses - foreach (self::$_autoResolveClasses as $autoResolveClass) { + // Try walking through all the options in self::$autoResolveClasses + foreach (self::$autoResolveClasses as $autoResolveClass) { // Ignore our original guess, we know that won't work if ($autoResolveClass !== $extensionType) { $reader = self::createReader($autoResolveClass); diff --git a/Classes/PHPExcel/NamedRange.php b/Classes/PHPExcel/NamedRange.php index 318bcf3b..2848db83 100644 --- a/Classes/PHPExcel/NamedRange.php +++ b/Classes/PHPExcel/NamedRange.php @@ -32,35 +32,35 @@ class PHPExcel_NamedRange * * @var string */ - private $_name; + private $name; /** * Worksheet on which the named range can be resolved * * @var PHPExcel_Worksheet */ - private $_worksheet; + private $worksheet; /** * Range of the referenced cells * * @var string */ - private $_range; + private $range; /** - * Is the named range local? (i.e. can only be used on $this->_worksheet) + * Is the named range local? (i.e. can only be used on $this->worksheet) * * @var bool */ - private $_localOnly; + private $localOnly; /** * Scope * * @var PHPExcel_Worksheet */ - private $_scope; + private $scope; /** * Create a new NamedRange @@ -80,12 +80,11 @@ class PHPExcel_NamedRange } // Set local members - $this->_name = $pName; - $this->_worksheet = $pWorksheet; - $this->_range = $pRange; - $this->_localOnly = $pLocalOnly; - $this->_scope = ($pLocalOnly == true) ? - (($pScope == null) ? $pWorksheet : $pScope) : null; + $this->name = $pName; + $this->worksheet = $pWorksheet; + $this->range = $pRange; + $this->localOnly = $pLocalOnly; + $this->scope = ($pLocalOnly == true) ? (($pScope == null) ? $pWorksheet : $pScope) : null; } /** @@ -95,7 +94,7 @@ class PHPExcel_NamedRange */ public function getName() { - return $this->_name; + return $this->name; } /** @@ -108,21 +107,21 @@ class PHPExcel_NamedRange { if ($value !== null) { // Old title - $oldTitle = $this->_name; + $oldTitle = $this->name; // Re-attach - if ($this->_worksheet !== null) { - $this->_worksheet->getParent()->removeNamedRange($this->_name, $this->_worksheet); + if ($this->worksheet !== null) { + $this->worksheet->getParent()->removeNamedRange($this->name, $this->worksheet); } - $this->_name = $value; + $this->name = $value; - if ($this->_worksheet !== null) { - $this->_worksheet->getParent()->addNamedRange($this); + if ($this->worksheet !== null) { + $this->worksheet->getParent()->addNamedRange($this); } // New title - $newTitle = $this->_name; - PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle); + $newTitle = $this->name; + PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->worksheet->getParent(), $oldTitle, $newTitle); } return $this; } @@ -134,7 +133,7 @@ class PHPExcel_NamedRange */ public function getWorksheet() { - return $this->_worksheet; + return $this->worksheet; } /** @@ -146,7 +145,7 @@ class PHPExcel_NamedRange public function setWorksheet(PHPExcel_Worksheet $value = null) { if ($value !== null) { - $this->_worksheet = $value; + $this->worksheet = $value; } return $this; } @@ -158,7 +157,7 @@ class PHPExcel_NamedRange */ public function getRange() { - return $this->_range; + return $this->range; } /** @@ -170,7 +169,7 @@ class PHPExcel_NamedRange public function setRange($value = null) { if ($value !== null) { - $this->_range = $value; + $this->range = $value; } return $this; } @@ -182,7 +181,7 @@ class PHPExcel_NamedRange */ public function getLocalOnly() { - return $this->_localOnly; + return $this->localOnly; } /** @@ -193,8 +192,8 @@ class PHPExcel_NamedRange */ public function setLocalOnly($value = false) { - $this->_localOnly = $value; - $this->_scope = $value ? $this->_worksheet : null; + $this->localOnly = $value; + $this->scope = $value ? $this->worksheet : null; return $this; } @@ -205,7 +204,7 @@ class PHPExcel_NamedRange */ public function getScope() { - return $this->_scope; + return $this->scope; } /** @@ -216,8 +215,8 @@ class PHPExcel_NamedRange */ public function setScope(PHPExcel_Worksheet $value = null) { - $this->_scope = $value; - $this->_localOnly = ($value == null) ? false : true; + $this->scope = $value; + $this->localOnly = ($value == null) ? false : true; return $this; } diff --git a/Classes/PHPExcel/Reader/CSV.php b/Classes/PHPExcel/Reader/CSV.php index d4fefd58..65e2d3b6 100644 --- a/Classes/PHPExcel/Reader/CSV.php +++ b/Classes/PHPExcel/Reader/CSV.php @@ -50,7 +50,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @access private * @var string */ - private $_inputEncoding = 'UTF-8'; + private $inputEncoding = 'UTF-8'; /** * Delimiter @@ -58,7 +58,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @access private * @var string */ - private $_delimiter = ','; + private $delimiter = ','; /** * Enclosure @@ -66,7 +66,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @access private * @var string */ - private $_enclosure = '"'; + private $enclosure = '"'; /** * Sheet index to read @@ -74,7 +74,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @access private * @var int */ - private $_sheetIndex = 0; + private $sheetIndex = 0; /** * Load rows contiguously @@ -82,21 +82,22 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @access private * @var int */ - private $_contiguous = false; + private $contiguous = false; /** * Row counter for loading rows contiguously * * @var int */ - private $_contiguousRow = -1; + private $contiguousRow = -1; /** * Create a new PHPExcel_Reader_CSV */ - public function __construct() { - $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); + public function __construct() + { + $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } /** @@ -106,7 +107,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R */ protected function _isValidFormat() { - return TRUE; + return true; } /** @@ -116,7 +117,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R */ public function setInputEncoding($pValue = 'UTF-8') { - $this->_inputEncoding = $pValue; + $this->inputEncoding = $pValue; return $this; } @@ -127,7 +128,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R */ public function getInputEncoding() { - return $this->_inputEncoding; + return $this->inputEncoding; } /** @@ -138,7 +139,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R { rewind($this->_fileHandle); - switch ($this->_inputEncoding) { + switch ($this->inputEncoding) { case 'UTF-8': fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ? fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0); @@ -175,7 +176,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; @@ -183,7 +184,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R // Skip BOM, if any $this->_skipBOM(); - $escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure ); + $escapeEnclosures = array( "\\" . $this->enclosure, $this->enclosure . $this->enclosure ); $worksheetInfo = array(); $worksheetInfo[0]['worksheetName'] = 'Worksheet'; @@ -193,7 +194,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R $worksheetInfo[0]['totalColumns'] = 0; // Loop through each line of the file in turn - while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { + while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) { $worksheetInfo[0]['totalRows']++; $worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1); } @@ -239,7 +240,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; @@ -248,32 +249,32 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R $this->_skipBOM(); // Create new PHPExcel object - while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { + while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) { $objPHPExcel->createSheet(); } - $sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex); + $sheet = $objPHPExcel->setActiveSheetIndex($this->sheetIndex); - $escapeEnclosures = array( "\\" . $this->_enclosure, - $this->_enclosure . $this->_enclosure + $escapeEnclosures = array( "\\" . $this->enclosure, + $this->enclosure . $this->enclosure ); // Set our starting row based on whether we're in contiguous mode or not $currentRow = 1; - if ($this->_contiguous) { - $currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow; + if ($this->contiguous) { + $currentRow = ($this->contiguousRow == -1) ? $sheet->getHighestRow(): $this->contiguousRow; } // Loop through each line of the file in turn - while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { + while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure)) !== false) { $columnLetter = 'A'; foreach ($rowData as $rowDatum) { if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) { // Unescape enclosures - $rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum); + $rowDatum = str_replace($escapeEnclosures, $this->enclosure, $rowDatum); // Convert encoding if necessary - if ($this->_inputEncoding !== 'UTF-8') { - $rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding); + if ($this->inputEncoding !== 'UTF-8') { + $rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding); } // Set cell value @@ -287,8 +288,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R // Close file fclose($fileHandle); - if ($this->_contiguous) { - $this->_contiguousRow = $currentRow; + if ($this->contiguous) { + $this->contiguousRow = $currentRow; } ini_set('auto_detect_line_endings', $lineEnding); @@ -302,8 +303,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return string */ - public function getDelimiter() { - return $this->_delimiter; + public function getDelimiter() + { + return $this->delimiter; } /** @@ -312,8 +314,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @param string $pValue Delimiter, defaults to , * @return PHPExcel_Reader_CSV */ - public function setDelimiter($pValue = ',') { - $this->_delimiter = $pValue; + public function setDelimiter($pValue = ',') + { + $this->delimiter = $pValue; return $this; } @@ -322,8 +325,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return string */ - public function getEnclosure() { - return $this->_enclosure; + public function getEnclosure() + { + return $this->enclosure; } /** @@ -332,11 +336,12 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @param string $pValue Enclosure, defaults to " * @return PHPExcel_Reader_CSV */ - public function setEnclosure($pValue = '"') { + public function setEnclosure($pValue = '"') + { if ($pValue == '') { $pValue = '"'; } - $this->_enclosure = $pValue; + $this->enclosure = $pValue; return $this; } @@ -345,8 +350,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return integer */ - public function getSheetIndex() { - return $this->_sheetIndex; + public function getSheetIndex() + { + return $this->sheetIndex; } /** @@ -355,8 +361,9 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @param integer $pValue Sheet index * @return PHPExcel_Reader_CSV */ - public function setSheetIndex($pValue = 0) { - $this->_sheetIndex = $pValue; + public function setSheetIndex($pValue = 0) + { + $this->sheetIndex = $pValue; return $this; } @@ -365,11 +372,11 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @param boolean $contiguous */ - public function setContiguous($contiguous = FALSE) + public function setContiguous($contiguous = false) { - $this->_contiguous = (bool) $contiguous; + $this->contiguous = (bool) $contiguous; if (!$contiguous) { - $this->_contiguousRow = -1; + $this->contiguousRow = -1; } return $this; @@ -380,8 +387,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return boolean */ - public function getContiguous() { - return $this->_contiguous; + public function getContiguous() + { + return $this->contiguous; } - } diff --git a/Classes/PHPExcel/Reader/DefaultReadFilter.php b/Classes/PHPExcel/Reader/DefaultReadFilter.php index 7caf2605..2e06dcbd 100644 --- a/Classes/PHPExcel/Reader/DefaultReadFilter.php +++ b/Classes/PHPExcel/Reader/DefaultReadFilter.php @@ -52,7 +52,8 @@ class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter * @param $worksheetName Optional worksheet name * @return boolean */ - public function readCell($column, $row, $worksheetName = '') { + public function readCell($column, $row, $worksheetName = '') + { return true; } } diff --git a/Classes/PHPExcel/Reader/Excel2003XML.php b/Classes/PHPExcel/Reader/Excel2003XML.php index e66ee1f1..feb0aaa0 100644 --- a/Classes/PHPExcel/Reader/Excel2003XML.php +++ b/Classes/PHPExcel/Reader/Excel2003XML.php @@ -1,6 +1,16 @@ _readFilter = new PHPExcel_Reader_DefaultReadFilter(); + $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } @@ -112,9 +103,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P // Retrieve charset encoding if (preg_match('//um', $data, $matches)) { - $this->_charSet = strtoupper($matches[1]); + $this->charSet = strtoupper($matches[1]); } -// echo 'Character Set is ', $this->_charSet,'
'; +// echo 'Character Set is ', $this->charSet,'
'; return $valid; } @@ -144,7 +135,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P $xml_ss = $xml->children($namespaces['ss']); foreach ($xml_ss->Worksheet as $worksheet) { $worksheet_ss = $worksheet->attributes($namespaces['ss']); - $worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->_charSet); + $worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet); } return $worksheetNames; @@ -239,7 +230,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P return $this->loadIntoExisting($pFilename, $objPHPExcel); } - protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) + protected static function identifyFixedStyleValue($styleList, &$styleAttributeValue) { $styleAttributeValue = strtolower($styleAttributeValue); foreach ($styleList as $style) { @@ -251,13 +242,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P return false; } - /** - * pixel units to excel width units(units of 1/256th of a character width) - * @param pxs - * @return - */ - protected static function _pixel2WidthUnits($pxs) - { + /** + * pixel units to excel width units(units of 1/256th of a character width) + * @param pxs + * @return + */ + protected static function _pixel2WidthUnits($pxs) + { $UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219); $widthUnits = 256 * ($pxs / 7); @@ -337,40 +328,40 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P if (isset($xml->DocumentProperties[0])) { foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) { switch ($propertyName) { - case 'Title' : - $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Title': + $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'Subject' : - $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Subject': + $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'Author' : - $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Author': + $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'Created' : + case 'Created': $creationDate = strtotime($propertyValue); $docProps->setCreated($creationDate); break; - case 'LastAuthor' : - $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'LastAuthor': + $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'LastSaved' : + case 'LastSaved': $lastSaveDate = strtotime($propertyValue); $docProps->setModified($lastSaveDate); break; - case 'Company' : - $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Company': + $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'Category' : - $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Category': + $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'Manager' : - $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Manager': + $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'Keywords' : - $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Keywords': + $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->charSet)); break; - case 'Description' : - $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet)); + case 'Description': + $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->charSet)); break; } } @@ -378,26 +369,26 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P if (isset($xml->CustomDocumentProperties)) { foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) { $propertyAttributes = $propertyValue->attributes($namespaces['dt']); - $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str', $propertyName); + $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/', 'PHPExcel_Reader_Excel2003XML::_hex2str', $propertyName); $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN; switch ((string) $propertyAttributes) { - case 'string' : + case 'string': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyValue = trim($propertyValue); break; - case 'boolean' : + case 'boolean': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; $propertyValue = (bool) $propertyValue; break; - case 'integer' : + case 'integer': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER; $propertyValue = intval($propertyValue); break; - case 'float' : + case 'float': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; $propertyValue = floatval($propertyValue); break; - case 'dateTime.tz' : + case 'dateTime.tz': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; $propertyValue = strtotime(trim($propertyValue)); break; @@ -411,125 +402,125 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P $styleID = (string) $style_ss['ID']; // echo 'Style ID = '.$styleID.'
'; if ($styleID == 'Default') { - $this->_styles['Default'] = array(); + $this->styles['Default'] = array(); } else { - $this->_styles[$styleID] = $this->_styles['Default']; + $this->styles[$styleID] = $this->styles['Default']; } foreach ($style as $styleType => $styleData) { $styleAttributes = $styleData->attributes($namespaces['ss']); // echo $styleType.'
'; switch ($styleType) { - case 'Alignment' : + case 'Alignment': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; $styleAttributeValue = (string) $styleAttributeValue; switch ($styleAttributeKey) { - case 'Vertical' : + case 'Vertical': if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) { - $this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; + $this->styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; } break; - case 'Horizontal' : + case 'Horizontal': if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) { - $this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; + $this->styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; } break; - case 'WrapText' : - $this->_styles[$styleID]['alignment']['wrap'] = true; + case 'WrapText': + $this->styles[$styleID]['alignment']['wrap'] = true; break; } } break; - case 'Borders' : + case 'Borders': foreach ($styleData->Border as $borderStyle) { $borderAttributes = $borderStyle->attributes($namespaces['ss']); $thisBorder = array(); foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) { // echo $borderStyleKey.' = '.$borderStyleValue.'
'; switch ($borderStyleKey) { - case 'LineStyle' : + case 'LineStyle': $thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; // $thisBorder['style'] = $borderStyleValue; break; - case 'Weight' : + case 'Weight': // $thisBorder['style'] = $borderStyleValue; break; - case 'Position' : + case 'Position': $borderPosition = strtolower($borderStyleValue); break; - case 'Color' : - $borderColour = substr($borderStyleValue,1); + case 'Color': + $borderColour = substr($borderStyleValue, 1); $thisBorder['color']['rgb'] = $borderColour; break; } } if (!empty($thisBorder)) { if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) { - $this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder; + $this->styles[$styleID]['borders'][$borderPosition] = $thisBorder; } } } break; - case 'Font' : + case 'Font': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; $styleAttributeValue = (string) $styleAttributeValue; switch ($styleAttributeKey) { - case 'FontName' : - $this->_styles[$styleID]['font']['name'] = $styleAttributeValue; + case 'FontName': + $this->styles[$styleID]['font']['name'] = $styleAttributeValue; break; - case 'Size' : - $this->_styles[$styleID]['font']['size'] = $styleAttributeValue; + case 'Size': + $this->styles[$styleID]['font']['size'] = $styleAttributeValue; break; - case 'Color' : - $this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1); + case 'Color': + $this->styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue, 1); break; - case 'Bold' : - $this->_styles[$styleID]['font']['bold'] = true; + case 'Bold': + $this->styles[$styleID]['font']['bold'] = true; break; - case 'Italic' : - $this->_styles[$styleID]['font']['italic'] = true; + case 'Italic': + $this->styles[$styleID]['font']['italic'] = true; break; - case 'Underline' : + case 'Underline': if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) { - $this->_styles[$styleID]['font']['underline'] = $styleAttributeValue; + $this->styles[$styleID]['font']['underline'] = $styleAttributeValue; } break; } } break; - case 'Interior' : + case 'Interior': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; switch ($styleAttributeKey) { - case 'Color' : - $this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1); + case 'Color': + $this->styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1); break; } } break; - case 'NumberFormat' : + case 'NumberFormat': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; $styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue); switch ($styleAttributeValue) { - case 'Short Date' : + case 'Short Date': $styleAttributeValue = 'dd/mm/yyyy'; break; } if ($styleAttributeValue > '') { - $this->_styles[$styleID]['numberformat']['code'] = $styleAttributeValue; + $this->styles[$styleID]['numberformat']['code'] = $styleAttributeValue; } } break; - case 'Protection' : + case 'Protection': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; } break; } } -// print_r($this->_styles[$styleID]); +// print_r($this->styles[$styleID]); // echo '
'; } // echo '
'; @@ -551,11 +542,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P $objPHPExcel->createSheet(); $objPHPExcel->setActiveSheetIndex($worksheetID); if (isset($worksheet_ss['Name'])) { - $worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->_charSet); + $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); + $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); } $columnID = 'A'; @@ -640,26 +631,26 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P const TYPE_INLINE = 'inlineStr'; const TYPE_ERROR = 'e'; */ - case 'String' : - $cellValue = self::_convertStringEncoding($cellValue, $this->_charSet); + case 'String': + $cellValue = self::_convertStringEncoding($cellValue, $this->charSet); $type = PHPExcel_Cell_DataType::TYPE_STRING; break; - case 'Number' : + case 'Number': $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $cellValue = (float) $cellValue; if (floor($cellValue) == $cellValue) { $cellValue = (integer) $cellValue; } break; - case 'Boolean' : + case 'Boolean': $type = PHPExcel_Cell_DataType::TYPE_BOOL; $cellValue = ($cellValue != 0); break; - case 'DateTime' : + case 'DateTime': $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue)); break; - case 'Error' : + case 'Error': $type = PHPExcel_Cell_DataType::TYPE_ERROR; break; } @@ -669,15 +660,15 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P // echo 'FORMULA
'; $type = PHPExcel_Cell_DataType::TYPE_FORMULA; $columnNumber = PHPExcel_Cell::columnIndexFromString($columnID); - if (substr($cellDataFormula,0,3) == 'of:') { - $cellDataFormula = substr($cellDataFormula,3); + if (substr($cellDataFormula, 0, 3) == 'of:') { + $cellDataFormula = substr($cellDataFormula, 3); // echo 'Before: ', $cellDataFormula,'
'; $temp = explode('"', $cellDataFormula); $key = false; foreach ($temp as &$value) { // Only replace in alternate array entries (i.e. non-quoted blocks) if ($key = !$key) { - $value = str_replace(array('[.','.',']'),'', $value); + $value = str_replace(array('[.', '.', ']'), '', $value); } } } else { @@ -688,7 +679,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P foreach ($temp as &$value) { // Only replace in alternate array entries (i.e. non-quoted blocks) if ($key = !$key) { - preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); + preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // through the formula from left to right. Reversing means that we work right to left.through // the formula @@ -703,7 +694,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } // Bracketed R references are relative to the current row if ($rowReference{0} == '[') { - $rowReference = $rowID + trim($rowReference,'[]'); + $rowReference = $rowID + trim($rowReference, '[]'); } $columnReference = $cellReference[4][0]; // Empty C reference is the current column @@ -712,10 +703,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } // Bracketed C references are relative to the current column if ($columnReference{0} == '[') { - $columnReference = $columnNumber + trim($columnReference,'[]'); + $columnReference = $columnNumber + trim($columnReference, '[]'); } $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; - $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0])); + $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); } } } @@ -749,20 +740,20 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P // echo $annotation,'
'; $annotation = strip_tags($node); // echo 'Annotation: ', $annotation,'
'; - $objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setAuthor(self::_convertStringEncoding($author , $this->_charSet))->setText($this->_parseRichText($annotation) ); + $objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->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])) && (!empty($this->_styles[$style]))) { + if ((isset($this->styles[$style])) && (!empty($this->styles[$style]))) { // echo 'Cell '.$columnID.$rowID.'
'; -// print_r($this->_styles[$style]); +// print_r($this->styles[$style]); // echo '
'; if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) { $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(null); } - $objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]); + $objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->styles[$style]); } } ++$columnID; @@ -807,7 +798,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P { $value = new PHPExcel_RichText(); - $value->createText(self::_convertStringEncoding($is, $this->_charSet)); + $value->createText(self::_convertStringEncoding($is, $this->charSet)); return $value; } diff --git a/Classes/PHPExcel/Reader/Excel2007.php b/Classes/PHPExcel/Reader/Excel2007.php index 9e62a852..47a130e3 100644 --- a/Classes/PHPExcel/Reader/Excel2007.php +++ b/Classes/PHPExcel/Reader/Excel2007.php @@ -1,6 +1,16 @@ _readFilter = new PHPExcel_Reader_DefaultReadFilter(); - $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); + $this->referenceHelper = PHPExcel_ReferenceHelper::getInstance(); } - /** * Can the current PHPExcel_Reader_IReader read the file? * @@ -85,7 +76,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $zipClass = PHPExcel_Settings::getZipClass(); // Check if zip class exists -// if (!class_exists($zipClass, FALSE)) { +// if (!class_exists($zipClass, false)) { // throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled"); // } @@ -210,7 +201,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $xml = new XMLReader(); $res = $xml->xml($this->securityScanFile('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet"), null, PHPExcel_Settings::getLibXmlLoaderOptions()); - $xml->setParserProperty(2,true); + $xml->setParserProperty(2, true); $currCells = 0; while ($xml->read()) { @@ -240,39 +231,39 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE return $worksheetInfo; } - - private static function _castToBool($c) { + private static function castToBoolean($c) + { // echo 'Initial Cast to Boolean', PHP_EOL; - $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) { + private static function castToError($c) + { // echo 'Initial Cast to Error', PHP_EOL; - return isset($c->v) ? (string) $c->v : NULL; - } // function _castToError() + return isset($c->v) ? (string) $c->v : null; + } - - private static function _castToString($c) { + private static function castToString($c) + { // echo 'Initial Cast to String, PHP_EOL; - return isset($c->v) ? (string) $c->v : NULL; - } // function _castToString() + return isset($c->v) ? (string) $c->v : null; + } - - private function _castToFormula($c, $r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas, $castBaseType) { + private function castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType) + { // echo 'Formula', PHP_EOL; // echo '$c->f is ', $c->f, PHP_EOL; - $cellDataType = 'f'; - $value = "={$c->f}"; - $calculatedValue = self::$castBaseType($c); + $cellDataType = 'f'; + $value = "={$c->f}"; + $calculatedValue = self::$castBaseType($c); // Shared formula? if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') { @@ -287,9 +278,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // echo 'SETTING NEW SHARED FORMULA', PHP_EOL; // echo 'Master is ', $r, PHP_EOL; // echo 'Formula is ', $value, PHP_EOL; - $sharedFormulas[$instance] = array( 'master' => $r, - 'formula' => $value - ); + $sharedFormulas[$instance] = array('master' => $r, 'formula' => $value); // echo 'New Shared Formula Array:', PHP_EOL; // print_r($sharedFormulas); } else { @@ -303,11 +292,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $difference[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]); $difference[1] = $current[1] - $master[1]; - $value = $this->_referenceHelper->updateFormulaReferences( $sharedFormulas[$instance]['formula'], - 'A1', - $difference[0], - $difference[1] - ); + $value = $this->referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]); // echo 'Adjusted Formula is ', $value, PHP_EOL; } } @@ -317,16 +302,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE public function _getFromZipArchive($archive, $fileName = '') { // Root-relative paths - if (strpos($fileName, '//') !== false) - { + if (strpos($fileName, '//') !== false) { $fileName = substr($fileName, strpos($fileName, '//') + 1); } $fileName = PHPExcel_Shared_File::realpath($fileName); // Apache POI fixes $contents = $archive->getFromName($fileName); - if ($contents === false) - { + if ($contents === false) { $contents = $archive->getFromName(substr($fileName, 1)); } @@ -366,7 +349,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE foreach ($wbRels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme": - $themeOrderArray = array('lt1','dk1','lt2','dk2'); + $themeOrderArray = array('lt1', 'dk1', 'lt2', 'dk2'); $themeOrderAdditional = count($themeOrderArray); $xmlTheme = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); @@ -393,7 +376,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $themeColours[$themePos] = $xmlColourData['val']; } } - self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName, $colourSchemeName, $themeColours); + self::$theme = new PHPExcel_Reader_Excel2007_Theme($themeName, $colourSchemeName, $themeColours); } break; } @@ -419,19 +402,19 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docProps->setKeywords((string) self::array_item($xmlCore->xpath("cp:keywords"))); $docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category"))); } - break; - + break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); - if (isset($xmlCore->Company)) + if (isset($xmlCore->Company)) { $docProps->setCompany((string) $xmlCore->Company); - if (isset($xmlCore->Manager)) + } + if (isset($xmlCore->Manager)) { $docProps->setManager((string) $xmlCore->Manager); + } } - break; - + break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { @@ -449,14 +432,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } } - break; + break; //Ribbon case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility": $customUI = $rel['Target']; if (!is_null($customUI)) { - $this->_readRibbon($excel, $customUI, $zip); + $this->readRibbon($excel, $customUI, $zip); } - break; + break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": $dir = dirname($rel["Target"]); $relsWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); @@ -468,24 +451,24 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlStrings) && isset($xmlStrings->si)) { foreach ($xmlStrings->si as $val) { if (isset($val->t)) { - $sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $val->t ); + $sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $val->t); } elseif (isset($val->r)) { - $sharedStrings[] = $this->_parseRichText($val); + $sharedStrings[] = $this->parseRichText($val); } } } $worksheets = array(); - $macros = $customUI = NULL; + $macros = $customUI = null; foreach ($relsWorkbook->Relationship as $ele) { switch ($ele['Type']) { - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": - $worksheets[(string) $ele["Id"]] = $ele["Target"]; - break; - // a vbaProject ? (: some macros) - case "http://schemas.microsoft.com/office/2006/relationships/vbaProject": - $macros = $ele["Target"]; - break; + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": + $worksheets[(string) $ele["Id"]] = $ele["Target"]; + break; + // a vbaProject ? (: some macros) + case "http://schemas.microsoft.com/office/2006/relationships/vbaProject": + $macros = $ele["Target"]; + break; } } @@ -496,8 +479,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $excel->setHasMacros(true); //short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir $Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin'); - if ($Certificate !== false) + if ($Certificate !== false) { $excel->setMacrosCertificate($Certificate); + } } } $styles = array(); @@ -508,7 +492,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($xmlStyles && $xmlStyles->numFmts[0]) { $numFmts = $xmlStyles->numFmts[0]; } - if (isset($numFmts) && ($numFmts !== NULL)) { + if (isset($numFmts) && ($numFmts !== null)) { $numFmts->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"); } if (!$this->_readDataOnly && $xmlStyles) { @@ -548,7 +532,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // add style to cellXf collection $objStyle = new PHPExcel_Style; - self::_readStyle($objStyle, $style); + self::readStyle($objStyle, $style); $excel->addCellXf($objStyle); } @@ -558,7 +542,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); if (isset($tmpNumFmt["formatCode"])) { $numFmt = (string) $tmpNumFmt["formatCode"]; - } else if ((int)$xf["numFmtId"] < 165) { + } elseif ((int)$xf["numFmtId"] < 165) { $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]); } } @@ -576,7 +560,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // add style to cellStyleXf collection $objStyle = new PHPExcel_Style; - self::_readStyle($objStyle, $cellStyle); + self::readStyle($objStyle, $cellStyle); $excel->addCellStyleXf($objStyle); } } @@ -586,8 +570,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Conditional Styles if ($xmlStyles->dxfs) { foreach ($xmlStyles->dxfs->dxf as $dxf) { - $style = new PHPExcel_Style(FALSE, TRUE); - self::_readStyle($style, $dxf); + $style = new PHPExcel_Style(false, true); + self::readStyle($style, $dxf); $dxfs[] = $style; } } @@ -598,7 +582,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($cellStyles[intval($cellStyle['xfId'])])) { // Set default style $style = new PHPExcel_Style; - self::_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]); + self::readStyle($style, $cellStyles[intval($cellStyle['xfId'])]); // normal style, currently not using it for anything } @@ -624,7 +608,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $countSkippedSheets = 0; // keep track of number of skipped sheets $mapSheetId = array(); // mapping of sheet ids from old to new - $charts = $chartDetails = array(); if ($xmlWorkbook->sheets) { @@ -648,44 +631,38 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // 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); + $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->securityScan($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $sharedFormulas = array(); if (isset($eleSheet["state"]) && (string) $eleSheet["state"] != '') { - $docSheet->setSheetState( (string) $eleSheet["state"] ); + $docSheet->setSheetState((string) $eleSheet["state"]); } if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) { if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { - $docSheet->getSheetView()->setZoomScale( intval($xmlSheet->sheetViews->sheetView['zoomScale']) ); + $docSheet->getSheetView()->setZoomScale(intval($xmlSheet->sheetViews->sheetView['zoomScale'])); } - if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { - $docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']) ); + $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(self::boolean((string)$xmlSheet->sheetViews->sheetView['showGridLines'])); } - if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { $docSheet->setShowRowColHeaders(self::boolean((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'])); } - if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { $docSheet->setRightToLeft(self::boolean((string)$xmlSheet->sheetViews->sheetView['rightToLeft'])); } - if (isset($xmlSheet->sheetViews->sheetView->pane)) { if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { - $docSheet->freezePane( (string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell'] ); + $docSheet->freezePane((string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell']); } else { $xSplit = 0; $ySplit = 0; @@ -710,12 +687,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docSheet->setSelectedCells($sqref); } } - } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) { if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { - $docSheet->getTabColor()->setARGB( (string)$xmlSheet->sheetPr->tabColor['rgb'] ); + $docSheet->getTabColor()->setARGB((string)$xmlSheet->sheetPr->tabColor['rgb']); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr['codeName'])) { @@ -724,25 +700,25 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) { if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { - $docSheet->setShowSummaryRight(FALSE); + $docSheet->setShowSummaryRight(false); } else { - $docSheet->setShowSummaryRight(TRUE); + $docSheet->setShowSummaryRight(true); } if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) { - $docSheet->setShowSummaryBelow(FALSE); + $docSheet->setShowSummaryBelow(false); } else { - $docSheet->setShowSummaryBelow(TRUE); + $docSheet->setShowSummaryBelow(true); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) { if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { - $docSheet->getPageSetup()->setFitToPage(FALSE); + $docSheet->getPageSetup()->setFitToPage(false); } else { - $docSheet->getPageSetup()->setFitToPage(TRUE); + $docSheet->getPageSetup()->setFitToPage(true); } } @@ -750,10 +726,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->sheetFormatPr['customHeight']) && self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { - $docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] ); + $docSheet->getDefaultRowDimension()->setRowHeight((float)$xmlSheet->sheetFormatPr['defaultRowHeight']); } if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { - $docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] ); + $docSheet->getDefaultColumnDimension()->setWidth((float)$xmlSheet->sheetFormatPr['defaultColWidth']); } if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && ((string)$xmlSheet->sheetFormatPr['zeroHeight'] == '1')) { @@ -768,14 +744,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"])); } if (self::boolean($col["bestFit"])) { - //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE); + //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true); } if (self::boolean($col["hidden"])) { - // echo PHPExcel_Cell::stringFromColumnIndex($i),': HIDDEN COLUMN',PHP_EOL; - $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE); + // echo PHPExcel_Cell::stringFromColumnIndex($i), ': HIDDEN COLUMN',PHP_EOL; + $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false); } if (self::boolean($col["collapsed"])) { - $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(TRUE); + $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true); } if ($col["outlineLevel"] > 0) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"])); @@ -791,18 +767,16 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) { if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) { - $docSheet->setShowGridlines(TRUE); + $docSheet->setShowGridlines(true); } - if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) { - $docSheet->setPrintGridlines(TRUE); + $docSheet->setPrintGridlines(true); } - if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) { - $docSheet->getPageSetup()->setHorizontalCentered(TRUE); + $docSheet->getPageSetup()->setHorizontalCentered(true); } if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) { - $docSheet->getPageSetup()->setVerticalCentered(TRUE); + $docSheet->getPageSetup()->setVerticalCentered(true); } } @@ -812,10 +786,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"])); } if (self::boolean($row["hidden"]) && !$this->_readDataOnly) { - $docSheet->getRowDimension(intval($row["r"]))->setVisible(FALSE); + $docSheet->getRowDimension(intval($row["r"]))->setVisible(false); } if (self::boolean($row["collapsed"])) { - $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(TRUE); + $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true); } if ($row["outlineLevel"] > 0) { $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"])); @@ -831,7 +805,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $calculatedValue = null; // Read cell? - if ($this->getReadFilter() !== NULL) { + if ($this->getReadFilter() !== null) { $coordinates = PHPExcel_Cell::coordinateFromString($r); if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) { @@ -857,15 +831,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } else { $value = ''; } - break; case "b": // echo 'Boolean', PHP_EOL; if (!isset($c->f)) { - $value = self::_castToBool($c); + $value = self::castToBoolean($c); } else { // Formula - $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToBool'); + $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToBoolean'); if (isset($c->f['t'])) { $att = array(); $att = $c->f; @@ -876,42 +849,42 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE break; case "inlineStr": // echo 'Inline String', PHP_EOL; - $value = $this->_parseRichText($c->is); - + $value = $this->parseRichText($c->is); break; case "e": // echo 'Error', PHP_EOL; if (!isset($c->f)) { - $value = self::_castToError($c); + $value = self::castToError($c); } else { // Formula - $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToError'); + $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); // echo '$calculatedValue = ', $calculatedValue, PHP_EOL; } - break; - default: // echo 'Default', PHP_EOL; if (!isset($c->f)) { // echo 'Not a Formula', PHP_EOL; - $value = self::_castToString($c); + $value = self::castToString($c); } else { // echo 'Treat as Formula', PHP_EOL; // Formula - $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToString'); + $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToString'); // echo '$calculatedValue = ', $calculatedValue, PHP_EOL; } - break; } // echo 'Value is ', $value, PHP_EOL; // Check for numeric values if (is_numeric($value) && $cellDataType != 's') { - if ($value == (int)$value) $value = (int)$value; - elseif ($value == (float)$value) $value = (float)$value; - elseif ($value == (double)$value) $value = (double)$value; + if ($value == (int)$value) { + $value = (int)$value; + } elseif ($value == (float)$value) { + $value = (float)$value; + } elseif ($value == (double)$value) { + $value = (double)$value; + } } // Rich text? @@ -926,7 +899,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } else { $cell->setValue($value); } - if ($calculatedValue !== NULL) { + if ($calculatedValue !== null) { $cell->setCalculatedValue($calculatedValue); } @@ -944,14 +917,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { foreach ($xmlSheet->conditionalFormatting as $conditional) { foreach ($conditional->cfRule as $cfRule) { - if ( - ( - (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || - (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || - (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || - (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION - ) && isset($dxfs[intval($cfRule["dxfId"])]) - ) { + if (((string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) && isset($dxfs[intval($cfRule["dxfId"])])) { $conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule; } } @@ -997,7 +963,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { - $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], TRUE); + $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true); if ($xmlSheet->protectedRanges->protectedRange) { foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { $docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true); @@ -1018,25 +984,20 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $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); + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule(null, '')->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); + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule(null, (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 + // Operator is undefined, but always treated as EQUAL + null, array( 'year' => (string) $dateGroupItem["year"], 'month' => (string) $dateGroupItem["month"], @@ -1073,16 +1034,17 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // 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 + // Operator is undefined, but always treated as EQUAL + null, (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"]); + $column->setAttribute('val', (string) $filterRule["val"]); } if (isset($filterRule["maxVal"])) { - $column->setAttribute('maxVal',(string) $filterRule["maxVal"]); + $column->setAttribute('maxVal', (string) $filterRule["maxVal"]); } } } @@ -1112,7 +1074,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) { foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) { $mergeRef = (string) $mergeCell["ref"]; - if (strpos($mergeRef,':') !== FALSE) { + if (strpos($mergeRef, ':') !== false) { $docSheet->mergeCells((string) $mergeCell["ref"]); } } @@ -1138,13 +1100,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"])); } if (isset($xmlSheet->pageSetup["scale"])) { - $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), FALSE); + $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), false); } if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) { - $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), FALSE); + $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), false); } if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) { - $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), FALSE); + $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), false); } if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) && self::boolean((string) $xmlSheet->pageSetup["useFirstPageNumber"])) { @@ -1157,27 +1119,27 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->headerFooter["differentOddEven"]) && self::boolean((string)$xmlSheet->headerFooter["differentOddEven"])) { - $docHeaderFooter->setDifferentOddEven(TRUE); + $docHeaderFooter->setDifferentOddEven(true); } else { - $docHeaderFooter->setDifferentOddEven(FALSE); + $docHeaderFooter->setDifferentOddEven(false); } if (isset($xmlSheet->headerFooter["differentFirst"]) && self::boolean((string)$xmlSheet->headerFooter["differentFirst"])) { - $docHeaderFooter->setDifferentFirst(TRUE); + $docHeaderFooter->setDifferentFirst(true); } else { - $docHeaderFooter->setDifferentFirst(FALSE); + $docHeaderFooter->setDifferentFirst(false); } if (isset($xmlSheet->headerFooter["scaleWithDoc"]) && !self::boolean((string)$xmlSheet->headerFooter["scaleWithDoc"])) { - $docHeaderFooter->setScaleWithDocument(FALSE); + $docHeaderFooter->setScaleWithDocument(false); } else { - $docHeaderFooter->setScaleWithDocument(TRUE); + $docHeaderFooter->setScaleWithDocument(true); } if (isset($xmlSheet->headerFooter["alignWithMargins"]) && !self::boolean((string)$xmlSheet->headerFooter["alignWithMargins"])) { - $docHeaderFooter->setAlignWithMargins(FALSE); + $docHeaderFooter->setAlignWithMargins(false); } else { - $docHeaderFooter->setAlignWithMargins(TRUE); + $docHeaderFooter->setAlignWithMargins(true); } $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); @@ -1239,7 +1201,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (!$this->_readDataOnly) { // Locate hyperlink relations if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { $hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"]; @@ -1254,7 +1216,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { - $cell = $docSheet->getCell( $cellReference ); + $cell = $docSheet->getCell($cellReference); if (isset($linkRel['id'])) { $hyperlinkUrl = $hyperlinks[ (string)$linkRel['id'] ]; if (isset($hyperlink['location'])) { @@ -1262,12 +1224,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } $cell->getHyperlink()->setUrl($hyperlinkUrl); } elseif (isset($hyperlink['location'])) { - $cell->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] ); + $cell->getHyperlink()->setUrl('sheet://' . (string)$hyperlink['location']); } // Tooltip if (isset($hyperlink['tooltip'])) { - $cell->getHyperlink()->setTooltip( (string)$hyperlink['tooltip'] ); + $cell->getHyperlink()->setTooltip((string)$hyperlink['tooltip']); } } } @@ -1280,7 +1242,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (!$this->_readDataOnly) { // Locate comment relations if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") { $comments[(string)$ele["Id"]] = (string)$ele["Target"]; @@ -1307,9 +1269,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Loop through contents foreach ($commentsFile->commentList->comment as $comment) { - if (!empty($comment['authorId'])) - $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] ); - $docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) ); + if (!empty($comment['authorId'])) { + $docSheet->getComment((string)$comment['ref'])->setAuthor($authors[(string)$comment['authorId']]); + } + $docSheet->getComment((string)$comment['ref'])->setText($this->parseRichText($comment->text)); } } @@ -1326,7 +1289,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($shape['style'])) { $style = (string)$shape['style']; - $fillColor = strtoupper( substr( (string)$shape['fillcolor'], 1 ) ); + $fillColor = strtoupper(substr((string)$shape['fillcolor'], 1)); $column = null; $row = null; @@ -1334,31 +1297,44 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (is_array($clientData) && !empty($clientData)) { $clientData = $clientData[0]; - if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) { + if (isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note') { $temp = $clientData->xpath('.//x:Row'); - if (is_array($temp)) $row = $temp[0]; + if (is_array($temp)) { + $row = $temp[0]; + } $temp = $clientData->xpath('.//x:Column'); - if (is_array($temp)) $column = $temp[0]; + if (is_array($temp)) { + $column = $temp[0]; + } } } - if (($column !== NULL) && ($row !== NULL)) { + if (($column !== null) && ($row !== null)) { // Set comment properties $comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1); - $comment->getFillColor()->setRGB( $fillColor ); + $comment->getFillColor()->setRGB($fillColor); // Parse style $styleArray = explode(';', str_replace(' ', '', $style)); foreach ($styleArray as $stylePair) { $stylePair = explode(':', $stylePair); - if ($stylePair[0] == 'margin-left') $comment->setMarginLeft($stylePair[1]); - if ($stylePair[0] == 'margin-top') $comment->setMarginTop($stylePair[1]); - if ($stylePair[0] == 'width') $comment->setWidth($stylePair[1]); - if ($stylePair[0] == 'height') $comment->setHeight($stylePair[1]); - if ($stylePair[0] == 'visibility') $comment->setVisible( $stylePair[1] == 'visible' ); - + if ($stylePair[0] == 'margin-left') { + $comment->setMarginLeft($stylePair[1]); + } + if ($stylePair[0] == 'margin-top') { + $comment->setMarginTop($stylePair[1]); + } + if ($stylePair[0] == 'width') { + $comment->setWidth($stylePair[1]); + } + if ($stylePair[0] == 'height') { + $comment->setHeight($stylePair[1]); + } + if ($stylePair[0] == 'visibility') { + $comment->setVisible($stylePair[1] == 'visible'); + } } } } @@ -1368,7 +1344,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Header/footer images if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) { if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $vmlRelationship = ''; foreach ($relsWorksheet->Relationship as $ele) { @@ -1379,7 +1355,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($vmlRelationship != '') { // Fetch linked images - $relsVML = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsVML = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $drawings = array(); foreach ($relsVML->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") { @@ -1400,11 +1376,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $imageData = $imageData[$idx]; $imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office'); - $style = self::toCSSArray( (string)$shape['style'] ); + $style = self::toCSSArray((string)$shape['style']); $hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing(); if (isset($imageData['title'])) { - $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] ); + $hfImages[ (string)$shape['id'] ]->setName((string)$imageData['title']); } $hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false); @@ -1427,7 +1403,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // TODO: Autoshapes from twoCellAnchors! if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $drawings = array(); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") { @@ -1437,7 +1413,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($xmlSheet->drawing && !$this->_readDataOnly) { foreach ($xmlSheet->drawing as $drawing) { $fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; - $relsDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $images = array(); if ($relsDrawing && $relsDrawing->Relationship) { @@ -1446,9 +1422,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $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() - ); + $charts[self::dir_add($fileDrawing, $ele["Target"])] = array( + 'id' => (string) $ele["Id"], + 'sheet' => $docSheet->getTitle() + ); } } } @@ -1490,8 +1467,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $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")); + $width = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx")); + $height = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy")); } } } @@ -1527,29 +1504,28 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } $objDrawing->setWorksheet($docSheet); } elseif (($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) { - $fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1); + $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); + $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"); + $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() - ); + $chartDetails[$docSheet->getTitle().'!'.$thisChart] = array( + 'fromCoordinate' => $fromCoordinate, + 'fromOffsetX' => $fromOffsetX, + 'fromOffsetY' => $fromOffsetY, + 'toCoordinate' => $toCoordinate, + 'toOffsetX' => $toOffsetX, + 'toOffsetY' => $toOffsetY, + 'worksheetTitle' => $docSheet->getTitle() + ); } } } - } } } @@ -1560,14 +1536,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Extract range $extractedRange = (string)$definedName; $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); - if (($spos = strpos($extractedRange,'!')) !== false) { - $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos)); + if (($spos = strpos($extractedRange, '!')) !== false) { + $extractedRange = substr($extractedRange, 0, $spos).str_replace('$', '', substr($extractedRange, $spos)); } else { $extractedRange = str_replace('$', '', $extractedRange); } // Valid range? - if (stripos((string)$definedName, '#REF!') !== FALSE || $extractedRange == '') { + if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') { continue; } @@ -1575,7 +1551,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ((string)$definedName['localSheetId'] != '' && (string)$definedName['localSheetId'] == $sheetId) { // Switch on type switch ((string)$definedName['name']) { - case '_xlnm._FilterDatabase': if ((string)$definedName['hidden'] !== '1') { $extractedRange = explode(',', $extractedRange); @@ -1587,7 +1562,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } break; - case '_xlnm.Print_Titles': // Split $extractedRange $extractedRange = explode(',', $extractedRange); @@ -1600,21 +1574,19 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // check for repeating columns, e g. 'A:A' or 'A:D' if (preg_match('/!?([A-Z]+)\:([A-Z]+)$/', $range, $matches)) { $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($matches[1], $matches[2])); - } - // check for repeating rows, e.g. '1:1' or '1:5' - elseif (preg_match('/!?(\d+)\:(\d+)$/', $range, $matches)) { + } elseif (preg_match('/!?(\d+)\:(\d+)$/', $range, $matches)) { + // check for repeating rows, e.g. '1:1' or '1:5' $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($matches[1], $matches[2])); } } break; - case '_xlnm.Print_Area': $rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma? $newRangeSets = array(); foreach ($rangeSets as $rangeSet) { $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $rangeSet = isset($range[1]) ? $range[1] : $range[0]; - if (strpos($rangeSet, ':') === FALSE) { + if (strpos($rangeSet, ':') === false) { $rangeSet = $rangeSet . ':' . $rangeSet; } $newRangeSets[] = str_replace('$', '', $rangeSet); @@ -1639,8 +1611,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Extract range $extractedRange = (string)$definedName; $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); - if (($spos = strpos($extractedRange,'!')) !== false) { - $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos)); + if (($spos = strpos($extractedRange, '!')) !== false) { + $extractedRange = substr($extractedRange, 0, $spos).str_replace('$', '', substr($extractedRange, $spos)); } else { $extractedRange = str_replace('$', '', $extractedRange); } @@ -1655,12 +1627,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Local defined name // Switch on type switch ((string)$definedName['name']) { - case '_xlnm._FilterDatabase': case '_xlnm.Print_Titles': case '_xlnm.Print_Area': break; - default: if ($mapSheetId[(integer) $definedName['localSheetId']] !== null) { $range = explode('!', (string)$definedName); @@ -1670,19 +1640,19 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); $scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]); - $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) ); + $excel->addNamedRange(new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope)); } } } break; } - } else if (!isset($definedName['localSheetId'])) { + } elseif (!isset($definedName['localSheetId'])) { // "Global" definedNames $locatedSheet = null; $extractedSheetName = ''; - if (strpos( (string)$definedName, '!' ) !== false) { + if (strpos((string)$definedName, '!') !== false) { // Extract sheet name - $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true ); + $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle((string)$definedName, true); $extractedSheetName = $extractedSheetName[0]; // Locate sheet @@ -1693,8 +1663,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $extractedRange = isset($range[1]) ? $range[1] : $range[0]; } - if ($locatedSheet !== NULL) { - $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) ); + if ($locatedSheet !== null) { + $excel->addNamedRange(new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false)); } } } @@ -1715,41 +1685,33 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $excel->setActiveSheetIndex(0); } } - break; + break; } - } - if (!$this->_readDataOnly) { $contentTypes = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "[Content_Types].xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); foreach ($contentTypes->Override as $contentType) { switch ($contentType["ContentType"]) { case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": if ($this->_includeCharts) { - $chartEntryRef = ltrim($contentType['PartName'],'/'); + $chartEntryRef = ltrim($contentType['PartName'], '/'); $chartElements = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $chartEntryRef)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); - $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml')); + $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements, basename($chartEntryRef, '.xml')); -// echo 'Chart ', $chartEntryRef,'
'; +// echo 'Chart ', $chartEntryRef, '
'; // var_dump($charts[$chartEntryRef]); // if (isset($charts[$chartEntryRef])) { $chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id']; -// echo 'Position Ref ', $chartPositionRef,'
'; +// 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'] - ); + $objChart->setTopLeftPosition($chartDetails[$chartPositionRef]['fromCoordinate'], $chartDetails[$chartPositionRef]['fromOffsetX'], $chartDetails[$chartPositionRef]['fromOffsetY']); + $objChart->setBottomRightPosition($chartDetails[$chartPositionRef]['toCoordinate'], $chartDetails[$chartPositionRef]['toOffsetX'], $chartDetails[$chartPositionRef]['toOffsetY']); } } } @@ -1762,15 +1724,15 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE 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"])) { + } elseif (isset($color["indexed"])) { return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB(); - } else if (isset($color["theme"])) { - if (self::$_theme !== NULL) { - $returnColour = self::$_theme->getColourByIndex((int)$color["theme"]); + } elseif (isset($color["theme"])) { + if (self::$theme !== null) { + $returnColour = self::$theme->getColourByIndex((int)$color["theme"]); if (isset($color["tint"])) { $tintAdjust = (float) $color["tint"]; $returnColour = PHPExcel_Style_Color::changeBrightness($returnColour, $tintAdjust); @@ -1785,8 +1747,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE return 'FF000000'; } - - private static function _readStyle($docStyle, $style) { + private static function readStyle($docStyle, $style) + { // format code // if (isset($style->numFmt)) { // if (isset($style->numFmt['formatCode'])) { @@ -1809,11 +1771,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($style->font->strike)) { $docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]) || self::boolean((string) $style->font->strike["val"])); } - $docStyle->getFont()->getColor()->setARGB(self::_readColor($style->font->color)); + $docStyle->getFont()->getColor()->setARGB(self::readColor($style->font->color)); if (isset($style->font->u) && !isset($style->font->u["val"])) { $docStyle->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); - } else if (isset($style->font->u) && isset($style->font->u["val"])) { + } elseif (isset($style->font->u) && isset($style->font->u["val"])) { $docStyle->getFont()->setUnderline((string)$style->font->u["val"]); } @@ -1837,18 +1799,18 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } $docStyle->getFill()->setRotation(floatval($gradientFill["degree"])); $gradientFill->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"); - $docStyle->getFill()->getStartColor()->setARGB(self::_readColor( self::array_item($gradientFill->xpath("sml:stop[@position=0]"))->color) ); - $docStyle->getFill()->getEndColor()->setARGB(self::_readColor( self::array_item($gradientFill->xpath("sml:stop[@position=1]"))->color) ); + $docStyle->getFill()->getStartColor()->setARGB(self::readColor(self::array_item($gradientFill->xpath("sml:stop[@position=0]"))->color)); + $docStyle->getFill()->getEndColor()->setARGB(self::readColor(self::array_item($gradientFill->xpath("sml:stop[@position=1]"))->color)); } elseif ($style->fill->patternFill) { $patternType = (string)$style->fill->patternFill["patternType"] != '' ? (string)$style->fill->patternFill["patternType"] : 'solid'; $docStyle->getFill()->setFillType($patternType); if ($style->fill->patternFill->fgColor) { - $docStyle->getFill()->getStartColor()->setARGB(self::_readColor($style->fill->patternFill->fgColor,true)); + $docStyle->getFill()->getStartColor()->setARGB(self::readColor($style->fill->patternFill->fgColor, true)); } else { $docStyle->getFill()->getStartColor()->setARGB('FF000000'); } if ($style->fill->patternFill->bgColor) { - $docStyle->getFill()->getEndColor()->setARGB(self::_readColor($style->fill->patternFill->bgColor,true)); + $docStyle->getFill()->getEndColor()->setARGB(self::readColor($style->fill->patternFill->bgColor, true)); } } } @@ -1866,11 +1828,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } else { $docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH); } - self::_readBorder($docStyle->getBorders()->getLeft(), $style->border->left); - self::_readBorder($docStyle->getBorders()->getRight(), $style->border->right); - self::_readBorder($docStyle->getBorders()->getTop(), $style->border->top); - self::_readBorder($docStyle->getBorders()->getBottom(), $style->border->bottom); - self::_readBorder($docStyle->getBorders()->getDiagonal(), $style->border->diagonal); + self::readBorder($docStyle->getBorders()->getLeft(), $style->border->left); + self::readBorder($docStyle->getBorders()->getRight(), $style->border->right); + self::readBorder($docStyle->getBorders()->getTop(), $style->border->top); + self::readBorder($docStyle->getBorders()->getBottom(), $style->border->bottom); + self::readBorder($docStyle->getBorders()->getDiagonal(), $style->border->diagonal); } // alignment @@ -1881,15 +1843,15 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $textRotation = 0; if ((int)$style->alignment["textRotation"] <= 90) { $textRotation = (int)$style->alignment["textRotation"]; - } else if ((int)$style->alignment["textRotation"] > 90) { + } elseif ((int)$style->alignment["textRotation"] > 90) { $textRotation = 90 - (int)$style->alignment["textRotation"]; } $docStyle->getAlignment()->setTextRotation(intval($textRotation)); $docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"])); $docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment["shrinkToFit"])); - $docStyle->getAlignment()->setIndent( intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0 ); - $docStyle->getAlignment()->setReadorder( intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0 ); + $docStyle->getAlignment()->setIndent(intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0); + $docStyle->getAlignment()->setReadorder(intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0); } // protection @@ -1917,82 +1879,75 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } - - private static function _readBorder($docBorder, $eleBorder) { + private static function readBorder($docBorder, $eleBorder) + { if (isset($eleBorder["style"])) { $docBorder->setBorderStyle((string) $eleBorder["style"]); } if (isset($eleBorder->color)) { - $docBorder->getColor()->setARGB(self::_readColor($eleBorder->color)); + $docBorder->getColor()->setARGB(self::readColor($eleBorder->color)); } } - - private function _parseRichText($is = null) { + private function parseRichText($is = null) + { $value = new PHPExcel_RichText(); if (isset($is->t)) { - $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) ); + $value->createText(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $is->t)); } else { if (is_object($is->r)) { - foreach ($is->r as $run) { - if (!isset($run->rPr)) { - $objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); + foreach ($is->r as $run) { + if (!isset($run->rPr)) { + $objText = $value->createText(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $run->t)); - } else { - $objText = $value->createTextRun( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); + } else { + $objText = $value->createTextRun(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $run->t)); - if (isset($run->rPr->rFont["val"])) { - $objText->getFont()->setName((string) $run->rPr->rFont["val"]); - } - - if (isset($run->rPr->sz["val"])) { - $objText->getFont()->setSize((string) $run->rPr->sz["val"]); - } - - if (isset($run->rPr->color)) { - $objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($run->rPr->color) ) ); - } - - if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) || - (isset($run->rPr->b) && !isset($run->rPr->b["val"]))) { - $objText->getFont()->setBold(TRUE); - } - - if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) || - (isset($run->rPr->i) && !isset($run->rPr->i["val"]))) { - $objText->getFont()->setItalic(TRUE); - } - - if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) { - $vertAlign = strtolower((string)$run->rPr->vertAlign["val"]); - if ($vertAlign == 'superscript') { - $objText->getFont()->setSuperScript(TRUE); + if (isset($run->rPr->rFont["val"])) { + $objText->getFont()->setName((string) $run->rPr->rFont["val"]); } - if ($vertAlign == 'subscript') { - $objText->getFont()->setSubScript(TRUE); + if (isset($run->rPr->sz["val"])) { + $objText->getFont()->setSize((string) $run->rPr->sz["val"]); + } + if (isset($run->rPr->color)) { + $objText->getFont()->setColor(new PHPExcel_Style_Color(self::readColor($run->rPr->color))); + } + if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) || + (isset($run->rPr->b) && !isset($run->rPr->b["val"]))) { + $objText->getFont()->setBold(true); + } + if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) || + (isset($run->rPr->i) && !isset($run->rPr->i["val"]))) { + $objText->getFont()->setItalic(true); + } + if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) { + $vertAlign = strtolower((string)$run->rPr->vertAlign["val"]); + if ($vertAlign == 'superscript') { + $objText->getFont()->setSuperScript(true); + } + if ($vertAlign == 'subscript') { + $objText->getFont()->setSubScript(true); + } + } + if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) { + $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); + } elseif (isset($run->rPr->u) && isset($run->rPr->u["val"])) { + $objText->getFont()->setUnderline((string)$run->rPr->u["val"]); + } + if ((isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"])) || + (isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) { + $objText->getFont()->setStrikethrough(true); } - } - - if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) { - $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); - } else if (isset($run->rPr->u) && isset($run->rPr->u["val"])) { - $objText->getFont()->setUnderline((string)$run->rPr->u["val"]); - } - - if ((isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"])) || - (isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) { - $objText->getFont()->setStrikethrough(TRUE); } } } - } } return $value; } - private function _readRibbon($excel, $customUITarget, $zip) + private function readRibbon($excel, $customUITarget, $zip) { $baseDir = dirname($customUITarget); $nameCustomUI = basename($customUITarget); @@ -2022,25 +1977,26 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) { $excel->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries); } else { - $excel->setRibbonBinObjects(NULL); + $excel->setRibbonBinObjects(null); } } else { - $excel->setRibbonXMLData(NULL); - $excel->setRibbonBinObjects(NULL); + $excel->setRibbonXMLData(null); + $excel->setRibbonBinObjects(null); } } - private static function array_item($array, $key = 0) { + private static function array_item($array, $key = 0) + { return (isset($array[$key]) ? $array[$key] : null); } - - private static function dir_add($base, $add) { + private static function dir_add($base, $add) + { return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add"); } - - private static function toCSSArray($style) { + private static function toCSSArray($style) + { $style = str_replace(array("\r","\n"), "", $style); $temp = explode(';', $style); @@ -2070,7 +2026,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE return $style; } - private static function boolean($value = NULL) + private static function boolean($value = null) { if (is_object($value)) { $value = (string) $value; diff --git a/Classes/PHPExcel/Reader/Excel2007/Chart.php b/Classes/PHPExcel/Reader/Excel2007/Chart.php index 80ac4470..88f336b3 100644 --- a/Classes/PHPExcel/Reader/Excel2007/Chart.php +++ b/Classes/PHPExcel/Reader/Excel2007/Chart.php @@ -34,7 +34,8 @@ */ class PHPExcel_Reader_Excel2007_Chart { - private static function _getAttribute($component, $name, $format) { + private static function getAttribute($component, $name, $format) + { $attributes = $component->attributes(); if (isset($attributes[$name])) { if ($format == 'string') { @@ -48,24 +49,25 @@ class PHPExcel_Reader_Excel2007_Chart } } return null; - } // function _getAttribute() + } - 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"])) { + } elseif (isset($color["indexed"])) { return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB(); } } - - public static function readChart($chartElements, $chartName) { + public static function readChart($chartElements, $chartName) + { $namespacesChartMeta = $chartElements->getNamespaces(true); $chartElementsC = $chartElements->children($namespacesChartMeta['c']); - $XaxisLabel = $YaxisLabel = $legend = $title = NULL; - $dispBlanksAs = $plotVisOnly = NULL; + $XaxisLabel = $YaxisLabel = $legend = $title = null; + $dispBlanksAs = $plotVisOnly = null; foreach ($chartElementsC as $chartElementKey => $chartElement) { switch ($chartElementKey) { @@ -74,124 +76,124 @@ class PHPExcel_Reader_Excel2007_Chart $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; - } + $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; + } + 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; + $plotVisOnly = self::getAttribute($chartDetails, 'val', 'string'); + break; case "dispBlanksAs": - $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string'); - break; + $dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string'); + break; case "title": - $title = self::_chartTitle($chartDetails, $namespacesChartMeta,'title'); - break; + $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; - } + $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; + } + $legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay); + break; } } } @@ -199,10 +201,10 @@ class PHPExcel_Reader_Excel2007_Chart $chart = new PHPExcel_Chart($chartName, $title, $legend, $plotArea, $plotVisOnly, $dispBlanksAs, $XaxisLabel, $YaxisLabel); return $chart; - } // function readChart() + } - - private static function _chartTitle($titleDetails, $namespacesChartMeta, $type) { + private static function chartTitle($titleDetails, $namespacesChartMeta, $type) + { $caption = array(); $titleLayout = null; foreach ($titleDetails as $titleDetailKey => $chartDetail) { @@ -213,21 +215,21 @@ class PHPExcel_Reader_Excel2007_Chart switch ($titleKey) { case "p": $titleDetailPart = $titleDetail->children($namespacesChartMeta['a']); - $caption[] = self::_parseRichText($titleDetailPart); + $caption[] = self::parseRichText($titleDetailPart); } } break; case "layout": - $titleLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta); + $titleLayout = self::chartLayoutDetails($chartDetail, $namespacesChartMeta); break; } } return new PHPExcel_Chart_Title($caption, $titleLayout); - } // function _chartTitle() + } - - private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta) { + private static function chartLayoutDetails($chartDetail, $namespacesChartMeta) + { if (!isset($chartDetail->manualLayout)) { return null; } @@ -237,15 +239,15 @@ class PHPExcel_Reader_Excel2007_Chart } $layout = array(); foreach ($details as $detailKey => $detail) { -// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL; - $layout[$detailKey] = self::_getAttribute($detail, 'val', 'string'); +// 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; + private static function chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) + { + $multiSeriesType = null; $smoothLine = false; $seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array(); @@ -253,77 +255,79 @@ class PHPExcel_Reader_Excel2007_Chart foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) { switch ($seriesDetailKey) { case "grouping": - $multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string'); + $multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string'); break; case "ser": - $marker = NULL; + $marker = null; foreach ($seriesDetails as $seriesKey => $seriesDetail) { switch ($seriesKey) { case "idx": - $seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer'); + $seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer'); break; case "order": - $seriesOrder = self::_getAttribute($seriesDetail, 'val', 'integer'); + $seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer'); $plotOrder[$seriesIndex] = $seriesOrder; break; case "tx": - $seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta); + $seriesLabel[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta); break; case "marker": - $marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string'); + $marker = self::getAttribute($seriesDetail->symbol, 'val', 'string'); break; case "smooth": - $smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean'); + $smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean'); break; case "cat": - $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta); + $seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta); break; case "val": - $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); + $seriesValues[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); break; case "xVal": - $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); + $seriesCategory[$seriesIndex] = self::chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); break; case "yVal": - $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker); + $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) { + 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'); + $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'])); + $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 = 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 = 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') { + private static function chartDataSeriesValues($seriesValueSet, $dataType = 'n') + { $seriesVal = array(); $formatCode = ''; $pointCount = 0; @@ -331,13 +335,13 @@ class PHPExcel_Reader_Excel2007_Chart foreach ($seriesValueSet as $seriesValueIdx => $seriesValue) { switch ($seriesValueIdx) { case 'ptCount': - $pointCount = self::_getAttribute($seriesValue, 'val', 'integer'); + $pointCount = self::getAttribute($seriesValue, 'val', 'integer'); break; case 'formatCode': $formatCode = (string) $seriesValue; break; case 'pt': - $pointVal = self::_getAttribute($seriesValue, 'idx', 'integer'); + $pointVal = self::getAttribute($seriesValue, 'idx', 'integer'); if ($dataType == 's') { $seriesVal[$pointVal] = (string) $seriesValue->v; } else { @@ -348,17 +352,18 @@ class PHPExcel_Reader_Excel2007_Chart } if (empty($seriesVal)) { - $seriesVal = NULL; + $seriesVal = null; } - return array( 'formatCode' => $formatCode, - 'pointCount' => $pointCount, - 'dataValues' => $seriesVal - ); - } // function _chartDataSeriesValues() + return array( + 'formatCode' => $formatCode, + 'pointCount' => $pointCount, + 'dataValues' => $seriesVal + ); + } - - private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType='n') { + private static function chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n') + { $seriesVal = array(); $formatCode = ''; $pointCount = 0; @@ -367,13 +372,13 @@ class PHPExcel_Reader_Excel2007_Chart foreach ($seriesLevel as $seriesValueIdx => $seriesValue) { switch ($seriesValueIdx) { case 'ptCount': - $pointCount = self::_getAttribute($seriesValue, 'val', 'integer'); + $pointCount = self::getAttribute($seriesValue, 'val', 'integer'); break; case 'formatCode': $formatCode = (string) $seriesValue; break; case 'pt': - $pointVal = self::_getAttribute($seriesValue, 'idx', 'integer'); + $pointVal = self::getAttribute($seriesValue, 'idx', 'integer'); if ($dataType == 's') { $seriesVal[$pointVal][] = (string) $seriesValue->v; } else { @@ -384,45 +389,47 @@ class PHPExcel_Reader_Excel2007_Chart } } - return array( 'formatCode' => $formatCode, - 'pointCount' => $pointCount, - 'dataValues' => $seriesVal - ); - } // function _chartDataSeriesValuesMultiLevel() + return array( + 'formatCode' => $formatCode, + 'pointCount' => $pointCount, + 'dataValues' => $seriesVal + ); + } - private static function _parseRichText($titleDetailPart = null) { + 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 ); + $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')); + $fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer')); if (!is_null($fontSize)) { $objText->getFont()->setSize(floor($fontSize / 100)); } - $fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string')); + $fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string')); if (!is_null($fontColor)) { - $objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) ); + $objText->getFont()->setColor(new PHPExcel_Style_Color(self::readColor($fontColor))); } - $bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean'); + $bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean'); if (!is_null($bold)) { $objText->getFont()->setBold($bold); } - $italic = self::_getAttribute($titleDetailElement->rPr, 'i', 'boolean'); + $italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean'); if (!is_null($italic)) { $objText->getFont()->setItalic($italic); } - $baseline = self::_getAttribute($titleDetailElement->rPr, 'baseline', 'integer'); + $baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer'); if (!is_null($baseline)) { if ($baseline > 0) { $objText->getFont()->setSuperScript(true); @@ -431,7 +438,7 @@ class PHPExcel_Reader_Excel2007_Chart } } - $underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string')); + $underscore = (self::getAttribute($titleDetailElement->rPr, 'u', 'string')); if (!is_null($underscore)) { if ($underscore == 'sng') { $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); @@ -442,7 +449,7 @@ class PHPExcel_Reader_Excel2007_Chart } } - $strikethrough = (self::_getAttribute($titleDetailElement->rPr, 's', 'string')); + $strikethrough = (self::getAttribute($titleDetailElement->rPr, 's', 'string')); if (!is_null($strikethrough)) { if ($strikethrough == 'noStrike') { $objText->getFont()->setStrikethrough(false); @@ -456,62 +463,62 @@ class PHPExcel_Reader_Excel2007_Chart return $value; } - private static function _readChartAttributes($chartDetail) { + 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'); + $plotAttributes['showLegendKey'] = self::getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string'); } if (isset($chartDetail->dLbls->showVal)) { - $plotAttributes['showVal'] = self::_getAttribute($chartDetail->dLbls->showVal, 'val', 'string'); + $plotAttributes['showVal'] = self::getAttribute($chartDetail->dLbls->showVal, 'val', 'string'); } if (isset($chartDetail->dLbls->showCatName)) { - $plotAttributes['showCatName'] = self::_getAttribute($chartDetail->dLbls->showCatName, 'val', 'string'); + $plotAttributes['showCatName'] = self::getAttribute($chartDetail->dLbls->showCatName, 'val', 'string'); } if (isset($chartDetail->dLbls->showSerName)) { - $plotAttributes['showSerName'] = self::_getAttribute($chartDetail->dLbls->showSerName, 'val', 'string'); + $plotAttributes['showSerName'] = self::getAttribute($chartDetail->dLbls->showSerName, 'val', 'string'); } if (isset($chartDetail->dLbls->showPercent)) { - $plotAttributes['showPercent'] = self::_getAttribute($chartDetail->dLbls->showPercent, 'val', 'string'); + $plotAttributes['showPercent'] = self::getAttribute($chartDetail->dLbls->showPercent, 'val', 'string'); } if (isset($chartDetail->dLbls->showBubbleSize)) { - $plotAttributes['showBubbleSize'] = self::_getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string'); + $plotAttributes['showBubbleSize'] = self::getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string'); } if (isset($chartDetail->dLbls->showLeaderLines)) { - $plotAttributes['showLeaderLines'] = self::_getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string'); + $plotAttributes['showLeaderLines'] = self::getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string'); } } return $plotAttributes; } - private static function _setChartAttributes($plotArea, $plotAttributes) + private static function setChartAttributes($plotArea, $plotAttributes) { foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) { switch ($plotAttributeKey) { - case 'showLegendKey' : + case 'showLegendKey': $plotArea->setShowLegendKey($plotAttributeValue); break; - case 'showVal' : + case 'showVal': $plotArea->setShowVal($plotAttributeValue); break; - case 'showCatName' : + case 'showCatName': $plotArea->setShowCatName($plotAttributeValue); break; - case 'showSerName' : + case 'showSerName': $plotArea->setShowSerName($plotAttributeValue); break; - case 'showPercent' : + case 'showPercent': $plotArea->setShowPercent($plotAttributeValue); break; - case 'showBubbleSize' : + case 'showBubbleSize': $plotArea->setShowBubbleSize($plotAttributeValue); break; - case 'showLeaderLines' : + case 'showLeaderLines': $plotArea->setShowLeaderLines($plotAttributeValue); break; } } } - } diff --git a/Classes/PHPExcel/Reader/Excel2007/Theme.php b/Classes/PHPExcel/Reader/Excel2007/Theme.php index 2501c814..134f4b60 100644 --- a/Classes/PHPExcel/Reader/Excel2007/Theme.php +++ b/Classes/PHPExcel/Reader/Excel2007/Theme.php @@ -40,21 +40,21 @@ class PHPExcel_Reader_Excel2007_Theme * * @var string */ - private $_themeName; + private $themeName; /** * Colour Scheme Name * * @var string */ - private $_colourSchemeName; + private $colourSchemeName; /** * Colour Map indexed by position * * @var array of string */ - private $_colourMapValues; + private $colourMapValues; /** @@ -62,7 +62,7 @@ class PHPExcel_Reader_Excel2007_Theme * * @var array of string */ - private $_colourMap; + private $colourMap; /** @@ -72,9 +72,9 @@ class PHPExcel_Reader_Excel2007_Theme public function __construct($themeName, $colourSchemeName, $colourMap) { // Initialise values - $this->_themeName = $themeName; - $this->_colourSchemeName = $colourSchemeName; - $this->_colourMap = $colourMap; + $this->themeName = $themeName; + $this->colourSchemeName = $colourSchemeName; + $this->colourMap = $colourMap; } /** @@ -84,7 +84,7 @@ class PHPExcel_Reader_Excel2007_Theme */ public function getThemeName() { - return $this->_themeName; + return $this->themeName; } /** @@ -92,8 +92,9 @@ class PHPExcel_Reader_Excel2007_Theme * * @return string */ - public function getColourSchemeName() { - return $this->_colourSchemeName; + public function getColourSchemeName() + { + return $this->colourSchemeName; } /** @@ -101,9 +102,10 @@ class PHPExcel_Reader_Excel2007_Theme * * @return string */ - public function getColourByIndex($index=0) { - if (isset($this->_colourMap[$index])) { - return $this->_colourMap[$index]; + public function getColourByIndex($index = 0) + { + if (isset($this->colourMap[$index])) { + return $this->colourMap[$index]; } return null; } @@ -111,7 +113,8 @@ class PHPExcel_Reader_Excel2007_Theme /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ - public function __clone() { + public function __clone() + { $vars = get_object_vars($this); foreach ($vars as $key => $value) { if ((is_object($value)) && ($key != '_parent')) { diff --git a/Classes/PHPExcel/Reader/Excel5.php b/Classes/PHPExcel/Reader/Excel5.php index 9b27b965..3728b6cc 100644 --- a/Classes/PHPExcel/Reader/Excel5.php +++ b/Classes/PHPExcel/Reader/Excel5.php @@ -1,7088 +1,8054 @@ -_data - * - * @var int - */ - private $_dataSize; - - /** - * Current position in stream - * - * @var integer - */ - private $_pos; - - /** - * Workbook to be returned by the reader. - * - * @var PHPExcel - */ - private $_phpExcel; - - /** - * Worksheet that is currently being built by the reader. - * - * @var PHPExcel_Worksheet - */ - private $_phpSheet; - - /** - * BIFF version - * - * @var int - */ - private $_version; - - /** - * Codepage set in the Excel file being read. Only important for BIFF5 (Excel 5.0 - Excel 95) - * For BIFF8 (Excel 97 - Excel 2003) this will always have the value 'UTF-16LE' - * - * @var string - */ - private $_codepage; - - /** - * Shared formats - * - * @var array - */ - private $_formats; - - /** - * Shared fonts - * - * @var array - */ - private $_objFonts; - - /** - * Color palette - * - * @var array - */ - private $_palette; - - /** - * Worksheets - * - * @var array - */ - private $_sheets; - - /** - * External books - * - * @var array - */ - private $_externalBooks; - - /** - * REF structures. Only applies to BIFF8. - * - * @var array - */ - private $_ref; - - /** - * External names - * - * @var array - */ - private $_externalNames; - - /** - * Defined names - * - * @var array - */ - private $_definedname; - - /** - * Shared strings. Only applies to BIFF8. - * - * @var array - */ - private $_sst; - - /** - * Panes are frozen? (in sheet currently being read). See WINDOW2 record. - * - * @var boolean - */ - private $_frozen; - - /** - * Fit printout to number of pages? (in sheet currently being read). See SHEETPR record. - * - * @var boolean - */ - private $_isFitToPages; - - /** - * Objects. One OBJ record contributes with one entry. - * - * @var array - */ - private $_objs; - - /** - * Text Objects. One TXO record corresponds with one entry. - * - * @var array - */ - private $_textObjects; - - /** - * Cell Annotations (BIFF8) - * - * @var array - */ - private $_cellNotes; - - /** - * The combined MSODRAWINGGROUP data - * - * @var string - */ - private $_drawingGroupData; - - /** - * The combined MSODRAWING data (per sheet) - * - * @var string - */ - private $_drawingData; - - /** - * Keep track of XF index - * - * @var int - */ - private $_xfIndex; - - /** - * Mapping of XF index (that is a cell XF) to final index in cellXf collection - * - * @var array - */ - private $_mapCellXfIndex; - - /** - * Mapping of XF index (that is a style XF) to final index in cellStyleXf collection - * - * @var array - */ - private $_mapCellStyleXfIndex; - - /** - * The shared formulas in a sheet. One SHAREDFMLA record contributes with one value. - * - * @var array - */ - private $_sharedFormulas; - - /** - * The shared formula parts in a sheet. One FORMULA record contributes with one value if it - * refers to a shared formula. - * - * @var array - */ - private $_sharedFormulaParts; - - /** - * The type of encryption in use - * - * @var int - */ - private $_encryption = 0; - - /** - * The position in the stream after which contents are encrypted - * - * @var int - */ - private $_encryptionStartPos = false; - - /** - * The current RC4 decryption object - * - * @var PHPExcel_Reader_Excel5_RC4 - */ - private $_rc4Key = null; - - /** - * The position in the stream that the RC4 decryption object was left at - * - * @var int - */ - private $_rc4Pos = 0; - - /** - * The current MD5 context state - * - * @var string - */ - private $_md5Ctxt = null; - - /** - * 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 PHPExcel_Reader_Exception - */ - public function canRead($pFilename) - { - // Check if file exists - if (!file_exists($pFilename)) { - throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - try { - // Use ParseXL for the hard work. - $ole = new PHPExcel_Shared_OLERead(); - - // get excel data - $res = $ole->read($pFilename); - return true; - } catch (PHPExcel_Exception $e) { - return false; - } - } - - - /** - * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object - * - * @param string $pFilename - * @throws PHPExcel_Reader_Exception - */ - public function listWorksheetNames($pFilename) - { - // Check if file exists - if (!file_exists($pFilename)) { - throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - $worksheetNames = array(); - - // Read the OLE file - $this->_loadOLE($pFilename); - - // total byte size of Excel data (workbook global substream + sheet substreams) - $this->_dataSize = strlen($this->_data); - - $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; - } - } - - foreach ($this->_sheets as $sheet) { - if ($sheet['sheetType'] != 0x00) { - // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module - continue; - } - - $worksheetNames[] = $sheet['name']; - } - - return $worksheetNames; - } - - - /** - * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) - * - * @param string $pFilename - * @throws PHPExcel_Reader_Exception - */ - public function listWorksheetInfo($pFilename) - { - // Check if file exists - if (!file_exists($pFilename)) { - throw new PHPExcel_Reader_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 = $this->_readRecordData($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 - * - * @param string $pFilename - * @return PHPExcel - * @throws PHPExcel_Reader_Exception - */ - public function load($pFilename) - { - // Read the OLE file - $this->_loadOLE($pFilename); - - // Initialisations - $this->_phpExcel = new PHPExcel; - $this->_phpExcel->removeSheetByIndex(0); // remove 1st sheet - if (!$this->_readDataOnly) { - $this->_phpExcel->removeCellStyleXfByIndex(0); // remove the default style - $this->_phpExcel->removeCellXfByIndex(0); // remove the default style - } - - // Read the summary information stream (containing meta data) - $this->_readSummaryInformation(); - - // Read the Additional document summary information stream (containing application-specific meta data) - $this->_readDocumentSummaryInformation(); - - // total byte size of Excel data (workbook global substream + sheet substreams) - $this->_dataSize = strlen($this->_data); - - // initialize - $this->_pos = 0; - $this->_codepage = 'CP1252'; - $this->_formats = array(); - $this->_objFonts = array(); - $this->_palette = array(); - $this->_sheets = array(); - $this->_externalBooks = array(); - $this->_ref = array(); - $this->_definedname = array(); - $this->_sst = array(); - $this->_drawingGroupData = ''; - $this->_xfIndex = ''; - $this->_mapCellXfIndex = array(); - $this->_mapCellStyleXfIndex = 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_FILEPASS: $this->_readFilepass(); break; - case self::XLS_Type_CODEPAGE: $this->_readCodepage(); break; - case self::XLS_Type_DATEMODE: $this->_readDateMode(); break; - case self::XLS_Type_FONT: $this->_readFont(); break; - case self::XLS_Type_FORMAT: $this->_readFormat(); break; - case self::XLS_Type_XF: $this->_readXf(); break; - case self::XLS_Type_XFEXT: $this->_readXfExt(); break; - case self::XLS_Type_STYLE: $this->_readStyle(); break; - case self::XLS_Type_PALETTE: $this->_readPalette(); break; - case self::XLS_Type_SHEET: $this->_readSheet(); break; - case self::XLS_Type_EXTERNALBOOK: $this->_readExternalBook(); break; - case self::XLS_Type_EXTERNNAME: $this->_readExternName(); break; - case self::XLS_Type_EXTERNSHEET: $this->_readExternSheet(); break; - case self::XLS_Type_DEFINEDNAME: $this->_readDefinedName(); break; - case self::XLS_Type_MSODRAWINGGROUP: $this->_readMsoDrawingGroup(); break; - case self::XLS_Type_SST: $this->_readSst(); break; - case self::XLS_Type_EOF: $this->_readDefault(); break 2; - default: $this->_readDefault(); break; - } - } - - // Resolve indexed colors for font, fill, and border colors - // Cannot be resolved already in XF record, because PALETTE record comes afterwards - if (!$this->_readDataOnly) { - foreach ($this->_objFonts as $objFont) { - if (isset($objFont->colorIndex)) { - $color = self::_readColor($objFont->colorIndex, $this->_palette, $this->_version); - $objFont->getColor()->setRGB($color['rgb']); - } - } - - foreach ($this->_phpExcel->getCellXfCollection() as $objStyle) { - // fill start and end color - $fill = $objStyle->getFill(); - - if (isset($fill->startcolorIndex)) { - $startColor = self::_readColor($fill->startcolorIndex, $this->_palette, $this->_version); - $fill->getStartColor()->setRGB($startColor['rgb']); - } - - if (isset($fill->endcolorIndex)) { - $endColor = self::_readColor($fill->endcolorIndex, $this->_palette, $this->_version); - $fill->getEndColor()->setRGB($endColor['rgb']); - } - - // border colors - $top = $objStyle->getBorders()->getTop(); - $right = $objStyle->getBorders()->getRight(); - $bottom = $objStyle->getBorders()->getBottom(); - $left = $objStyle->getBorders()->getLeft(); - $diagonal = $objStyle->getBorders()->getDiagonal(); - - if (isset($top->colorIndex)) { - $borderTopColor = self::_readColor($top->colorIndex, $this->_palette, $this->_version); - $top->getColor()->setRGB($borderTopColor['rgb']); - } - - if (isset($right->colorIndex)) { - $borderRightColor = self::_readColor($right->colorIndex, $this->_palette, $this->_version); - $right->getColor()->setRGB($borderRightColor['rgb']); - } - - if (isset($bottom->colorIndex)) { - $borderBottomColor = self::_readColor($bottom->colorIndex, $this->_palette, $this->_version); - $bottom->getColor()->setRGB($borderBottomColor['rgb']); - } - - if (isset($left->colorIndex)) { - $borderLeftColor = self::_readColor($left->colorIndex, $this->_palette, $this->_version); - $left->getColor()->setRGB($borderLeftColor['rgb']); - } - - if (isset($diagonal->colorIndex)) { - $borderDiagonalColor = self::_readColor($diagonal->colorIndex, $this->_palette, $this->_version); - $diagonal->getColor()->setRGB($borderDiagonalColor['rgb']); - } - } - } - - // treat MSODRAWINGGROUP records, workbook-level Escher - if (!$this->_readDataOnly && $this->_drawingGroupData) { - $escherWorkbook = new PHPExcel_Shared_Escher(); - $reader = new PHPExcel_Reader_Excel5_Escher($escherWorkbook); - $escherWorkbook = $reader->load($this->_drawingGroupData); - - // debug Escher stream - //$debug = new Debug_Escher(new PHPExcel_Shared_Escher()); - //$debug->load($this->_drawingGroupData); - } - - // Parse the individual sheets - foreach ($this->_sheets as $sheet) { - - if ($sheet['sheetType'] != 0x00) { - // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module - continue; - } - - // check if sheet should be skipped - if (isset($this->_loadSheetsOnly) && !in_array($sheet['name'], $this->_loadSheetsOnly)) { - continue; - } - - // add sheet to PHPExcel object - $this->_phpSheet = $this->_phpExcel->createSheet(); - // 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']; - - // Initialize isFitToPages. May change after reading SHEETPR record. - $this->_isFitToPages = false; - - // Initialize drawingData - $this->_drawingData = ''; - - // Initialize objs - $this->_objs = array(); - - // Initialize shared formula parts - $this->_sharedFormulaParts = array(); - - // Initialize shared formulas - $this->_sharedFormulas = array(); - - // Initialize text objs - $this->_textObjects = array(); - - // Initialize cell annotations - $this->_cellNotes = array(); - $this->textObjRef = -1; - - while ($this->_pos <= $this->_dataSize - 4) { - $code = self::_GetInt2d($this->_data, $this->_pos); - - switch ($code) { - case self::XLS_Type_BOF: $this->_readBof(); break; - case self::XLS_Type_PRINTGRIDLINES: $this->_readPrintGridlines(); break; - case self::XLS_Type_DEFAULTROWHEIGHT: $this->_readDefaultRowHeight(); break; - case self::XLS_Type_SHEETPR: $this->_readSheetPr(); break; - case self::XLS_Type_HORIZONTALPAGEBREAKS: $this->_readHorizontalPageBreaks(); break; - case self::XLS_Type_VERTICALPAGEBREAKS: $this->_readVerticalPageBreaks(); break; - case self::XLS_Type_HEADER: $this->_readHeader(); break; - case self::XLS_Type_FOOTER: $this->_readFooter(); break; - case self::XLS_Type_HCENTER: $this->_readHcenter(); break; - case self::XLS_Type_VCENTER: $this->_readVcenter(); break; - case self::XLS_Type_LEFTMARGIN: $this->_readLeftMargin(); break; - case self::XLS_Type_RIGHTMARGIN: $this->_readRightMargin(); break; - case self::XLS_Type_TOPMARGIN: $this->_readTopMargin(); break; - case self::XLS_Type_BOTTOMMARGIN: $this->_readBottomMargin(); break; - case self::XLS_Type_PAGESETUP: $this->_readPageSetup(); break; - case self::XLS_Type_PROTECT: $this->_readProtect(); break; - case self::XLS_Type_SCENPROTECT: $this->_readScenProtect(); break; - case self::XLS_Type_OBJECTPROTECT: $this->_readObjectProtect(); break; - case self::XLS_Type_PASSWORD: $this->_readPassword(); break; - case self::XLS_Type_DEFCOLWIDTH: $this->_readDefColWidth(); break; - case self::XLS_Type_COLINFO: $this->_readColInfo(); break; - case self::XLS_Type_DIMENSION: $this->_readDefault(); break; - case self::XLS_Type_ROW: $this->_readRow(); break; - case self::XLS_Type_DBCELL: $this->_readDefault(); break; - case self::XLS_Type_RK: $this->_readRk(); break; - case self::XLS_Type_LABELSST: $this->_readLabelSst(); break; - case self::XLS_Type_MULRK: $this->_readMulRk(); break; - case self::XLS_Type_NUMBER: $this->_readNumber(); break; - case self::XLS_Type_FORMULA: $this->_readFormula(); break; - case self::XLS_Type_SHAREDFMLA: $this->_readSharedFmla(); break; - case self::XLS_Type_BOOLERR: $this->_readBoolErr(); break; - case self::XLS_Type_MULBLANK: $this->_readMulBlank(); break; - case self::XLS_Type_LABEL: $this->_readLabel(); break; - case self::XLS_Type_BLANK: $this->_readBlank(); break; - case self::XLS_Type_MSODRAWING: $this->_readMsoDrawing(); break; - case self::XLS_Type_OBJ: $this->_readObj(); break; - case self::XLS_Type_WINDOW2: $this->_readWindow2(); break; - case self::XLS_Type_PAGELAYOUTVIEW: $this->_readPageLayoutView(); break; - case self::XLS_Type_SCL: $this->_readScl(); break; - case self::XLS_Type_PANE: $this->_readPane(); break; - case self::XLS_Type_SELECTION: $this->_readSelection(); break; - case self::XLS_Type_MERGEDCELLS: $this->_readMergedCells(); break; - case self::XLS_Type_HYPERLINK: $this->_readHyperLink(); break; - case self::XLS_Type_DATAVALIDATIONS: $this->_readDataValidations(); break; - case self::XLS_Type_DATAVALIDATION: $this->_readDataValidation(); break; - case self::XLS_Type_SHEETLAYOUT: $this->_readSheetLayout(); break; - case self::XLS_Type_SHEETPROTECTION: $this->_readSheetProtection(); break; - case self::XLS_Type_RANGEPROTECTION: $this->_readRangeProtection(); break; - case self::XLS_Type_NOTE: $this->_readNote(); break; - //case self::XLS_Type_IMDATA: $this->_readImData(); break; - case self::XLS_Type_TXO: $this->_readTextObject(); break; - case self::XLS_Type_CONTINUE: $this->_readContinue(); break; - case self::XLS_Type_EOF: $this->_readDefault(); break 2; - default: $this->_readDefault(); break; - } - - } - - // treat MSODRAWING records, sheet-level Escher - if (!$this->_readDataOnly && $this->_drawingData) { - $escherWorksheet = new PHPExcel_Shared_Escher(); - $reader = new PHPExcel_Reader_Excel5_Escher($escherWorksheet); - $escherWorksheet = $reader->load($this->_drawingData); - - // debug Escher stream - //$debug = new Debug_Escher(new PHPExcel_Shared_Escher()); - //$debug->load($this->_drawingData); - - // get all spContainers in one long array, so they can be mapped to OBJ records - $allSpContainers = $escherWorksheet->getDgContainer()->getSpgrContainer()->getAllSpContainers(); - } - - // treat OBJ records - foreach ($this->_objs as $n => $obj) { -// echo '
Object reference is ', $n,'
'; -// var_dump($obj); -// echo '
'; - - // the first shape container never has a corresponding OBJ record, hence $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']]; - - 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; - - } - } - } - - // treat SHAREDFMLA records - if ($this->_version == self::XLS_BIFF8) { - foreach ($this->_sharedFormulaParts as $cell => $baseCell) { - list($column, $row) = PHPExcel_Cell::coordinateFromString($cell); - 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 (!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 '
'; - $cellAddress = str_replace('$','', $noteDetails['cellRef']); - $this->_phpSheet->getComment( $cellAddress ) - ->setAuthor( $noteDetails['author'] ) - ->setText($this->_parseRichText($noteDetails['objTextData']['text']) ); - } - } - } - - // add the named ranges (defined names) - foreach ($this->_definedname as $definedName) { - if ($definedName['isBuiltInName']) { - switch ($definedName['name']) { - - case pack('C', 0x06): - // print area - // in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2 - $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? - - $extractedRanges = array(); - foreach ($ranges as $range) { - // $range should look like one of these - // Foo!$C$7:$J$66 - // Bar!$A$1:$IV$2 - - $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? - $sheetName = trim($explodes[0], "'"); - - if (count($explodes) == 2) { - if (strpos($explodes[1], ':') === FALSE) { - $explodes[1] = $explodes[1] . ':' . $explodes[1]; - } - $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 - } - } - if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) { - $docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2 - } - break; - - case pack('C', 0x07): - // print titles (repeating rows) - // Assuming BIFF8, there are 3 cases - // 1. repeating rows - // formula looks like this: Sheet!$A$1:$IV$2 - // rows 1-2 repeat - // 2. repeating columns - // formula looks like this: Sheet!$A$1:$B$65536 - // columns A-B repeat - // 3. both repeating rows and repeating columns - // formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2 - - $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? - - foreach ($ranges as $range) { - // $range should look like this one of these - // Sheet!$A$1:$B$65536 - // Sheet!$A$1:$IV$2 - - $explodes = explode('!', $range); - - if (count($explodes) == 2) { - if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) { - - $extractedRange = $explodes[1]; - $extractedRange = str_replace('$', '', $extractedRange); - - $coordinateStrings = explode(':', $extractedRange); - if (count($coordinateStrings) == 2) { - list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]); - list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]); - - if ($firstColumn == 'A' and $lastColumn == 'IV') { - // then we have repeating rows - $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow)); - } elseif ($firstRow == 1 and $lastRow == 65536) { - // then we have repeating columns - $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn)); - } - } - } - } - } - break; - - } - } else { - // Extract range - $explodes = explode('!', $definedName['formula']); - - if (count($explodes) == 2) { - 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 - } - } - } - $this->_data = null; - - return $this->_phpExcel; - } - - /** - * Read record data from stream, decrypting as required - * - * @param string $data Data stream to read from - * @param int $pos Position to start reading from - * @param int $length Record data length - * - * @return string Record data - */ - private function _readRecordData($data, $pos, $len) - { - $data = substr($data, $pos, $len); - - // File not encrypted, or record before encryption start point - if ($this->_encryption == self::MS_BIFF_CRYPTO_NONE || $pos < $this->_encryptionStartPos) { - return $data; - } - - $recordData = ''; - if ($this->_encryption == self::MS_BIFF_CRYPTO_RC4) { - - $oldBlock = floor($this->_rc4Pos / self::REKEY_BLOCK); - $block = floor($pos / self::REKEY_BLOCK); - $endBlock = floor(($pos + $len) / self::REKEY_BLOCK); - - // Spin an RC4 decryptor to the right spot. If we have a decryptor sitting - // at a point earlier in the current block, re-use it as we can save some time. - if ($block != $oldBlock || $pos < $this->_rc4Pos || !$this->_rc4Key) { - $this->_rc4Key = $this->_makeKey($block, $this->_md5Ctxt); - $step = $pos % self::REKEY_BLOCK; - } else { - $step = $pos - $this->_rc4Pos; - } - $this->_rc4Key->RC4(str_repeat("\0", $step)); - - // Decrypt record data (re-keying at the end of every block) - while ($block != $endBlock) { - $step = self::REKEY_BLOCK - ($pos % self::REKEY_BLOCK); - $recordData .= $this->_rc4Key->RC4(substr($data, 0, $step)); - $data = substr($data, $step); - $pos += $step; - $len -= $step; - $block++; - $this->_rc4Key = $this->_makeKey($block, $this->_md5Ctxt); - } - $recordData .= $this->_rc4Key->RC4(substr($data, 0, $len)); - - // Keep track of the position of this decryptor. - // We'll try and re-use it later if we can to speed things up - $this->_rc4Pos = $pos + $len; - - } elseif ($this->_encryption == self::MS_BIFF_CRYPTO_XOR) { - throw new PHPExcel_Reader_Exception('XOr encryption not supported'); - } - return $recordData; - } - - /** - * Use OLE reader to extract the relevant data streams from the OLE file - * - * @param string $pFilename - */ - private function _loadOLE($pFilename) - { - // OLE reader - $ole = new PHPExcel_Shared_OLERead(); - - // get excel data, - $res = $ole->read($pFilename); - // Get workbook data: workbook stream + sheet streams - $this->_data = $ole->getStream($ole->wrkbook); - - // Get summary information data - $this->_summaryInformation = $ole->getStream($ole->summaryInformation); - - // Get additional document summary information data - $this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation); - - // Get user-defined property data -// $this->_userDefinedProperties = $ole->getUserDefinedProperties(); - } - - - /** - * Read summary information - */ - private function _readSummaryInformation() - { - if (!isset($this->_summaryInformation)) { - return; - } - - // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) - // offset: 2; size: 2; - // offset: 4; size: 2; OS version - // offset: 6; size: 2; OS indicator - // offset: 8; size: 16 - // offset: 24; size: 4; section count - $secCount = self::_GetInt4d($this->_summaryInformation, 24); - - // offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9 - // offset: 44; size: 4 - $secOffset = self::_GetInt4d($this->_summaryInformation, 44); - - // section header - // offset: $secOffset; size: 4; section length - $secLength = self::_GetInt4d($this->_summaryInformation, $secOffset); - - // offset: $secOffset+4; size: 4; property count - $countProperties = self::_GetInt4d($this->_summaryInformation, $secOffset+4); - - // initialize code page (used to resolve string values) - $codePage = 'CP1252'; - - // offset: ($secOffset+8); size: var - // loop through property decarations and properties - for ($i = 0; $i < $countProperties; ++$i) { - - // offset: ($secOffset+8) + (8 * $i); size: 4; property ID - $id = self::_GetInt4d($this->_summaryInformation, ($secOffset+8) + (8 * $i)); - - // Use value of property id as appropriate - // offset: ($secOffset+12) + (8 * $i); size: 4; offset from beginning of section (48) - $offset = self::_GetInt4d($this->_summaryInformation, ($secOffset+12) + (8 * $i)); - - $type = self::_GetInt4d($this->_summaryInformation, $secOffset + $offset); - - // initialize property value - $value = null; - - // extract property value based on property type - switch ($type) { - case 0x02: // 2 byte signed integer - $value = self::_GetInt2d($this->_summaryInformation, $secOffset + 4 + $offset); - break; - - case 0x03: // 4 byte signed integer - $value = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset); - break; - - case 0x13: // 4 byte unsigned integer - // not needed yet, fix later if necessary - break; - - case 0x1E: // null-terminated string prepended by dword string length - $byteLength = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset); - $value = substr($this->_summaryInformation, $secOffset + 8 + $offset, $byteLength); - $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage); - $value = rtrim($value); - break; - - case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - // PHP-time - $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_summaryInformation, $secOffset + 4 + $offset, 8)); - break; - - case 0x47: // Clipboard format - // not needed yet, fix later if necessary - break; - } - - switch ($id) { - case 0x01: // Code Page - $codePage = PHPExcel_Shared_CodePage::NumberToName($value); - break; - - case 0x02: // Title - $this->_phpExcel->getProperties()->setTitle($value); - break; - - case 0x03: // Subject - $this->_phpExcel->getProperties()->setSubject($value); - break; - - case 0x04: // Author (Creator) - $this->_phpExcel->getProperties()->setCreator($value); - break; - - case 0x05: // Keywords - $this->_phpExcel->getProperties()->setKeywords($value); - break; - - case 0x06: // Comments (Description) - $this->_phpExcel->getProperties()->setDescription($value); - break; - - case 0x07: // Template - // Not supported by PHPExcel - break; - - case 0x08: // Last Saved By (LastModifiedBy) - $this->_phpExcel->getProperties()->setLastModifiedBy($value); - break; - - case 0x09: // Revision - // Not supported by PHPExcel - break; - - case 0x0A: // Total Editing Time - // Not supported by PHPExcel - break; - - case 0x0B: // Last Printed - // Not supported by PHPExcel - break; - - case 0x0C: // Created Date/Time - $this->_phpExcel->getProperties()->setCreated($value); - break; - - case 0x0D: // Modified Date/Time - $this->_phpExcel->getProperties()->setModified($value); - break; - - case 0x0E: // Number of Pages - // Not supported by PHPExcel - break; - - case 0x0F: // Number of Words - // Not supported by PHPExcel - break; - - case 0x10: // Number of Characters - // Not supported by PHPExcel - break; - - case 0x11: // Thumbnail - // Not supported by PHPExcel - break; - - case 0x12: // Name of creating application - // Not supported by PHPExcel - break; - - case 0x13: // Security - // Not supported by PHPExcel - break; - - } - } - } - - - /** - * Read additional document summary information - */ - private function _readDocumentSummaryInformation() - { - if (!isset($this->_documentSummaryInformation)) { - return; - } - - // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) - // offset: 2; size: 2; - // offset: 4; size: 2; OS version - // offset: 6; size: 2; OS indicator - // offset: 8; size: 16 - // offset: 24; size: 4; section count - $secCount = self::_GetInt4d($this->_documentSummaryInformation, 24); -// echo '$secCount = ', $secCount,'
'; - - // offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae - // offset: 44; size: 4; first section offset - $secOffset = self::_GetInt4d($this->_documentSummaryInformation, 44); -// echo '$secOffset = ', $secOffset,'
'; - - // section header - // offset: $secOffset; size: 4; section length - $secLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset); -// echo '$secLength = ', $secLength,'
'; - - // offset: $secOffset+4; size: 4; property count - $countProperties = self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4); -// echo '$countProperties = ', $countProperties,'
'; - - // initialize code page (used to resolve string values) - $codePage = 'CP1252'; - - // offset: ($secOffset+8); size: var - // loop through property decarations and properties - for ($i = 0; $i < $countProperties; ++$i) { -// echo 'Property ', $i,'
'; - // offset: ($secOffset+8) + (8 * $i); size: 4; property ID - $id = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i)); -// echo 'ID is ', $id,'
'; - - // Use value of property id as appropriate - // offset: 60 + 8 * $i; size: 4; offset from beginning of section (48) - $offset = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i)); - - $type = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + $offset); -// echo 'Type is ', $type,', '; - - // initialize property value - $value = null; - - // extract property value based on property type - switch ($type) { - case 0x02: // 2 byte signed integer - $value = self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset); - break; - - case 0x03: // 4 byte signed integer - $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; - - case 0x1E: // null-terminated string prepended by dword string length - $byteLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset); - $value = substr($this->_documentSummaryInformation, $secOffset + 8 + $offset, $byteLength); - $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage); - $value = rtrim($value); - break; - - case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - // PHP-Time - $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_documentSummaryInformation, $secOffset + 4 + $offset, 8)); - break; - - case 0x47: // Clipboard format - // not needed yet, fix later if necessary - break; - } - - switch ($id) { - case 0x01: // Code Page - $codePage = PHPExcel_Shared_CodePage::NumberToName($value); - break; - - case 0x02: // Category - $this->_phpExcel->getProperties()->setCategory($value); - break; - - case 0x03: // Presentation Target - // Not supported by PHPExcel - break; - - case 0x04: // Bytes - // Not supported by PHPExcel - break; - - case 0x05: // Lines - // Not supported by PHPExcel - break; - - case 0x06: // Paragraphs - // Not supported by PHPExcel - break; - - case 0x07: // Slides - // Not supported by PHPExcel - break; - - case 0x08: // Notes - // Not supported by PHPExcel - break; - - case 0x09: // Hidden Slides - // Not supported by PHPExcel - break; - - case 0x0A: // MM Clips - // Not supported by PHPExcel - break; - - case 0x0B: // Scale Crop - // Not supported by PHPExcel - break; - - case 0x0C: // Heading Pairs - // Not supported by PHPExcel - break; - - case 0x0D: // Titles of Parts - // Not supported by PHPExcel - break; - - case 0x0E: // Manager - $this->_phpExcel->getProperties()->setManager($value); - break; - - case 0x0F: // Company - $this->_phpExcel->getProperties()->setCompany($value); - break; - - case 0x10: // Links up-to-date - // Not supported by PHPExcel - break; - - } - } - } - - - /** - * Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record. - */ - private function _readDefault() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); -// $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - } - - - /** - * The NOTE record specifies a comment associated with a particular cell. In Excel 95 (BIFF7) and earlier versions, - * this record stores a note (cell note). This feature was significantly enhanced in Excel 97. - */ - private function _readNote() - { -// echo 'Read Cell Annotation
'; - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly) { - return; - } - - $cellAddress = $this->_readBIFF8CellAddress(substr($recordData, 0, 4)); - if ($this->_version == self::XLS_BIFF8) { - $noteObjID = self::_GetInt2d($recordData, 6); - $noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8)); - $noteAuthor = $noteAuthor['value']; -// echo 'Note Address=', $cellAddress,'
'; -// echo 'Note Object ID=', $noteObjID,'
'; -// echo 'Note Author=', $noteAuthor,'
'; -// - $this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress, - 'objectID' => $noteObjID, - 'author' => $noteAuthor - ); - } else { - $extension = false; - if ($cellAddress == '$B$65536') { - // If the address row is -1 and the column is 0, (which translates as $B$65536) then this is a continuation - // note from the previous cell annotation. We're not yet handling this, so annotations longer than the - // max 2048 bytes will probably throw a wobbly. - $row = self::_GetInt2d($recordData, 0); - $extension = true; - $cellAddress = array_pop(array_keys($this->_phpSheet->getComments())); - } -// echo 'Note Address=', $cellAddress,'
'; - - $cellAddress = str_replace('$','', $cellAddress); - $noteLength = self::_GetInt2d($recordData, 4); - $noteText = trim(substr($recordData, 6)); -// echo 'Note Length=', $noteLength,'
'; -// echo 'Note Text=', $noteText,'
'; - - if ($extension) { - // Concatenate this extension with the currently set comment for the cell - $comment = $this->_phpSheet->getComment( $cellAddress ); - $commentText = $comment->getText()->getPlainText(); - $comment->setText($this->_parseRichText($commentText.$noteText) ); - } else { - // Set comment for the cell - $this->_phpSheet->getComment( $cellAddress ) -// ->setAuthor( $author ) - ->setText($this->_parseRichText($noteText) ); - } - } - - } - - - /** - * The TEXT Object record contains the text associated with a cell annotation. - */ - private function _readTextObject() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly) { - return; - } - - // recordData consists of an array of subrecords looking like this: - // grbit: 2 bytes; Option Flags - // rot: 2 bytes; rotation - // cchText: 2 bytes; length of the text (in the first continue record) - // cbRuns: 2 bytes; length of the formatting (in the second continue record) - // followed by the continuation records containing the actual text and formatting - $grbitOpts = self::_GetInt2d($recordData, 0); - $rot = self::_GetInt2d($recordData, 2); - $cchText = self::_GetInt2d($recordData, 10); - $cbRuns = self::_GetInt2d($recordData, 12); - $text = $this->_getSplicedRecordData(); - - $this->_textObjects[$this->textObjRef] = array( - 'text' => substr($text["recordData"], $text["spliceOffsets"][0]+1, $cchText), - 'format' => substr($text["recordData"], $text["spliceOffsets"][1], $cbRuns), - 'alignment' => $grbitOpts, - 'rotation' => $rot - ); - -// echo '_readTextObject()
'; -// var_dump($this->_textObjects[$this->textObjRef]); -// echo '
'; - } - - - /** - * Read BOF - */ - private function _readBof() - { - $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; - - // offset: 2; size: 2; type of the following data - $substreamType = self::_GetInt2d($recordData, 2); - - switch ($substreamType) { - case self::XLS_WorkbookGlobals: - $version = self::_GetInt2d($recordData, 0); - if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) { - throw new PHPExcel_Reader_Exception('Cannot read this Excel file. Version is too old.'); - } - $this->_version = $version; - break; - - case self::XLS_Worksheet: - // do not use this version information for anything - // it is unreliable (OpenOffice doc, 5.8), use only version information from the global stream - break; - - default: - // substream, e.g. chart - // just skip the entire substream - do { - $code = self::_GetInt2d($this->_data, $this->_pos); - $this->_readDefault(); - } while ($code != self::XLS_Type_EOF && $this->_pos < $this->_dataSize); - break; - } - } - - - /** - * FILEPASS - * - * This record is part of the File Protection Block. It - * contains information about the read/write password of the - * file. All record contents following this record will be - * encrypted. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - * - * The decryption functions and objects used from here on in - * are based on the source of Spreadsheet-ParseExcel: - * http://search.cpan.org/~jmcnamara/Spreadsheet-ParseExcel/ - */ - private function _readFilepass() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - - if ($length != 54) { - throw new PHPExcel_Reader_Exception('Unexpected file pass record length'); - } - - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_verifyPassword( - 'VelvetSweatshop', - substr($recordData, 6, 16), - substr($recordData, 22, 16), - substr($recordData, 38, 16), - $this->_md5Ctxt - )) { - throw new PHPExcel_Reader_Exception('Decryption password incorrect'); - } - - $this->_encryption = self::MS_BIFF_CRYPTO_RC4; - - // Decryption required from the record after next onwards - $this->_encryptionStartPos = $this->_pos + self::_GetInt2d($this->_data, $this->_pos + 2); - } - - /** - * Make an RC4 decryptor for the given block - * - * @var int $block Block for which to create decrypto - * @var string $valContext MD5 context state - * - * @return PHPExcel_Reader_Excel5_RC4 - */ - private function _makeKey($block, $valContext) - { - $pwarray = str_repeat("\0", 64); - - for ($i = 0; $i < 5; $i++) { - $pwarray[$i] = $valContext[$i]; - } - - $pwarray[5] = chr($block & 0xff); - $pwarray[6] = chr(($block >> 8) & 0xff); - $pwarray[7] = chr(($block >> 16) & 0xff); - $pwarray[8] = chr(($block >> 24) & 0xff); - - $pwarray[9] = "\x80"; - $pwarray[56] = "\x48"; - - $md5 = new PHPExcel_Reader_Excel5_MD5(); - $md5->add($pwarray); - - $s = $md5->getContext(); - return new PHPExcel_Reader_Excel5_RC4($s); - } - - /** - * Verify RC4 file password - * - * @var string $password Password to check - * @var string $docid Document id - * @var string $salt_data Salt data - * @var string $hashedsalt_data Hashed salt data - * @var string &$valContext Set to the MD5 context of the value - * - * @return bool Success - */ - private function _verifyPassword($password, $docid, $salt_data, $hashedsalt_data, &$valContext) - { - $pwarray = str_repeat("\0", 64); - - for ($i = 0; $i < strlen($password); $i++) { - $o = ord(substr($password, $i, 1)); - $pwarray[2 * $i] = chr($o & 0xff); - $pwarray[2 * $i + 1] = chr(($o >> 8) & 0xff); - } - $pwarray[2 * $i] = chr(0x80); - $pwarray[56] = chr(($i << 4) & 0xff); - - $md5 = new PHPExcel_Reader_Excel5_MD5(); - $md5->add($pwarray); - - $mdContext1 = $md5->getContext(); - - $offset = 0; - $keyoffset = 0; - $tocopy = 5; - - $md5->reset(); - - while ($offset != 16) { - if ((64 - $offset) < 5) { - $tocopy = 64 - $offset; - } - - for ($i = 0; $i <= $tocopy; $i++) { - $pwarray[$offset + $i] = $mdContext1[$keyoffset + $i]; - } - - $offset += $tocopy; - - if ($offset == 64) { - $md5->add($pwarray); - $keyoffset = $tocopy; - $tocopy = 5 - $tocopy; - $offset = 0; - continue; - } - - $keyoffset = 0; - $tocopy = 5; - for ($i = 0; $i < 16; $i++) { - $pwarray[$offset + $i] = $docid[$i]; - } - $offset += 16; - } - - $pwarray[16] = "\x80"; - for ($i = 0; $i < 47; $i++) { - $pwarray[17 + $i] = "\0"; - } - $pwarray[56] = "\x80"; - $pwarray[57] = "\x0a"; - - $md5->add($pwarray); - $valContext = $md5->getContext(); - - $key = $this->_makeKey(0, $valContext); - - $salt = $key->RC4($salt_data); - $hashedsalt = $key->RC4($hashedsalt_data); - - $salt .= "\x80" . str_repeat("\0", 47); - $salt[56] = "\x80"; - - $md5->reset(); - $md5->add($salt); - $mdContext2 = $md5->getContext(); - - return $mdContext2 == $hashedsalt; - } - - /** - * CODEPAGE - * - * This record stores the text encoding used to write byte - * strings, stored as MS Windows code page identifier. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readCodepage() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; code page identifier - $codepage = self::_GetInt2d($recordData, 0); - - $this->_codepage = PHPExcel_Shared_CodePage::NumberToName($codepage); - } - - - /** - * DATEMODE - * - * This record specifies the base date for displaying date - * values. All dates are stored as count of days past this - * base date. In BIFF2-BIFF4 this record is part of the - * Calculation Settings Block. In BIFF5-BIFF8 it is - * stored in the Workbook Globals Substream. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readDateMode() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; 0 = base 1900, 1 = base 1904 - PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); - if (ord($recordData{0}) == 1) { - PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); - } - } - - - /** - * Read a FONT record - */ - private function _readFont() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - $objFont = new PHPExcel_Style_Font(); - - // offset: 0; size: 2; height of the font (in twips = 1/20 of a point) - $size = self::_GetInt2d($recordData, 0); - $objFont->setSize($size / 20); - - // offset: 2; size: 2; option flags - // bit: 0; mask 0x0001; bold (redundant in BIFF5-BIFF8) - // bit: 1; mask 0x0002; italic - $isItalic = (0x0002 & self::_GetInt2d($recordData, 2)) >> 1; - if ($isItalic) $objFont->setItalic(true); - - // bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8) - // bit: 3; mask 0x0008; strike - $isStrike = (0x0008 & self::_GetInt2d($recordData, 2)) >> 3; - if ($isStrike) $objFont->setStrikethrough(true); - - // offset: 4; size: 2; colour index - $colorIndex = self::_GetInt2d($recordData, 4); - $objFont->colorIndex = $colorIndex; - - // offset: 6; size: 2; font weight - $weight = self::_GetInt2d($recordData, 6); - switch ($weight) { - case 0x02BC: - $objFont->setBold(true); - break; - } - - // offset: 8; size: 2; escapement type - $escapement = self::_GetInt2d($recordData, 8); - switch ($escapement) { - case 0x0001: - $objFont->setSuperScript(true); - break; - case 0x0002: - $objFont->setSubScript(true); - break; - } - - // offset: 10; size: 1; underline type - $underlineType = ord($recordData{10}); - switch ($underlineType) { - case 0x00: - break; // no underline - case 0x01: - $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); - break; - case 0x02: - $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE); - break; - case 0x21: - $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING); - break; - case 0x22: - $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING); - break; - } - - // offset: 11; size: 1; font family - // offset: 12; size: 1; character set - // offset: 13; size: 1; not used - // offset: 14; size: var; font name - if ($this->_version == self::XLS_BIFF8) { - $string = self::_readUnicodeStringShort(substr($recordData, 14)); - } else { - $string = $this->_readByteStringShort(substr($recordData, 14)); - } - $objFont->setName($string['value']); - - $this->_objFonts[] = $objFont; - } - } - - - /** - * FORMAT - * - * This record contains information about a number format. - * All FORMAT records occur together in a sequential list. - * - * In BIFF2-BIFF4 other records referencing a FORMAT record - * contain a zero-based index into this list. From BIFF5 on - * the FORMAT record contains the index itself that will be - * used by other records. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readFormat() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - $indexCode = self::_GetInt2d($recordData, 0); - - if ($this->_version == self::XLS_BIFF8) { - $string = self::_readUnicodeStringLong(substr($recordData, 2)); - } else { - // BIFF7 - $string = $this->_readByteStringShort(substr($recordData, 2)); - } - - $formatString = $string['value']; - $this->_formats[$indexCode] = $formatString; - } - } - - - /** - * XF - Extended Format - * - * This record contains formatting information for cells, rows, columns or styles. - * According to http://support.microsoft.com/kb/147732 there are always at least 15 cell style XF - * and 1 cell XF. - * Inspection of Excel files generated by MS Office Excel shows that XF records 0-14 are cell style XF - * and XF record 15 is a cell XF - * We only read the first cell style XF and skip the remaining cell style XF records - * We read all cell XF records. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readXf() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - $objStyle = new PHPExcel_Style(); - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; Index to FONT record - if (self::_GetInt2d($recordData, 0) < 4) { - $fontIndex = self::_GetInt2d($recordData, 0); - } else { - // this has to do with that index 4 is omitted in all BIFF versions for some strange reason - // check the OpenOffice documentation of the FONT record - $fontIndex = self::_GetInt2d($recordData, 0) - 1; - } - $objStyle->setFont($this->_objFonts[$fontIndex]); - - // offset: 2; size: 2; Index to FORMAT record - $numberFormatIndex = self::_GetInt2d($recordData, 2); - if (isset($this->_formats[$numberFormatIndex])) { - // then we have user-defined format code - $numberformat = array('code' => $this->_formats[$numberFormatIndex]); - } elseif (($code = PHPExcel_Style_NumberFormat::builtInFormatCode($numberFormatIndex)) !== '') { - // then we have built-in format code - $numberformat = array('code' => $code); - } else { - // we set the general format code - $numberformat = array('code' => 'General'); - } - $objStyle->getNumberFormat()->setFormatCode($numberformat['code']); - - // offset: 4; size: 2; XF type, cell protection, and parent style XF - // bit 2-0; mask 0x0007; XF_TYPE_PROT - $xfTypeProt = self::_GetInt2d($recordData, 4); - // bit 0; mask 0x01; 1 = cell is locked - $isLocked = (0x01 & $xfTypeProt) >> 0; - $objStyle->getProtection()->setLocked($isLocked ? - PHPExcel_Style_Protection::PROTECTION_INHERIT : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); - - // bit 1; mask 0x02; 1 = Formula is hidden - $isHidden = (0x02 & $xfTypeProt) >> 1; - $objStyle->getProtection()->setHidden($isHidden ? - PHPExcel_Style_Protection::PROTECTION_PROTECTED : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); - - // bit 2; mask 0x04; 0 = Cell XF, 1 = Cell Style XF - $isCellStyleXf = (0x04 & $xfTypeProt) >> 2; - - // offset: 6; size: 1; Alignment and text break - // bit 2-0, mask 0x07; horizontal alignment - $horAlign = (0x07 & ord($recordData{6})) >> 0; - switch ($horAlign) { - case 0: - $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_GENERAL); - break; - case 1: - $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); - break; - case 2: - $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); - break; - case 3: - $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); - break; - case 4: - $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_FILL); - break; - case 5: - $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY); - break; - case 6: - $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS); - break; - } - // bit 3, mask 0x08; wrap text - $wrapText = (0x08 & ord($recordData{6})) >> 3; - switch ($wrapText) { - case 0: - $objStyle->getAlignment()->setWrapText(false); - break; - case 1: - $objStyle->getAlignment()->setWrapText(true); - break; - } - // bit 6-4, mask 0x70; vertical alignment - $vertAlign = (0x70 & ord($recordData{6})) >> 4; - switch ($vertAlign) { - case 0: - $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); - break; - case 1: - $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); - break; - case 2: - $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_BOTTOM); - break; - case 3: - $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_JUSTIFY); - break; - } - - if ($this->_version == self::XLS_BIFF8) { - // offset: 7; size: 1; XF_ROTATION: Text rotation angle - $angle = ord($recordData{7}); - $rotation = 0; - if ($angle <= 90) { - $rotation = $angle; - } else if ($angle <= 180) { - $rotation = 90 - $angle; - } else if ($angle == 255) { - $rotation = -165; - } - $objStyle->getAlignment()->setTextRotation($rotation); - - // offset: 8; size: 1; Indentation, shrink to cell size, and text direction - // bit: 3-0; mask: 0x0F; indent level - $indent = (0x0F & ord($recordData{8})) >> 0; - $objStyle->getAlignment()->setIndent($indent); - - // bit: 4; mask: 0x10; 1 = shrink content to fit into cell - $shrinkToFit = (0x10 & ord($recordData{8})) >> 4; - switch ($shrinkToFit) { - case 0: - $objStyle->getAlignment()->setShrinkToFit(false); - break; - case 1: - $objStyle->getAlignment()->setShrinkToFit(true); - break; - } - - // offset: 9; size: 1; Flags used for attribute groups - - // offset: 10; size: 4; Cell border lines and background area - // bit: 3-0; mask: 0x0000000F; left style - if ($bordersLeftStyle = self::_mapBorderStyle((0x0000000F & self::_GetInt4d($recordData, 10)) >> 0)) { - $objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle); - } - // bit: 7-4; mask: 0x000000F0; right style - if ($bordersRightStyle = self::_mapBorderStyle((0x000000F0 & self::_GetInt4d($recordData, 10)) >> 4)) { - $objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle); - } - // bit: 11-8; mask: 0x00000F00; top style - if ($bordersTopStyle = self::_mapBorderStyle((0x00000F00 & self::_GetInt4d($recordData, 10)) >> 8)) { - $objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle); - } - // bit: 15-12; mask: 0x0000F000; bottom style - if ($bordersBottomStyle = self::_mapBorderStyle((0x0000F000 & self::_GetInt4d($recordData, 10)) >> 12)) { - $objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle); - } - // bit: 22-16; mask: 0x007F0000; left color - $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & self::_GetInt4d($recordData, 10)) >> 16; - - // bit: 29-23; mask: 0x3F800000; right color - $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & self::_GetInt4d($recordData, 10)) >> 23; - - // bit: 30; mask: 0x40000000; 1 = diagonal line from top left to right bottom - $diagonalDown = (0x40000000 & self::_GetInt4d($recordData, 10)) >> 30 ? - true : false; - - // bit: 31; mask: 0x80000000; 1 = diagonal line from bottom left to top right - $diagonalUp = (0x80000000 & self::_GetInt4d($recordData, 10)) >> 31 ? - true : false; - - if ($diagonalUp == false && $diagonalDown == false) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE); - } elseif ($diagonalUp == true && $diagonalDown == false) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP); - } elseif ($diagonalUp == false && $diagonalDown == true) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN); - } elseif ($diagonalUp == true && $diagonalDown == true) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH); - } - - // offset: 14; size: 4; - // bit: 6-0; mask: 0x0000007F; top color - $objStyle->getBorders()->getTop()->colorIndex = (0x0000007F & self::_GetInt4d($recordData, 14)) >> 0; - - // bit: 13-7; mask: 0x00003F80; bottom color - $objStyle->getBorders()->getBottom()->colorIndex = (0x00003F80 & self::_GetInt4d($recordData, 14)) >> 7; - - // bit: 20-14; mask: 0x001FC000; diagonal color - $objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 & self::_GetInt4d($recordData, 14)) >> 14; - - // bit: 24-21; mask: 0x01E00000; diagonal style - if ($bordersDiagonalStyle = self::_mapBorderStyle((0x01E00000 & self::_GetInt4d($recordData, 14)) >> 21)) { - $objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle); - } - - // bit: 31-26; mask: 0xFC000000 fill pattern - if ($fillType = self::_mapFillPattern((0xFC000000 & self::_GetInt4d($recordData, 14)) >> 26)) { - $objStyle->getFill()->setFillType($fillType); - } - // offset: 18; size: 2; pattern and background colour - // bit: 6-0; mask: 0x007F; color index for pattern color - $objStyle->getFill()->startcolorIndex = (0x007F & self::_GetInt2d($recordData, 18)) >> 0; - - // bit: 13-7; mask: 0x3F80; color index for pattern background - $objStyle->getFill()->endcolorIndex = (0x3F80 & self::_GetInt2d($recordData, 18)) >> 7; - } else { - // BIFF5 - - // offset: 7; size: 1; Text orientation and flags - $orientationAndFlags = ord($recordData{7}); - - // bit: 1-0; mask: 0x03; XF_ORIENTATION: Text orientation - $xfOrientation = (0x03 & $orientationAndFlags) >> 0; - switch ($xfOrientation) { - case 0: - $objStyle->getAlignment()->setTextRotation(0); - break; - case 1: - $objStyle->getAlignment()->setTextRotation(-165); - break; - case 2: - $objStyle->getAlignment()->setTextRotation(90); - break; - case 3: - $objStyle->getAlignment()->setTextRotation(-90); - break; - } - - // offset: 8; size: 4; cell border lines and background area - $borderAndBackground = self::_GetInt4d($recordData, 8); - - // bit: 6-0; mask: 0x0000007F; color index for pattern color - $objStyle->getFill()->startcolorIndex = (0x0000007F & $borderAndBackground) >> 0; - - // bit: 13-7; mask: 0x00003F80; color index for pattern background - $objStyle->getFill()->endcolorIndex = (0x00003F80 & $borderAndBackground) >> 7; - - // bit: 21-16; mask: 0x003F0000; fill pattern - $objStyle->getFill()->setFillType(self::_mapFillPattern((0x003F0000 & $borderAndBackground) >> 16)); - - // bit: 24-22; mask: 0x01C00000; bottom line style - $objStyle->getBorders()->getBottom()->setBorderStyle(self::_mapBorderStyle((0x01C00000 & $borderAndBackground) >> 22)); - - // bit: 31-25; mask: 0xFE000000; bottom line color - $objStyle->getBorders()->getBottom()->colorIndex = (0xFE000000 & $borderAndBackground) >> 25; - - // offset: 12; size: 4; cell border lines - $borderLines = self::_GetInt4d($recordData, 12); - - // bit: 2-0; mask: 0x00000007; top line style - $objStyle->getBorders()->getTop()->setBorderStyle(self::_mapBorderStyle((0x00000007 & $borderLines) >> 0)); - - // bit: 5-3; mask: 0x00000038; left line style - $objStyle->getBorders()->getLeft()->setBorderStyle(self::_mapBorderStyle((0x00000038 & $borderLines) >> 3)); - - // bit: 8-6; mask: 0x000001C0; right line style - $objStyle->getBorders()->getRight()->setBorderStyle(self::_mapBorderStyle((0x000001C0 & $borderLines) >> 6)); - - // bit: 15-9; mask: 0x0000FE00; top line color index - $objStyle->getBorders()->getTop()->colorIndex = (0x0000FE00 & $borderLines) >> 9; - - // bit: 22-16; mask: 0x007F0000; left line color index - $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & $borderLines) >> 16; - - // bit: 29-23; mask: 0x3F800000; right line color index - $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & $borderLines) >> 23; - } - - // add cellStyleXf or cellXf and update mapping - if ($isCellStyleXf) { - // we only read one style XF record which is always the first - if ($this->_xfIndex == 0) { - $this->_phpExcel->addCellStyleXf($objStyle); - $this->_mapCellStyleXfIndex[$this->_xfIndex] = 0; - } - } else { - // we read all cell XF records - $this->_phpExcel->addCellXf($objStyle); - $this->_mapCellXfIndex[$this->_xfIndex] = count($this->_phpExcel->getCellXfCollection()) - 1; - } - - // update XF index for when we read next record - ++$this->_xfIndex; - } - } - - - /** - * - */ - private function _readXfExt() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; 0x087D = repeated header - - // offset: 2; size: 2 - - // offset: 4; size: 8; not used - - // offset: 12; size: 2; record version - - // offset: 14; size: 2; index to XF record which this record modifies - $ixfe = self::_GetInt2d($recordData, 14); - - // offset: 16; size: 2; not used - - // offset: 18; size: 2; number of extension properties that follow - $cexts = self::_GetInt2d($recordData, 18); - - // start reading the actual extension data - $offset = 20; - while ($offset < $length) { - // extension type - $extType = self::_GetInt2d($recordData, $offset); - - // extension length - $cb = self::_GetInt2d($recordData, $offset + 2); - - // extension data - $extData = substr($recordData, $offset + 4, $cb); - - switch ($extType) { - case 4: // fill start color - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); - $fill->getStartColor()->setRGB($rgb); - unset($fill->startcolorIndex); // normal color index does not apply, discard - } - } - break; - - case 5: // fill end color - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); - $fill->getEndColor()->setRGB($rgb); - unset($fill->endcolorIndex); // normal color index does not apply, discard - } - } - break; - - case 7: // border color top - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $top = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getTop(); - $top->getColor()->setRGB($rgb); - unset($top->colorIndex); // normal color index does not apply, discard - } - } - break; - - case 8: // border color bottom - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $bottom = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getBottom(); - $bottom->getColor()->setRGB($rgb); - unset($bottom->colorIndex); // normal color index does not apply, discard - } - } - break; - - case 9: // border color left - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $left = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getLeft(); - $left->getColor()->setRGB($rgb); - unset($left->colorIndex); // normal color index does not apply, discard - } - } - break; - - case 10: // border color right - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $right = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getRight(); - $right->getColor()->setRGB($rgb); - unset($right->colorIndex); // normal color index does not apply, discard - } - } - break; - - case 11: // border color diagonal - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $diagonal = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getDiagonal(); - $diagonal->getColor()->setRGB($rgb); - unset($diagonal->colorIndex); // normal color index does not apply, discard - } - } - break; - - case 13: // font color - $xclfType = self::_GetInt2d($extData, 0); // color type - $xclrValue = substr($extData, 4, 4); // color value (value based on color type) - - if ($xclfType == 2) { - $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); - - // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { - $font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont(); - $font->getColor()->setRGB($rgb); - unset($font->colorIndex); // normal color index does not apply, discard - } - } - break; - } - - $offset += $cb; - } - } - - } - - - /** - * Read STYLE record - */ - private function _readStyle() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; index to XF record and flag for built-in style - $ixfe = self::_GetInt2d($recordData, 0); - - // bit: 11-0; mask 0x0FFF; index to XF record - $xfIndex = (0x0FFF & $ixfe) >> 0; - - // bit: 15; mask 0x8000; 0 = user-defined style, 1 = built-in style - $isBuiltIn = (bool) ((0x8000 & $ixfe) >> 15); - - if ($isBuiltIn) { - // offset: 2; size: 1; identifier for built-in style - $builtInId = ord($recordData{2}); - - switch ($builtInId) { - case 0x00: - // currently, we are not using this for anything - break; - - default: - break; - } - - } else { - // user-defined; not supported by PHPExcel - } - } - } - - - /** - * Read PALETTE record - */ - private function _readPalette() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; number of following colors - $nm = self::_GetInt2d($recordData, 0); - - // list of RGB colors - for ($i = 0; $i < $nm; ++$i) { - $rgb = substr($recordData, 2 + 4 * $i, 4); - $this->_palette[] = self::_readRGB($rgb); - } - } - } - - - /** - * SHEET - * - * This record is located in the Workbook Globals - * Substream and represents a sheet inside the workbook. - * One SHEET record is written for each sheet. It stores the - * sheet name and a stream offset to the BOF record of the - * respective Sheet Substream within the Workbook Stream. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readSheet() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // offset: 0; size: 4; absolute stream position of the BOF record of the sheet - // NOTE: not encrypted - $rec_offset = self::_GetInt4d($this->_data, $this->_pos + 4); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 4; size: 1; sheet state - switch (ord($recordData{4})) { - case 0x00: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break; - case 0x01: $sheetState = PHPExcel_Worksheet::SHEETSTATE_HIDDEN; break; - case 0x02: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN; break; - default: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break; - } - - // offset: 5; size: 1; sheet type - $sheetType = ord($recordData{5}); - - // offset: 6; size: var; sheet name - if ($this->_version == self::XLS_BIFF8) { - $string = self::_readUnicodeStringShort(substr($recordData, 6)); - $rec_name = $string['value']; - } elseif ($this->_version == self::XLS_BIFF7) { - $string = $this->_readByteStringShort(substr($recordData, 6)); - $rec_name = $string['value']; - } - - $this->_sheets[] = array( - 'name' => $rec_name, - 'offset' => $rec_offset, - 'sheetState' => $sheetState, - 'sheetType' => $sheetType, - ); - } - - - /** - * Read EXTERNALBOOK record - */ - private function _readExternalBook() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset within record data - $offset = 0; - - // there are 4 types of records - if (strlen($recordData) > 4) { - // external reference - // offset: 0; size: 2; number of sheet names ($nm) - $nm = self::_GetInt2d($recordData, 0); - $offset += 2; - - // offset: 2; size: var; encoded URL without sheet name (Unicode string, 16-bit length) - $encodedUrlString = self::_readUnicodeStringLong(substr($recordData, 2)); - $offset += $encodedUrlString['size']; - - // offset: var; size: var; list of $nm sheet names (Unicode strings, 16-bit length) - $externalSheetNames = array(); - for ($i = 0; $i < $nm; ++$i) { - $externalSheetNameString = self::_readUnicodeStringLong(substr($recordData, $offset)); - $externalSheetNames[] = $externalSheetNameString['value']; - $offset += $externalSheetNameString['size']; - } - - // store the record data - $this->_externalBooks[] = array( - 'type' => 'external', - 'encodedUrl' => $encodedUrlString['value'], - 'externalSheetNames' => $externalSheetNames, - ); - - } elseif (substr($recordData, 2, 2) == pack('CC', 0x01, 0x04)) { - // internal reference - // offset: 0; size: 2; number of sheet in this document - // offset: 2; size: 2; 0x01 0x04 - $this->_externalBooks[] = array( - 'type' => 'internal', - ); - } elseif (substr($recordData, 0, 4) == pack('vCC', 0x0001, 0x01, 0x3A)) { - // add-in function - // offset: 0; size: 2; 0x0001 - $this->_externalBooks[] = array( - 'type' => 'addInFunction', - ); - } elseif (substr($recordData, 0, 2) == pack('v', 0x0000)) { - // DDE links, OLE links - // offset: 0; size: 2; 0x0000 - // offset: 2; size: var; encoded source document name - $this->_externalBooks[] = array( - 'type' => 'DDEorOLE', - ); - } - } - - - /** - * Read EXTERNNAME record. - */ - private function _readExternName() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // external sheet references provided for named cells - if ($this->_version == self::XLS_BIFF8) { - // offset: 0; size: 2; options - $options = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; - - // offset: 4; size: 2; not used - - // offset: 6; size: var - $nameString = self::_readUnicodeStringShort(substr($recordData, 6)); - - // offset: var; size: var; formula data - $offset = 6 + $nameString['size']; - $formula = $this->_getFormulaFromStructure(substr($recordData, $offset)); - - $this->_externalNames[] = array( - 'name' => $nameString['value'], - 'formula' => $formula, - ); - } - } - - - /** - * Read EXTERNSHEET record - */ - private function _readExternSheet() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // external sheet references provided for named cells - if ($this->_version == self::XLS_BIFF8) { - // offset: 0; size: 2; number of following ref structures - $nm = self::_GetInt2d($recordData, 0); - for ($i = 0; $i < $nm; ++$i) { - $this->_ref[] = array( - // offset: 2 + 6 * $i; index to EXTERNALBOOK record - 'externalBookIndex' => self::_GetInt2d($recordData, 2 + 6 * $i), - // offset: 4 + 6 * $i; index to first sheet in EXTERNALBOOK record - 'firstSheetIndex' => self::_GetInt2d($recordData, 4 + 6 * $i), - // offset: 6 + 6 * $i; index to last sheet in EXTERNALBOOK record - 'lastSheetIndex' => self::_GetInt2d($recordData, 6 + 6 * $i), - ); - } - } - } - - - /** - * DEFINEDNAME - * - * This record is part of a Link Table. It contains the name - * and the token array of an internal defined name. Token - * arrays of defined names contain tokens with aberrant - * token classes. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readDefinedName() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_version == self::XLS_BIFF8) { - // retrieves named cells - - // offset: 0; size: 2; option flags - $opts = self::_GetInt2d($recordData, 0); - - // bit: 5; mask: 0x0020; 0 = user-defined name, 1 = built-in-name - $isBuiltInName = (0x0020 & $opts) >> 5; - - // offset: 2; size: 1; keyboard shortcut - - // offset: 3; size: 1; length of the name (character count) - $nlen = ord($recordData{3}); - - // offset: 4; size: 2; size of the formula data (it can happen that this is zero) - // note: there can also be additional data, this is not included in $flen - $flen = self::_GetInt2d($recordData, 4); - - // offset: 8; size: 2; 0=Global name, otherwise index to sheet (1-based) - $scope = self::_GetInt2d($recordData, 8); - - // offset: 14; size: var; Name (Unicode string without length field) - $string = self::_readUnicodeString(substr($recordData, 14), $nlen); - - // offset: var; size: $flen; formula data - $offset = 14 + $string['size']; - $formulaStructure = pack('v', $flen) . substr($recordData, $offset); - - try { - $formula = $this->_getFormulaFromStructure($formulaStructure); - } catch (PHPExcel_Exception $e) { - $formula = ''; - } - - $this->_definedname[] = array( - 'isBuiltInName' => $isBuiltInName, - 'name' => $string['value'], - 'formula' => $formula, - 'scope' => $scope, - ); - } - } - - - /** - * Read MSODRAWINGGROUP record - */ - private function _readMsoDrawingGroup() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - - // get spliced record data - $splicedRecordData = $this->_getSplicedRecordData(); - $recordData = $splicedRecordData['recordData']; - - $this->_drawingGroupData .= $recordData; - } - - - /** - * SST - Shared String Table - * - * This record contains a list of all strings used anywhere - * in the workbook. Each string occurs only once. The - * workbook uses indexes into the list to reference the - * strings. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - **/ - private function _readSst() - { - // offset within (spliced) record data - $pos = 0; - - // get spliced record data - $splicedRecordData = $this->_getSplicedRecordData(); - - $recordData = $splicedRecordData['recordData']; - $spliceOffsets = $splicedRecordData['spliceOffsets']; - - // offset: 0; size: 4; total number of strings in the workbook - $pos += 4; - - // offset: 4; size: 4; number of following strings ($nm) - $nm = self::_GetInt4d($recordData, 4); - $pos += 4; - - // loop through the Unicode strings (16-bit length) - for ($i = 0; $i < $nm; ++$i) { - - // number of characters in the Unicode string - $numChars = self::_GetInt2d($recordData, $pos); - $pos += 2; - - // option flags - $optionFlags = ord($recordData{$pos}); - ++$pos; - - // bit: 0; mask: 0x01; 0 = compressed; 1 = uncompressed - $isCompressed = (($optionFlags & 0x01) == 0) ; - - // bit: 2; mask: 0x02; 0 = ordinary; 1 = Asian phonetic - $hasAsian = (($optionFlags & 0x04) != 0); - - // bit: 3; mask: 0x03; 0 = ordinary; 1 = Rich-Text - $hasRichText = (($optionFlags & 0x08) != 0); - - if ($hasRichText) { - // number of Rich-Text formatting runs - $formattingRuns = self::_GetInt2d($recordData, $pos); - $pos += 2; - } - - if ($hasAsian) { - // size of Asian phonetic setting - $extendedRunLength = self::_GetInt4d($recordData, $pos); - $pos += 4; - } - - // expected byte length of character array if not split - $len = ($isCompressed) ? $numChars : $numChars * 2; - - // look up limit position - foreach ($spliceOffsets as $spliceOffset) { - // it can happen that the string is empty, therefore we need - // <= and not just < - if ($pos <= $spliceOffset) { - $limitpos = $spliceOffset; - break; - } - } - - if ($pos + $len <= $limitpos) { - // character array is not split between records - - $retstr = substr($recordData, $pos, $len); - $pos += $len; - - } else { - // character array is split between records - - // first part of character array - $retstr = substr($recordData, $pos, $limitpos - $pos); - - $bytesRead = $limitpos - $pos; - - // remaining characters in Unicode string - $charsLeft = $numChars - (($isCompressed) ? $bytesRead : ($bytesRead / 2)); - - $pos = $limitpos; - - // keep reading the characters - while ($charsLeft > 0) { - - // look up next limit position, in case the string span more than one continue record - foreach ($spliceOffsets as $spliceOffset) { - if ($pos < $spliceOffset) { - $limitpos = $spliceOffset; - break; - } - } - - // repeated option flags - // OpenOffice.org documentation 5.21 - $option = ord($recordData{$pos}); - ++$pos; - - if ($isCompressed && ($option == 0)) { - // 1st fragment compressed - // this fragment compressed - $len = min($charsLeft, $limitpos - $pos); - $retstr .= substr($recordData, $pos, $len); - $charsLeft -= $len; - $isCompressed = true; - - } elseif (!$isCompressed && ($option != 0)) { - // 1st fragment uncompressed - // this fragment uncompressed - $len = min($charsLeft * 2, $limitpos - $pos); - $retstr .= substr($recordData, $pos, $len); - $charsLeft -= $len / 2; - $isCompressed = false; - - } elseif (!$isCompressed && ($option == 0)) { - // 1st fragment uncompressed - // this fragment compressed - $len = min($charsLeft, $limitpos - $pos); - for ($j = 0; $j < $len; ++$j) { - $retstr .= $recordData{$pos + $j} . chr(0); - } - $charsLeft -= $len; - $isCompressed = false; - - } else { - // 1st fragment compressed - // this fragment uncompressed - $newstr = ''; - for ($j = 0; $j < strlen($retstr); ++$j) { - $newstr .= $retstr[$j] . chr(0); - } - $retstr = $newstr; - $len = min($charsLeft * 2, $limitpos - $pos); - $retstr .= substr($recordData, $pos, $len); - $charsLeft -= $len / 2; - $isCompressed = false; - } - - $pos += $len; - } - } - - // convert to UTF-8 - $retstr = self::_encodeUTF16($retstr, $isCompressed); - - // read additional Rich-Text information, if any - $fmtRuns = array(); - if ($hasRichText) { - // list of formatting runs - for ($j = 0; $j < $formattingRuns; ++$j) { - // first formatted character; zero-based - $charPos = self::_GetInt2d($recordData, $pos + $j * 4); - - // index to font record - $fontIndex = self::_GetInt2d($recordData, $pos + 2 + $j * 4); - - $fmtRuns[] = array( - 'charPos' => $charPos, - 'fontIndex' => $fontIndex, - ); - } - $pos += 4 * $formattingRuns; - } - - // read additional Asian phonetics information, if any - if ($hasAsian) { - // For Asian phonetic settings, we skip the extended string data - $pos += $extendedRunLength; - } - - // store the shared sting - $this->_sst[] = array( - 'value' => $retstr, - 'fmtRuns' => $fmtRuns, - ); - } - - // _getSplicedRecordData() takes care of moving current position in data stream - } - - - /** - * Read PRINTGRIDLINES record - */ - private function _readPrintGridlines() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { - // offset: 0; size: 2; 0 = do not print sheet grid lines; 1 = print sheet gridlines - $printGridlines = (bool) self::_GetInt2d($recordData, 0); - $this->_phpSheet->setPrintGridlines($printGridlines); - } - } - - - /** - * Read DEFAULTROWHEIGHT record - */ - private function _readDefaultRowHeight() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; option flags - // offset: 2; size: 2; default height for unused rows, (twips 1/20 point) - $height = self::_GetInt2d($recordData, 2); - $this->_phpSheet->getDefaultRowDimension()->setRowHeight($height / 20); - } - - - /** - * Read SHEETPR record - */ - private function _readSheetPr() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2 - - // bit: 6; mask: 0x0040; 0 = outline buttons above outline group - $isSummaryBelow = (0x0040 & self::_GetInt2d($recordData, 0)) >> 6; - $this->_phpSheet->setShowSummaryBelow($isSummaryBelow); - - // bit: 7; mask: 0x0080; 0 = outline buttons left of outline group - $isSummaryRight = (0x0080 & self::_GetInt2d($recordData, 0)) >> 7; - $this->_phpSheet->setShowSummaryRight($isSummaryRight); - - // bit: 8; mask: 0x100; 0 = scale printout in percent, 1 = fit printout to number of pages - // this corresponds to radio button setting in page setup dialog in Excel - $this->_isFitToPages = (bool) ((0x0100 & self::_GetInt2d($recordData, 0)) >> 8); - } - - - /** - * Read HORIZONTALPAGEBREAKS record - */ - private function _readHorizontalPageBreaks() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { - - // offset: 0; size: 2; number of the following row index structures - $nm = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 6 * $nm; list of $nm row index structures - for ($i = 0; $i < $nm; ++$i) { - $r = self::_GetInt2d($recordData, 2 + 6 * $i); - $cf = self::_GetInt2d($recordData, 2 + 6 * $i + 2); - $cl = self::_GetInt2d($recordData, 2 + 6 * $i + 4); - - // not sure why two column indexes are necessary? - $this->_phpSheet->setBreakByColumnAndRow($cf, $r, PHPExcel_Worksheet::BREAK_ROW); - } - } - } - - - /** - * Read VERTICALPAGEBREAKS record - */ - private function _readVerticalPageBreaks() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { - // offset: 0; size: 2; number of the following column index structures - $nm = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 6 * $nm; list of $nm row index structures - for ($i = 0; $i < $nm; ++$i) { - $c = self::_GetInt2d($recordData, 2 + 6 * $i); - $rf = self::_GetInt2d($recordData, 2 + 6 * $i + 2); - $rl = self::_GetInt2d($recordData, 2 + 6 * $i + 4); - - // not sure why two row indexes are necessary? - $this->_phpSheet->setBreakByColumnAndRow($c, $rf, PHPExcel_Worksheet::BREAK_COLUMN); - } - } - } - - - /** - * Read HEADER record - */ - private function _readHeader() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: var - // realized that $recordData can be empty even when record exists - if ($recordData) { - if ($this->_version == self::XLS_BIFF8) { - $string = self::_readUnicodeStringLong($recordData); - } else { - $string = $this->_readByteStringShort($recordData); - } - - $this->_phpSheet->getHeaderFooter()->setOddHeader($string['value']); - $this->_phpSheet->getHeaderFooter()->setEvenHeader($string['value']); - } - } - } - - - /** - * Read FOOTER record - */ - private function _readFooter() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: var - // realized that $recordData can be empty even when record exists - if ($recordData) { - if ($this->_version == self::XLS_BIFF8) { - $string = self::_readUnicodeStringLong($recordData); - } else { - $string = $this->_readByteStringShort($recordData); - } - $this->_phpSheet->getHeaderFooter()->setOddFooter($string['value']); - $this->_phpSheet->getHeaderFooter()->setEvenFooter($string['value']); - } - } - } - - - /** - * Read HCENTER record - */ - private function _readHcenter() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally - $isHorizontalCentered = (bool) self::_GetInt2d($recordData, 0); - - $this->_phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered); - } - } - - - /** - * Read VCENTER record - */ - private function _readVcenter() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered - $isVerticalCentered = (bool) self::_GetInt2d($recordData, 0); - - $this->_phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered); - } - } - - - /** - * Read LEFTMARGIN record - */ - private function _readLeftMargin() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 8 - $this->_phpSheet->getPageMargins()->setLeft(self::_extractNumber($recordData)); - } - } - - - /** - * Read RIGHTMARGIN record - */ - private function _readRightMargin() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 8 - $this->_phpSheet->getPageMargins()->setRight(self::_extractNumber($recordData)); - } - } - - - /** - * Read TOPMARGIN record - */ - private function _readTopMargin() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 8 - $this->_phpSheet->getPageMargins()->setTop(self::_extractNumber($recordData)); - } - } - - - /** - * Read BOTTOMMARGIN record - */ - private function _readBottomMargin() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 8 - $this->_phpSheet->getPageMargins()->setBottom(self::_extractNumber($recordData)); - } - } - - - /** - * Read PAGESETUP record - */ - private function _readPageSetup() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; paper size - $paperSize = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; scaling factor - $scale = self::_GetInt2d($recordData, 2); - - // offset: 6; size: 2; fit worksheet width to this number of pages, 0 = use as many as needed - $fitToWidth = self::_GetInt2d($recordData, 6); - - // offset: 8; size: 2; fit worksheet height to this number of pages, 0 = use as many as needed - $fitToHeight = self::_GetInt2d($recordData, 8); - - // offset: 10; size: 2; option flags - - // bit: 1; mask: 0x0002; 0=landscape, 1=portrait - $isPortrait = (0x0002 & self::_GetInt2d($recordData, 10)) >> 1; - - // bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init - // when this bit is set, do not use flags for those properties - $isNotInit = (0x0004 & self::_GetInt2d($recordData, 10)) >> 2; - - if (!$isNotInit) { - $this->_phpSheet->getPageSetup()->setPaperSize($paperSize); - switch ($isPortrait) { - case 0: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); break; - case 1: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); break; - } - - $this->_phpSheet->getPageSetup()->setScale($scale, false); - $this->_phpSheet->getPageSetup()->setFitToPage((bool) $this->_isFitToPages); - $this->_phpSheet->getPageSetup()->setFitToWidth($fitToWidth, false); - $this->_phpSheet->getPageSetup()->setFitToHeight($fitToHeight, false); - } - - // offset: 16; size: 8; header margin (IEEE 754 floating-point value) - $marginHeader = self::_extractNumber(substr($recordData, 16, 8)); - $this->_phpSheet->getPageMargins()->setHeader($marginHeader); - - // offset: 24; size: 8; footer margin (IEEE 754 floating-point value) - $marginFooter = self::_extractNumber(substr($recordData, 24, 8)); - $this->_phpSheet->getPageMargins()->setFooter($marginFooter); - } - } - - - /** - * PROTECT - Sheet protection (BIFF2 through BIFF8) - * if this record is omitted, then it also means no sheet protection - */ - private function _readProtect() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly) { - return; - } - - // offset: 0; size: 2; - - // bit 0, mask 0x01; 1 = sheet is protected - $bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0; - $this->_phpSheet->getProtection()->setSheet((bool)$bool); - } - - - /** - * SCENPROTECT - */ - private function _readScenProtect() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly) { - return; - } - - // offset: 0; size: 2; - - // bit: 0, mask 0x01; 1 = scenarios are protected - $bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0; - - $this->_phpSheet->getProtection()->setScenarios((bool)$bool); - } - - - /** - * OBJECTPROTECT - */ - private function _readObjectProtect() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly) { - return; - } - - // offset: 0; size: 2; - - // bit: 0, mask 0x01; 1 = objects are protected - $bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0; - - $this->_phpSheet->getProtection()->setObjects((bool)$bool); - } - - - /** - * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8) - */ - private function _readPassword() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; 16-bit hash value of password - $password = strtoupper(dechex(self::_GetInt2d($recordData, 0))); // the hashed password - $this->_phpSheet->getProtection()->setPassword($password, true); - } - } - - - /** - * Read DEFCOLWIDTH record - */ - private function _readDefColWidth() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; default column width - $width = self::_GetInt2d($recordData, 0); - if ($width != 8) { - $this->_phpSheet->getDefaultColumnDimension()->setWidth($width); - } - } - - - /** - * Read COLINFO record - */ - private function _readColInfo() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; index to first column in range - $fc = self::_GetInt2d($recordData, 0); // first column index - - // offset: 2; size: 2; index to last column in range - $lc = self::_GetInt2d($recordData, 2); // first column index - - // offset: 4; size: 2; width of the column in 1/256 of the width of the zero character - $width = self::_GetInt2d($recordData, 4); - - // offset: 6; size: 2; index to XF record for default column formatting - $xfIndex = self::_GetInt2d($recordData, 6); - - // offset: 8; size: 2; option flags - - // bit: 0; mask: 0x0001; 1= columns are hidden - $isHidden = (0x0001 & self::_GetInt2d($recordData, 8)) >> 0; - - // bit: 10-8; mask: 0x0700; outline level of the columns (0 = no outline) - $level = (0x0700 & self::_GetInt2d($recordData, 8)) >> 8; - - // bit: 12; mask: 0x1000; 1 = collapsed - $isCollapsed = (0x1000 & self::_GetInt2d($recordData, 8)) >> 12; - - // offset: 10; size: 2; not used - - for ($i = $fc; $i <= $lc; ++$i) { - if ($lc == 255 || $lc == 256) { - $this->_phpSheet->getDefaultColumnDimension()->setWidth($width / 256); - break; - } - $this->_phpSheet->getColumnDimensionByColumn($i)->setWidth($width / 256); - $this->_phpSheet->getColumnDimensionByColumn($i)->setVisible(!$isHidden); - $this->_phpSheet->getColumnDimensionByColumn($i)->setOutlineLevel($level); - $this->_phpSheet->getColumnDimensionByColumn($i)->setCollapsed($isCollapsed); - $this->_phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - } - } - - - /** - * ROW - * - * This record contains the properties of a single row in a - * sheet. Rows and cells in a sheet are divided into blocks - * of 32 rows. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readRow() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; index of this row - $r = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; index to column of the first cell which is described by a cell record - - // offset: 4; size: 2; index to column of the last cell which is described by a cell record, increased by 1 - - // 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: 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); - } - - // offset: 8; size: 2; not used - - // offset: 10; size: 2; not used in BIFF5-BIFF8 - - // 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: 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: 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; - - if ($hasExplicitFormat) { - $this->_phpSheet->getRowDimension($r + 1)->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - } - } - - - /** - * Read RK record - * This record represents a cell that contains an RK value - * (encoded integer or floating-point value). If a - * floating-point value cannot be encoded to an RK value, - * a NUMBER record will be written. This record replaces the - * record INTEGER written in BIFF2. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readRk() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; index to row - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; index to column - $column = self::_GetInt2d($recordData, 2); - $columnString = PHPExcel_Cell::stringFromColumnIndex($column); - - // Read cell? - 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); - - // offset: 6; size: 4; RK value - $rknum = self::_GetInt4d($recordData, 6); - $numValue = self::_GetIEEE754($rknum); - - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - if (!$this->_readDataOnly) { - // add style information - $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - - // add cell - $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC); - } - } - - - /** - * Read LABELSST record - * This record represents a cell that contains a string. It - * replaces the LABEL record and RSTRING record used in - * BIFF2-BIFF5. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readLabelSst() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; index to row - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; index to column - $column = self::_GetInt2d($recordData, 2); - $columnString = PHPExcel_Cell::stringFromColumnIndex($column); - - // Read cell? - 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); - - // offset: 6; size: 4; index to SST record - $index = self::_GetInt4d($recordData, 6); - - // add cell - if (($fmtRuns = $this->_sst[$index]['fmtRuns']) && !$this->_readDataOnly) { - // then we should treat as rich text - $richText = new PHPExcel_RichText(); - $charPos = 0; - $sstCount = count($this->_sst[$index]['fmtRuns']); - for ($i = 0; $i <= $sstCount; ++$i) { - if (isset($fmtRuns[$i])) { - $text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos); - $charPos = $fmtRuns[$i]['charPos']; - } else { - $text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, PHPExcel_Shared_String::CountCharacters($this->_sst[$index]['value'])); - } - - if (PHPExcel_Shared_String::CountCharacters($text) > 0) { - if ($i == 0) { // first text run, no style - $richText->createText($text); - } else { - $textRun = $richText->createTextRun($text); - if (isset($fmtRuns[$i - 1])) { - if ($fmtRuns[$i - 1]['fontIndex'] < 4) { - $fontIndex = $fmtRuns[$i - 1]['fontIndex']; - } else { - // this has to do with that index 4 is omitted in all BIFF versions for some strange reason - // check the OpenOffice documentation of the FONT record - $fontIndex = $fmtRuns[$i - 1]['fontIndex'] - 1; - } - $textRun->setFont(clone $this->_objFonts[$fontIndex]); - } - } - } - } - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - $cell->setValueExplicit($richText, PHPExcel_Cell_DataType::TYPE_STRING); - } else { - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - $cell->setValueExplicit($this->_sst[$index]['value'], PHPExcel_Cell_DataType::TYPE_STRING); - } - - if (!$this->_readDataOnly) { - // add style information - $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - } - } - - - /** - * Read MULRK record - * This record represents a cell range containing RK value - * cells. All cells are located in the same row. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readMulRk() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; index to row - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; index to first column - $colFirst = self::_GetInt2d($recordData, 2); - - // offset: var; size: 2; index to last column - $colLast = self::_GetInt2d($recordData, $length - 2); - $columns = $colLast - $colFirst + 1; - - // offset within record data - $offset = 4; - - for ($i = 0; $i < $columns; ++$i) { - $columnString = PHPExcel_Cell::stringFromColumnIndex($colFirst + $i); - - // Read cell? - 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); - - // offset: var; size: 4; RK value - $numValue = self::_GetIEEE754(self::_GetInt4d($recordData, $offset + 2)); - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - if (!$this->_readDataOnly) { - // add style - $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - - // add cell value - $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC); - } - - $offset += 6; - } - } - - - /** - * Read NUMBER record - * This record represents a cell that contains a - * floating-point value. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readNumber() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; index to row - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size 2; index to column - $column = self::_GetInt2d($recordData, 2); - $columnString = PHPExcel_Cell::stringFromColumnIndex($column); - - // Read cell? - 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); - - $numValue = self::_extractNumber(substr($recordData, 6, 8)); - - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - if (!$this->_readDataOnly) { - // add cell style - $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - - // add cell value - $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC); - } - } - - - /** - * 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 - * formula cell. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readFormula() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; row index - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; col index - $column = self::_GetInt2d($recordData, 2); - $columnString = PHPExcel_Cell::stringFromColumnIndex($column); - - // offset: 20: size: variable; formula structure - $formulaStructure = substr($recordData, 20); - - // offset: 14: size: 2; option flags, recalculate always, recalculate on open etc. - $options = self::_GetInt2d($recordData, 14); - - // bit: 0; mask: 0x0001; 1 = recalculate always - // bit: 1; mask: 0x0002; 1 = calculate on open - // bit: 2; mask: 0x0008; 1 = part of a shared formula - $isPartOfSharedFormula = (bool) (0x0008 & $options); - - // WARNING: - // We can apparently not rely on $isPartOfSharedFormula. Even when $isPartOfSharedFormula = true - // the formula data may be ordinary formula data, therefore we need to check - // explicitly for the tExp token (0x01) - $isPartOfSharedFormula = $isPartOfSharedFormula && ord($formulaStructure{2}) == 0x01; - - if ($isPartOfSharedFormula) { - // part of shared formula which means there will be a formula with a tExp token and nothing else - // get the base cell, grab tExp token - $baseRow = self::_GetInt2d($formulaStructure, 3); - $baseCol = self::_GetInt2d($formulaStructure, 5); - $this->_baseCell = PHPExcel_Cell::stringFromColumnIndex($baseCol). ($baseRow + 1); - } - - // Read cell? - 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 - $this->_sharedFormulaParts[$columnString . ($row + 1)] = $this->_baseCell; - } - - // offset: 16: size: 4; not used - - // offset: 4; size: 2; XF index - $xfIndex = self::_GetInt2d($recordData, 4); - - // offset: 6; size: 8; result of the formula - if ( (ord($recordData{6}) == 0) - && (ord($recordData{12}) == 255) - && (ord($recordData{13}) == 255) ) { - - // String formula. Result follows in appended STRING record - $dataType = PHPExcel_Cell_DataType::TYPE_STRING; - - // read possible SHAREDFMLA record - $code = self::_GetInt2d($this->_data, $this->_pos); - if ($code == self::XLS_Type_SHAREDFMLA) { - $this->_readSharedFmla(); - } - - // read STRING record - $value = $this->_readString(); - - } elseif ((ord($recordData{6}) == 1) - && (ord($recordData{12}) == 255) - && (ord($recordData{13}) == 255)) { - - // Boolean formula. Result is in +2; 0=false, 1=true - $dataType = PHPExcel_Cell_DataType::TYPE_BOOL; - $value = (bool) ord($recordData{8}); - - } elseif ((ord($recordData{6}) == 2) - && (ord($recordData{12}) == 255) - && (ord($recordData{13}) == 255)) { - - // Error formula. Error code is in +2 - $dataType = PHPExcel_Cell_DataType::TYPE_ERROR; - $value = self::_mapErrorCode(ord($recordData{8})); - - } elseif ((ord($recordData{6}) == 3) - && (ord($recordData{12}) == 255) - && (ord($recordData{13}) == 255)) { - - // Formula result is a null string - $dataType = PHPExcel_Cell_DataType::TYPE_NULL; - $value = ''; - - } else { - - // forumla result is a number, first 14 bytes like _NUMBER record - $dataType = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $value = self::_extractNumber(substr($recordData, 6, 8)); - - } - - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - if (!$this->_readDataOnly) { - // add cell style - $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - - // store the formula - if (!$isPartOfSharedFormula) { - // not part of shared formula - // add cell value. If we can read formula, populate with formula, otherwise just used cached value - try { - if ($this->_version != self::XLS_BIFF8) { - throw new PHPExcel_Reader_Exception('Not BIFF8. Can only read BIFF8 formulas'); - } - $formula = $this->_getFormulaFromStructure($formulaStructure); // get formula in human language - $cell->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA); - - } catch (PHPExcel_Exception $e) { - $cell->setValueExplicit($value, $dataType); - } - } else { - if ($this->_version == self::XLS_BIFF8) { - // do nothing at this point, formula id added later in the code - } else { - $cell->setValueExplicit($value, $dataType); - } - } - - // store the cached calculated value - $cell->setCalculatedValue($value); - } - } - - - /** - * Read a SHAREDFMLA record. This function just stores the binary shared formula in the reader, - * which usually contains relative references. - * These will be used to construct the formula in each shared formula part after the sheet is read. - */ - private function _readSharedFmla() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0, size: 6; cell range address of the area used by the shared formula, not used for anything - $cellRange = substr($recordData, 0, 6); - $cellRange = $this->_readBIFF5CellRangeAddressFixed($cellRange); // note: even BIFF8 uses BIFF5 syntax - - // offset: 6, size: 1; not used - - // offset: 7, size: 1; number of existing FORMULA records for this shared formula - $no = ord($recordData{7}); - - // offset: 8, size: var; Binary token array of the shared formula - $formula = substr($recordData, 8); - - // at this point we only store the shared formula for later use - $this->_sharedFormulas[$this->_baseCell] = $formula; - - } - - - /** - * 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 - * it occurs directly after the FORMULA record - * - * @return string The string contents as UTF-8 - */ - private function _readString() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_version == self::XLS_BIFF8) { - $string = self::_readUnicodeStringLong($recordData); - $value = $string['value']; - } else { - $string = $this->_readByteStringLong($recordData); - $value = $string['value']; - } - - return $value; - } - - - /** - * Read BOOLERR record - * This record represents a Boolean value or error value - * cell. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readBoolErr() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; row index - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; column index - $column = self::_GetInt2d($recordData, 2); - $columnString = PHPExcel_Cell::stringFromColumnIndex($column); - - // Read cell? - 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); - - // offset: 6; size: 1; the boolean value or error value - $boolErr = ord($recordData{6}); - - // offset: 7; size: 1; 0=boolean; 1=error - $isError = ord($recordData{7}); - - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - switch ($isError) { - case 0: // boolean - $value = (bool) $boolErr; - - // add cell value - $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_BOOL); - break; - - case 1: // error type - $value = self::_mapErrorCode($boolErr); - - // add cell value - $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_ERROR); - break; - } - - if (!$this->_readDataOnly) { - // add cell style - $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - } - } - - - /** - * Read MULBLANK record - * This record represents a cell range of empty cells. All - * cells are located in the same row - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readMulBlank() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; index to row - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; index to first column - $fc = self::_GetInt2d($recordData, 2); - - // offset: 4; size: 2 x nc; list of indexes to XF records - // add style information - if (!$this->_readDataOnly) { - for ($i = 0; $i < $length / 2 - 3; ++$i) { - $columnString = PHPExcel_Cell::stringFromColumnIndex($fc + $i); - - // Read cell? - 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]); - } - } - } - - // offset: 6; size 2; index to last column (not needed) - } - - - /** - * Read LABEL record - * This record represents a cell that contains a string. In - * BIFF8 it is usually replaced by the LABELSST record. - * Excel still uses this record, if it copies unformatted - * text cells to the clipboard. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readLabel() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; index to row - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; index to column - $column = self::_GetInt2d($recordData, 2); - $columnString = PHPExcel_Cell::stringFromColumnIndex($column); - - // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { - // offset: 4; size: 2; XF index - $xfIndex = self::_GetInt2d($recordData, 4); - - // add cell value - // todo: what if string is very long? continue record - if ($this->_version == self::XLS_BIFF8) { - $string = self::_readUnicodeStringLong(substr($recordData, 6)); - $value = $string['value']; - } else { - $string = $this->_readByteStringLong(substr($recordData, 6)); - $value = $string['value']; - } - $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); - $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); - - if (!$this->_readDataOnly) { - // add cell style - $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - } - } - - - /** - * Read BLANK record - */ - private function _readBlank() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; row index - $row = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; col index - $col = self::_GetInt2d($recordData, 2); - $columnString = PHPExcel_Cell::stringFromColumnIndex($col); - - // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { - // offset: 4; size: 2; XF index - $xfIndex = self::_GetInt2d($recordData, 4); - - // add style information - if (!$this->_readDataOnly) { - $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]); - } - } - - } - - - /** - * Read MSODRAWING record - */ - private function _readMsoDrawing() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - - // get spliced record data - $splicedRecordData = $this->_getSplicedRecordData(); - $recordData = $splicedRecordData['recordData']; - - $this->_drawingData .= $recordData; - } - - - /** - * Read OBJ record - */ - private function _readObj() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly || $this->_version != self::XLS_BIFF8) { - return; - } - - // recordData consists of an array of subrecords looking like this: - // ft: 2 bytes; ftCmo type (0x15) - // cb: 2 bytes; size in bytes of ftCmo data - // ot: 2 bytes; Object Type - // id: 2 bytes; Object id number - // grbit: 2 bytes; Option Flags - // data: var; subrecord data - - // for now, we are just interested in the second subrecord containing the object type - $ftCmoType = self::_GetInt2d($recordData, 0); - $cbCmoSize = self::_GetInt2d($recordData, 2); - $otObjType = self::_GetInt2d($recordData, 4); - $idObjID = self::_GetInt2d($recordData, 6); - $grbitOpts = self::_GetInt2d($recordData, 6); - - $this->_objs[] = array( - 'ftCmoType' => $ftCmoType, - 'cbCmoSize' => $cbCmoSize, - 'otObjType' => $otObjType, - 'idObjID' => $idObjID, - 'grbitOpts' => $grbitOpts - ); - $this->textObjRef = $idObjID; - -// echo '_readObj()
'; -// var_dump(end($this->_objs)); -// echo '
'; - } - - - /** - * Read WINDOW2 record - */ - private function _readWindow2() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; option flags - $options = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; index to first visible row - $firstVisibleRow = self::_GetInt2d($recordData, 2); - - // offset: 4; size: 2; index to first visible colum - $firstVisibleColumn = self::_GetInt2d($recordData, 4); - if ($this->_version === self::XLS_BIFF8) { - // offset: 8; size: 2; not used - // offset: 10; size: 2; cached magnification factor in page break preview (in percent); 0 = Default (60%) - // offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%) - // offset: 14; size: 4; not used - $zoomscaleInPageBreakPreview = self::_GetInt2d($recordData, 10); - if ($zoomscaleInPageBreakPreview === 0) $zoomscaleInPageBreakPreview = 60; - $zoomscaleInNormalView = self::_GetInt2d($recordData, 12); - if ($zoomscaleInNormalView === 0) $zoomscaleInNormalView = 100; - } - - // bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines - $showGridlines = (bool) ((0x0002 & $options) >> 1); - $this->_phpSheet->setShowGridlines($showGridlines); - - // bit: 2; mask: 0x0004; 0 = do not show headers, 1 = show headers - $showRowColHeaders = (bool) ((0x0004 & $options) >> 2); - $this->_phpSheet->setShowRowColHeaders($showRowColHeaders); - - // bit: 3; mask: 0x0008; 0 = panes are not frozen, 1 = panes are frozen - $this->_frozen = (bool) ((0x0008 & $options) >> 3); - - // bit: 6; mask: 0x0040; 0 = columns from left to right, 1 = columns from right to left - $this->_phpSheet->setRightToLeft((bool)((0x0040 & $options) >> 6)); - - // bit: 10; mask: 0x0400; 0 = sheet not active, 1 = sheet active - $isActive = (bool) ((0x0400 & $options) >> 10); - if ($isActive) { - $this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet)); - } - - // bit: 11; mask: 0x0800; 0 = normal view, 1 = page break view - $isPageBreakPreview = (bool) ((0x0800 & $options) >> 11); - - //FIXME: set $firstVisibleRow and $firstVisibleColumn - - if ($this->_phpSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT) { - //NOTE: this setting is inferior to page layout view(Excel2007-) - $view = $isPageBreakPreview? PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW : - PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL; - $this->_phpSheet->getSheetView()->setView($view); - if ($this->_version === self::XLS_BIFF8) { - $zoomScale = $isPageBreakPreview? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView; - $this->_phpSheet->getSheetView()->setZoomScale($zoomScale); - $this->_phpSheet->getSheetView()->setZoomScaleNormal($zoomscaleInNormalView); - } - } - } - - /** - * Read PLV Record(Created by Excel2007 or upper) - */ - private function _readPageLayoutView() { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - //var_dump(unpack("vrt/vgrbitFrt/V2reserved/vwScalePLV/vgrbit", $recordData)); - - // offset: 0; size: 2; rt - //->ignore - $rt = self::_GetInt2d($recordData, 0); - // offset: 2; size: 2; grbitfr - //->ignore - $grbitFrt = self::_GetInt2d($recordData, 2); - // offset: 4; size: 8; reserved - //->ignore - - // offset: 12; size 2; zoom scale - $wScalePLV = self::_GetInt2d($recordData, 12); - // offset: 14; size 2; grbit - $grbit = self::_GetInt2d($recordData, 14); - - // decomprise grbit - $fPageLayoutView = $grbit & 0x01; - $fRulerVisible = ($grbit >> 1) & 0x01; //no support - $fWhitespaceHidden = ($grbit >> 3) & 0x01; //no support - - if ($fPageLayoutView === 1) { - $this->_phpSheet->getSheetView()->setView(PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT); - $this->_phpSheet->getSheetView()->setZoomScale($wScalePLV); //set by Excel2007 only if SHEETVIEW_PAGE_LAYOUT - } - //otherwise, we cannot know whether SHEETVIEW_PAGE_LAYOUT or SHEETVIEW_PAGE_BREAK_PREVIEW. - } - - /** - * Read SCL record - */ - private function _readScl() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // offset: 0; size: 2; numerator of the view magnification - $numerator = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; numerator of the view magnification - $denumerator = self::_GetInt2d($recordData, 2); - - // set the zoom scale (in percent) - $this->_phpSheet->getSheetView()->setZoomScale($numerator * 100 / $denumerator); - } - - - /** - * Read PANE record - */ - private function _readPane() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; position of vertical split - $px = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; position of horizontal split - $py = self::_GetInt2d($recordData, 2); - - if ($this->_frozen) { - // frozen panes - $this->_phpSheet->freezePane(PHPExcel_Cell::stringFromColumnIndex($px) . ($py + 1)); - } else { - // unfrozen panes; split windows; not supported by PHPExcel core - } - } - } - - - /** - * Read SELECTION record. There is one such record for each pane in the sheet. - */ - private function _readSelection() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 1; pane identifier - $paneId = ord($recordData{0}); - - // offset: 1; size: 2; index to row of the active cell - $r = self::_GetInt2d($recordData, 1); - - // offset: 3; size: 2; index to column of the active cell - $c = self::_GetInt2d($recordData, 3); - - // offset: 5; size: 2; index into the following cell range list to the - // entry that contains the active cell - $index = self::_GetInt2d($recordData, 5); - - // offset: 7; size: var; cell range address list containing all selected cell ranges - $data = substr($recordData, 7); - $cellRangeAddressList = $this->_readBIFF5CellRangeAddressList($data); // note: also BIFF8 uses BIFF5 syntax - - $selectedCells = $cellRangeAddressList['cellRangeAddresses'][0]; - - // first row '1' + last row '16384' indicates that full column is selected (apparently also in BIFF8!) - if (preg_match('/^([A-Z]+1\:[A-Z]+)16384$/', $selectedCells)) { - $selectedCells = preg_replace('/^([A-Z]+1\:[A-Z]+)16384$/', '${1}1048576', $selectedCells); - } - - // first row '1' + last row '65536' indicates that full column is selected - if (preg_match('/^([A-Z]+1\:[A-Z]+)65536$/', $selectedCells)) { - $selectedCells = preg_replace('/^([A-Z]+1\:[A-Z]+)65536$/', '${1}1048576', $selectedCells); - } - - // first column 'A' + last column 'IV' indicates that full row is selected - if (preg_match('/^(A[0-9]+\:)IV([0-9]+)$/', $selectedCells)) { - $selectedCells = preg_replace('/^(A[0-9]+\:)IV([0-9]+)$/', '${1}XFD${2}', $selectedCells); - } - - $this->_phpSheet->setSelectedCells($selectedCells); - } - } - - - private function _includeCellRangeFiltered($cellRangeAddress) - { - $includeCellRange = true; - if ($this->getReadFilter() !== NULL) { - $includeCellRange = false; - $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($cellRangeAddress); - $rangeBoundaries[1][0]++; - for ($row = $rangeBoundaries[0][1]; $row <= $rangeBoundaries[1][1]; $row++) { - for ($column = $rangeBoundaries[0][0]; $column != $rangeBoundaries[1][0]; $column++) { - if ($this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle())) { - $includeCellRange = true; - break 2; - } - } - } - } - return $includeCellRange; - } - - - /** - * MERGEDCELLS - * - * This record contains the addresses of merged cell ranges - * in the current sheet. - * - * -- "OpenOffice.org's Documentation of the Microsoft - * Excel File Format" - */ - private function _readMergedCells() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { - $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData); - foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) { - if ((strpos($cellRangeAddress,':') !== FALSE) && - ($this->_includeCellRangeFiltered($cellRangeAddress))) { - $this->_phpSheet->mergeCells($cellRangeAddress); - } - } - } - } - - - /** - * Read HYPERLINK record - */ - private function _readHyperLink() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer forward to next record - $this->_pos += 4 + $length; - - if (!$this->_readDataOnly) { - // offset: 0; size: 8; cell range address of all cells containing this hyperlink - try { - $cellRange = $this->_readBIFF8CellRangeAddressFixed($recordData, 0, 8); - } catch (PHPExcel_Exception $e) { - return; - } - - // offset: 8, size: 16; GUID of StdLink - - // offset: 24, size: 4; unknown value - - // offset: 28, size: 4; option flags - - // bit: 0; mask: 0x00000001; 0 = no link or extant, 1 = file link or URL - $isFileLinkOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 0; - - // bit: 1; mask: 0x00000002; 0 = relative path, 1 = absolute path or URL - $isAbsPathOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 1; - - // bit: 2 (and 4); mask: 0x00000014; 0 = no description - $hasDesc = (0x00000014 & self::_GetInt2d($recordData, 28)) >> 2; - - // bit: 3; mask: 0x00000008; 0 = no text, 1 = has text - $hasText = (0x00000008 & self::_GetInt2d($recordData, 28)) >> 3; - - // bit: 7; mask: 0x00000080; 0 = no target frame, 1 = has target frame - $hasFrame = (0x00000080 & self::_GetInt2d($recordData, 28)) >> 7; - - // bit: 8; mask: 0x00000100; 0 = file link or URL, 1 = UNC path (inc. server name) - $isUNC = (0x00000100 & self::_GetInt2d($recordData, 28)) >> 8; - - // offset within record data - $offset = 32; - - if ($hasDesc) { - // offset: 32; size: var; character count of description text - $dl = self::_GetInt4d($recordData, 32); - // offset: 36; size: var; character array of description text, no Unicode string header, always 16-bit characters, zero terminated - $desc = self::_encodeUTF16(substr($recordData, 36, 2 * ($dl - 1)), false); - $offset += 4 + 2 * $dl; - } - if ($hasFrame) { - $fl = self::_GetInt4d($recordData, $offset); - $offset += 4 + 2 * $fl; - } - - // detect type of hyperlink (there are 4 types) - $hyperlinkType = null; - - if ($isUNC) { - $hyperlinkType = 'UNC'; - } else if (!$isFileLinkOrUrl) { - $hyperlinkType = 'workbook'; - } else if (ord($recordData{$offset}) == 0x03) { - $hyperlinkType = 'local'; - } else if (ord($recordData{$offset}) == 0xE0) { - $hyperlinkType = 'URL'; - } - - switch ($hyperlinkType) { - case 'URL': - // section 5.58.2: Hyperlink containing a URL - // e.g. http://example.org/index.php - - // offset: var; size: 16; GUID of URL Moniker - $offset += 16; - // offset: var; size: 4; size (in bytes) of character array of the URL including trailing zero word - $us = self::_GetInt4d($recordData, $offset); - $offset += 4; - // offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated - $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false); - $nullOffset = strpos($url, 0x00); - if ($nullOffset) - $url = substr($url,0, $nullOffset); - $url .= $hasText ? '#' : ''; - $offset += $us; - break; - - case 'local': - // section 5.58.3: Hyperlink to local file - // examples: - // mydoc.txt - // ../../somedoc.xls#Sheet!A1 - - // offset: var; size: 16; GUI of File Moniker - $offset += 16; - - // offset: var; size: 2; directory up-level count. - $upLevelCount = self::_GetInt2d($recordData, $offset); - $offset += 2; - - // offset: var; size: 4; character count of the shortened file path and name, including trailing zero word - $sl = self::_GetInt4d($recordData, $offset); - $offset += 4; - - // offset: var; size: sl; character array of the shortened file path and name in 8.3-DOS-format (compressed Unicode string) - $shortenedFilePath = substr($recordData, $offset, $sl); - $shortenedFilePath = self::_encodeUTF16($shortenedFilePath, true); - $shortenedFilePath = substr($shortenedFilePath, 0, -1); // remove trailing zero - - $offset += $sl; - - // offset: var; size: 24; unknown sequence - $offset += 24; - - // extended file path - // offset: var; size: 4; size of the following file link field including string lenth mark - $sz = self::_GetInt4d($recordData, $offset); - $offset += 4; - - // only present if $sz > 0 - if ($sz > 0) { - // offset: var; size: 4; size of the character array of the extended file path and name - $xl = self::_GetInt4d($recordData, $offset); - $offset += 4; - - // offset: var; size 2; unknown - $offset += 2; - - // offset: var; size $xl; character array of the extended file path and name. - $extendedFilePath = substr($recordData, $offset, $xl); - $extendedFilePath = self::_encodeUTF16($extendedFilePath, false); - $offset += $xl; - } - - // construct the path - $url = str_repeat('..\\', $upLevelCount); - $url .= ($sz > 0) ? - $extendedFilePath : $shortenedFilePath; // use extended path if available - $url .= $hasText ? '#' : ''; - - break; - - - case 'UNC': - // section 5.58.4: Hyperlink to a File with UNC (Universal Naming Convention) Path - // todo: implement - return; - - case 'workbook': - // section 5.58.5: Hyperlink to the Current Workbook - // e.g. Sheet2!B1:C2, stored in text mark field - $url = 'sheet://'; - break; - - default: - return; - - } - - if ($hasText) { - // offset: var; size: 4; character count of text mark including trailing zero word - $tl = self::_GetInt4d($recordData, $offset); - $offset += 4; - // offset: var; size: var; character array of the text mark without the # sign, no Unicode header, always 16-bit characters, zero-terminated - $text = self::_encodeUTF16(substr($recordData, $offset, 2 * ($tl - 1)), false); - $url .= $text; - } - - // apply the hyperlink to all the relevant cells - foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cellRange) as $coordinate) { - $this->_phpSheet->getCell($coordinate)->getHyperLink()->setUrl($url); - } - } - } - - - /** - * Read DATAVALIDATIONS record - */ - private function _readDataValidations() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer forward to next record - $this->_pos += 4 + $length; - } - - - /** - * Read DATAVALIDATION record - */ - private function _readDataValidation() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer forward to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly) { - return; - } - - // offset: 0; size: 4; Options - $options = self::_GetInt4d($recordData, 0); - - // bit: 0-3; mask: 0x0000000F; type - $type = (0x0000000F & $options) >> 0; - switch ($type) { - case 0x00: $type = PHPExcel_Cell_DataValidation::TYPE_NONE; break; - case 0x01: $type = PHPExcel_Cell_DataValidation::TYPE_WHOLE; break; - case 0x02: $type = PHPExcel_Cell_DataValidation::TYPE_DECIMAL; break; - case 0x03: $type = PHPExcel_Cell_DataValidation::TYPE_LIST; break; - case 0x04: $type = PHPExcel_Cell_DataValidation::TYPE_DATE; break; - case 0x05: $type = PHPExcel_Cell_DataValidation::TYPE_TIME; break; - case 0x06: $type = PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH; break; - case 0x07: $type = PHPExcel_Cell_DataValidation::TYPE_CUSTOM; break; - } - - // bit: 4-6; mask: 0x00000070; error type - $errorStyle = (0x00000070 & $options) >> 4; - switch ($errorStyle) { - case 0x00: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; break; - case 0x01: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_WARNING; break; - case 0x02: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_INFORMATION; break; - } - - // bit: 7; mask: 0x00000080; 1= formula is explicit (only applies to list) - // I have only seen cases where this is 1 - $explicitFormula = (0x00000080 & $options) >> 7; - - // bit: 8; mask: 0x00000100; 1= empty cells allowed - $allowBlank = (0x00000100 & $options) >> 8; - - // bit: 9; mask: 0x00000200; 1= suppress drop down arrow in list type validity - $suppressDropDown = (0x00000200 & $options) >> 9; - - // bit: 18; mask: 0x00040000; 1= show prompt box if cell selected - $showInputMessage = (0x00040000 & $options) >> 18; - - // bit: 19; mask: 0x00080000; 1= show error box if invalid values entered - $showErrorMessage = (0x00080000 & $options) >> 19; - - // bit: 20-23; mask: 0x00F00000; condition operator - $operator = (0x00F00000 & $options) >> 20; - switch ($operator) { - case 0x00: $operator = PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN ; break; - case 0x01: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN ; break; - case 0x02: $operator = PHPExcel_Cell_DataValidation::OPERATOR_EQUAL ; break; - case 0x03: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL ; break; - case 0x04: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN ; break; - case 0x05: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN ; break; - case 0x06: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL; break; - case 0x07: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL ; break; - } - - // offset: 4; size: var; title of the prompt box - $offset = 4; - $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $promptTitle = $string['value'] !== chr(0) ? - $string['value'] : ''; - $offset += $string['size']; - - // offset: var; size: var; title of the error box - $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $errorTitle = $string['value'] !== chr(0) ? - $string['value'] : ''; - $offset += $string['size']; - - // offset: var; size: var; text of the prompt box - $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $prompt = $string['value'] !== chr(0) ? - $string['value'] : ''; - $offset += $string['size']; - - // offset: var; size: var; text of the error box - $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $error = $string['value'] !== chr(0) ? - $string['value'] : ''; - $offset += $string['size']; - - // offset: var; size: 2; size of the formula data for the first condition - $sz1 = self::_GetInt2d($recordData, $offset); - $offset += 2; - - // offset: var; size: 2; not used - $offset += 2; - - // offset: var; size: $sz1; formula data for first condition (without size field) - $formula1 = substr($recordData, $offset, $sz1); - $formula1 = pack('v', $sz1) . $formula1; // prepend the length - try { - $formula1 = $this->_getFormulaFromStructure($formula1); - - // in list type validity, null characters are used as item separators - if ($type == PHPExcel_Cell_DataValidation::TYPE_LIST) { - $formula1 = str_replace(chr(0), ',', $formula1); - } - } catch (PHPExcel_Exception $e) { - return; - } - $offset += $sz1; - - // offset: var; size: 2; size of the formula data for the first condition - $sz2 = self::_GetInt2d($recordData, $offset); - $offset += 2; - - // offset: var; size: 2; not used - $offset += 2; - - // offset: var; size: $sz2; formula data for second condition (without size field) - $formula2 = substr($recordData, $offset, $sz2); - $formula2 = pack('v', $sz2) . $formula2; // prepend the length - try { - $formula2 = $this->_getFormulaFromStructure($formula2); - } catch (PHPExcel_Exception $e) { - return; - } - $offset += $sz2; - - // offset: var; size: var; cell range address list with - $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList(substr($recordData, $offset)); - $cellRangeAddresses = $cellRangeAddressList['cellRangeAddresses']; - - foreach ($cellRangeAddresses as $cellRange) { - $stRange = $this->_phpSheet->shrinkRangeToFit($cellRange); - $stRange = PHPExcel_Cell::extractAllCellReferencesInRange($stRange); - foreach ($stRange as $coordinate) { - $objValidation = $this->_phpSheet->getCell($coordinate)->getDataValidation(); - $objValidation->setType($type); - $objValidation->setErrorStyle($errorStyle); - $objValidation->setAllowBlank((bool)$allowBlank); - $objValidation->setShowInputMessage((bool)$showInputMessage); - $objValidation->setShowErrorMessage((bool)$showErrorMessage); - $objValidation->setShowDropDown(!$suppressDropDown); - $objValidation->setOperator($operator); - $objValidation->setErrorTitle($errorTitle); - $objValidation->setError($error); - $objValidation->setPromptTitle($promptTitle); - $objValidation->setPrompt($prompt); - $objValidation->setFormula1($formula1); - $objValidation->setFormula2($formula2); - } - } - - } - - - /** - * Read SHEETLAYOUT record. Stores sheet tab color information. - */ - private function _readSheetLayout() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // local pointer in record data - $offset = 0; - - if (!$this->_readDataOnly) { - // offset: 0; size: 2; repeated record identifier 0x0862 - - // offset: 2; size: 10; not used - - // offset: 12; size: 4; size of record data - // Excel 2003 uses size of 0x14 (documented), Excel 2007 uses size of 0x28 (not documented?) - $sz = self::_GetInt4d($recordData, 12); - - switch ($sz) { - case 0x14: - // offset: 16; size: 2; color index for sheet tab - $colorIndex = self::_GetInt2d($recordData, 16); - $color = self::_readColor($colorIndex, $this->_palette, $this->_version); - $this->_phpSheet->getTabColor()->setRGB($color['rgb']); - break; - - case 0x28: - // TODO: Investigate structure for .xls SHEETLAYOUT record as saved by MS Office Excel 2007 - return; - break; - } - } - } - - - /** - * Read SHEETPROTECTION record (FEATHEADR) - */ - private function _readSheetProtection() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - if ($this->_readDataOnly) { - return; - } - - // offset: 0; size: 2; repeated record header - - // offset: 2; size: 2; FRT cell reference flag (=0 currently) - - // offset: 4; size: 8; Currently not used and set to 0 - - // offset: 12; size: 2; Shared feature type index (2=Enhanced Protetion, 4=SmartTag) - $isf = self::_GetInt2d($recordData, 12); - if ($isf != 2) { - return; - } - - // offset: 14; size: 1; =1 since this is a feat header - - // offset: 15; size: 4; size of rgbHdrSData - - // rgbHdrSData, assume "Enhanced Protection" - // offset: 19; size: 2; option flags - $options = self::_GetInt2d($recordData, 19); - - // bit: 0; mask 0x0001; 1 = user may edit objects, 0 = users must not edit objects - $bool = (0x0001 & $options) >> 0; - $this->_phpSheet->getProtection()->setObjects(!$bool); - - // bit: 1; mask 0x0002; edit scenarios - $bool = (0x0002 & $options) >> 1; - $this->_phpSheet->getProtection()->setScenarios(!$bool); - - // bit: 2; mask 0x0004; format cells - $bool = (0x0004 & $options) >> 2; - $this->_phpSheet->getProtection()->setFormatCells(!$bool); - - // bit: 3; mask 0x0008; format columns - $bool = (0x0008 & $options) >> 3; - $this->_phpSheet->getProtection()->setFormatColumns(!$bool); - - // bit: 4; mask 0x0010; format rows - $bool = (0x0010 & $options) >> 4; - $this->_phpSheet->getProtection()->setFormatRows(!$bool); - - // bit: 5; mask 0x0020; insert columns - $bool = (0x0020 & $options) >> 5; - $this->_phpSheet->getProtection()->setInsertColumns(!$bool); - - // bit: 6; mask 0x0040; insert rows - $bool = (0x0040 & $options) >> 6; - $this->_phpSheet->getProtection()->setInsertRows(!$bool); - - // bit: 7; mask 0x0080; insert hyperlinks - $bool = (0x0080 & $options) >> 7; - $this->_phpSheet->getProtection()->setInsertHyperlinks(!$bool); - - // bit: 8; mask 0x0100; delete columns - $bool = (0x0100 & $options) >> 8; - $this->_phpSheet->getProtection()->setDeleteColumns(!$bool); - - // bit: 9; mask 0x0200; delete rows - $bool = (0x0200 & $options) >> 9; - $this->_phpSheet->getProtection()->setDeleteRows(!$bool); - - // bit: 10; mask 0x0400; select locked cells - $bool = (0x0400 & $options) >> 10; - $this->_phpSheet->getProtection()->setSelectLockedCells(!$bool); - - // bit: 11; mask 0x0800; sort cell range - $bool = (0x0800 & $options) >> 11; - $this->_phpSheet->getProtection()->setSort(!$bool); - - // bit: 12; mask 0x1000; auto filter - $bool = (0x1000 & $options) >> 12; - $this->_phpSheet->getProtection()->setAutoFilter(!$bool); - - // bit: 13; mask 0x2000; pivot tables - $bool = (0x2000 & $options) >> 13; - $this->_phpSheet->getProtection()->setPivotTables(!$bool); - - // bit: 14; mask 0x4000; select unlocked cells - $bool = (0x4000 & $options) >> 14; - $this->_phpSheet->getProtection()->setSelectUnlockedCells(!$bool); - - // 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, - * where it is referred to as FEAT record - */ - private function _readRangeProtection() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // move stream pointer to next record - $this->_pos += 4 + $length; - - // local pointer in record data - $offset = 0; - - if (!$this->_readDataOnly) { - $offset += 12; - - // offset: 12; size: 2; shared feature type, 2 = enhanced protection, 4 = smart tag - $isf = self::_GetInt2d($recordData, 12); - if ($isf != 2) { - // we only read FEAT records of type 2 - return; - } - $offset += 2; - - $offset += 5; - - // offset: 19; size: 2; count of ref ranges this feature is on - $cref = self::_GetInt2d($recordData, 19); - $offset += 2; - - $offset += 6; - - // offset: 27; size: 8 * $cref; list of cell ranges (like in hyperlink record) - $cellRanges = array(); - for ($i = 0; $i < $cref; ++$i) { - try { - $cellRange = $this->_readBIFF8CellRangeAddressFixed(substr($recordData, 27 + 8 * $i, 8)); - } catch (PHPExcel_Exception $e) { - return; - } - $cellRanges[] = $cellRange; - $offset += 8; - } - - // offset: var; size: var; variable length of feature specific data - $rgbFeat = substr($recordData, $offset); - $offset += 4; - - // offset: var; size: 4; the encrypted password (only 16-bit although field is 32-bit) - $wPassword = self::_GetInt4d($recordData, $offset); - $offset += 4; - - // Apply range protection to sheet - if ($cellRanges) { - $this->_phpSheet->protectCells(implode(' ', $cellRanges), strtoupper(dechex($wPassword)), true); - } - } - } - - - /** - * Read IMDATA record - */ - private function _readImData() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - - // get spliced record data - $splicedRecordData = $this->_getSplicedRecordData(); - $recordData = $splicedRecordData['recordData']; - - // UNDER CONSTRUCTION - - // offset: 0; size: 2; image format - $cf = self::_GetInt2d($recordData, 0); - - // offset: 2; size: 2; environment from which the file was written - $env = self::_GetInt2d($recordData, 2); - - // offset: 4; size: 4; length of the image data - $lcb = self::_GetInt4d($recordData, 4); - - // offset: 8; size: var; image data - $iData = substr($recordData, 8); - - switch ($cf) { - case 0x09: // Windows bitmap format - // BITMAPCOREINFO - // 1. BITMAPCOREHEADER - // offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure - $bcSize = self::_GetInt4d($iData, 0); -// var_dump($bcSize); - - // offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels - $bcWidth = self::_GetInt2d($iData, 4); -// var_dump($bcWidth); - - // offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels. - $bcHeight = self::_GetInt2d($iData, 6); -// var_dump($bcHeight); - $ih = imagecreatetruecolor($bcWidth, $bcHeight); - - // offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1 - - // offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24 - $bcBitCount = self::_GetInt2d($iData, 10); -// var_dump($bcBitCount); - - $rgbString = substr($iData, 12); - $rgbTriples = array(); - while (strlen($rgbString) > 0) { - $rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString); - $rgbString = substr($rgbString, 3); - } - $x = 0; - $y = 0; - foreach ($rgbTriples as $i => $rgbTriple) { - $color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']); - imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color); - $x = ($x + 1) % $bcWidth; - $y = $y + floor(($x + 1) / $bcWidth); - } - //imagepng($ih, 'image.png'); - - $drawing = new PHPExcel_Worksheet_Drawing(); - $drawing->setPath($filename); - $drawing->setWorksheet($this->_phpSheet); - - break; - - case 0x02: // Windows metafile or Macintosh PICT format - case 0x0e: // native format - default; - break; - - } - - // _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. - * In this case, we must treat the CONTINUE record as a MSODRAWING record - */ - private function _readContinue() - { - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - // check if we are reading drawing data - // this is in case a free CONTINUE record occurs in other circumstances we are unaware of - if ($this->_drawingData == '') { - // move stream pointer to next record - $this->_pos += 4 + $length; - - return; - } - - // check if record data is at least 4 bytes long, otherwise there is no chance this is MSODRAWING data - if ($length < 4) { - // move stream pointer to next record - $this->_pos += 4 + $length; - - return; - } - - // dirty check to see if CONTINUE record could be a camouflaged MSODRAWING record - // look inside CONTINUE record to see if it looks like a part of an Escher stream - // we know that Escher stream may be split at least at - // 0xF003 MsofbtSpgrContainer - // 0xF004 MsofbtSpContainer - // 0xF00D MsofbtClientTextbox - $validSplitPoints = array(0xF003, 0xF004, 0xF00D); // add identifiers if we find more - - $splitPoint = self::_GetInt2d($recordData, 2); - if (in_array($splitPoint, $validSplitPoints)) { - // get spliced record data (and move pointer to next record) - $splicedRecordData = $this->_getSplicedRecordData(); - $this->_drawingData .= $splicedRecordData['recordData']; - - return; - } - - // move stream pointer to next record - $this->_pos += 4 + $length; - - } - - - /** - * Reads a record from current position in data stream and continues reading data as long as CONTINUE - * records are found. Splices the record data pieces and returns the combined string as if record data - * is in one piece. - * Moves to next current position in data stream to start of next record different from a CONtINUE record - * - * @return array - */ - private function _getSplicedRecordData() - { - $data = ''; - $spliceOffsets = array(); - - $i = 0; - $spliceOffsets[0] = 0; - - do { - ++$i; - - // offset: 0; size: 2; identifier - $identifier = self::_GetInt2d($this->_data, $this->_pos); - // offset: 2; size: 2; length - $length = self::_GetInt2d($this->_data, $this->_pos + 2); - $data .= $this->_readRecordData($this->_data, $this->_pos + 4, $length); - - $spliceOffsets[$i] = $spliceOffsets[$i - 1] + $length; - - $this->_pos += 4 + $length; - $nextIdentifier = self::_GetInt2d($this->_data, $this->_pos); - } - while ($nextIdentifier == self::XLS_Type_CONTINUE); - - $splicedData = array( - 'recordData' => $data, - 'spliceOffsets' => $spliceOffsets, - ); - - return $splicedData; - - } - - - /** - * Convert formula structure into human readable Excel formula like 'A3+A5*5' - * - * @param string $formulaStructure The complete binary data for the formula - * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas - * @return string Human readable formula - */ - private function _getFormulaFromStructure($formulaStructure, $baseCell = 'A1') - { - // offset: 0; size: 2; size of the following formula data - $sz = self::_GetInt2d($formulaStructure, 0); - - // offset: 2; size: sz - $formulaData = substr($formulaStructure, 2, $sz); - - // for debug: dump the formula data - //echo ''; - //echo 'size: ' . $sz . "\n"; - //echo 'the entire formula data: '; - //Debug::dump($formulaData); - //echo "\n----\n"; - - // offset: 2 + sz; size: variable (optional) - if (strlen($formulaStructure) > 2 + $sz) { - $additionalData = substr($formulaStructure, 2 + $sz); - - // for debug: dump the additional data - //echo 'the entire additional data: '; - //Debug::dump($additionalData); - //echo "\n----\n"; - - } else { - $additionalData = ''; - } - - return $this->_getFormulaFromData($formulaData, $additionalData, $baseCell); - } - - - /** - * Take formula data and additional data for formula and return human readable formula - * - * @param string $formulaData The binary data for the formula itself - * @param string $additionalData Additional binary data going with the formula - * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas - * @return string Human readable formula - */ - private function _getFormulaFromData($formulaData, $additionalData = '', $baseCell = 'A1') - { - // start parsing the formula data - $tokens = array(); - - while (strlen($formulaData) > 0 and $token = $this->_getNextToken($formulaData, $baseCell)) { - $tokens[] = $token; - $formulaData = substr($formulaData, $token['size']); - - // for debug: dump the token - //var_dump($token); - } - - $formulaString = $this->_createFormulaFromTokens($tokens, $additionalData); - - return $formulaString; - } - - - /** - * Take array of tokens together with additional data for formula and return human readable formula - * - * @param array $tokens - * @param array $additionalData Additional binary data going with the formula - * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas - * @return string Human readable formula - */ - private function _createFormulaFromTokens($tokens, $additionalData) - { - // empty formula? - if (empty($tokens)) { - return ''; - } - - $formulaStrings = array(); - foreach ($tokens as $token) { - // initialize spaces - $space0 = isset($space0) ? $space0 : ''; // spaces before next token, not tParen - $space1 = isset($space1) ? $space1 : ''; // carriage returns before next token, not tParen - $space2 = isset($space2) ? $space2 : ''; // spaces before opening parenthesis - $space3 = isset($space3) ? $space3 : ''; // carriage returns before opening parenthesis - $space4 = isset($space4) ? $space4 : ''; // spaces before closing parenthesis - $space5 = isset($space5) ? $space5 : ''; // carriage returns before closing parenthesis - - switch ($token['name']) { - case 'tAdd': // addition - case 'tConcat': // addition - case 'tDiv': // division - case 'tEQ': // equality - case 'tGE': // greater than or equal - case 'tGT': // greater than - case 'tIsect': // intersection - case 'tLE': // less than or equal - case 'tList': // less than or equal - case 'tLT': // less than - case 'tMul': // multiplication - case 'tNE': // multiplication - case 'tPower': // power - case 'tRange': // range - case 'tSub': // subtraction - $op2 = array_pop($formulaStrings); - $op1 = array_pop($formulaStrings); - $formulaStrings[] = "$op1$space1$space0{$token['data']}$op2"; - unset($space0, $space1); - break; - case 'tUplus': // unary plus - case 'tUminus': // unary minus - $op = array_pop($formulaStrings); - $formulaStrings[] = "$space1$space0{$token['data']}$op"; - unset($space0, $space1); - break; - case 'tPercent': // percent sign - $op = array_pop($formulaStrings); - $formulaStrings[] = "$op$space1$space0{$token['data']}"; - unset($space0, $space1); - break; - case 'tAttrVolatile': // indicates volatile function - case 'tAttrIf': - case 'tAttrSkip': - case 'tAttrChoose': - // token is only important for Excel formula evaluator - // do nothing - break; - case 'tAttrSpace': // space / carriage return - // space will be used when next token arrives, do not alter formulaString stack - switch ($token['data']['spacetype']) { - case 'type0': - $space0 = str_repeat(' ', $token['data']['spacecount']); - break; - case 'type1': - $space1 = str_repeat("\n", $token['data']['spacecount']); - break; - case 'type2': - $space2 = str_repeat(' ', $token['data']['spacecount']); - break; - case 'type3': - $space3 = str_repeat("\n", $token['data']['spacecount']); - break; - case 'type4': - $space4 = str_repeat(' ', $token['data']['spacecount']); - break; - case 'type5': - $space5 = str_repeat("\n", $token['data']['spacecount']); - break; - } - break; - case 'tAttrSum': // SUM function with one parameter - $op = array_pop($formulaStrings); - $formulaStrings[] = "{$space1}{$space0}SUM($op)"; - unset($space0, $space1); - break; - case 'tFunc': // function with fixed number of arguments - case 'tFuncV': // function with variable number of arguments - if ($token['data']['function'] != '') { - // normal function - $ops = array(); // array of operators - for ($i = 0; $i < $token['data']['args']; ++$i) { - $ops[] = array_pop($formulaStrings); - } - $ops = array_reverse($ops); - $formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")"; - unset($space0, $space1); - } else { - // add-in function - $ops = array(); // array of operators - for ($i = 0; $i < $token['data']['args'] - 1; ++$i) { - $ops[] = array_pop($formulaStrings); - } - $ops = array_reverse($ops); - $function = array_pop($formulaStrings); - $formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")"; - unset($space0, $space1); - } - break; - case 'tParen': // parenthesis - $expression = array_pop($formulaStrings); - $formulaStrings[] = "$space3$space2($expression$space5$space4)"; - unset($space2, $space3, $space4, $space5); - break; - case 'tArray': // array constant - $constantArray = self::_readBIFF8ConstantArray($additionalData); - $formulaStrings[] = $space1 . $space0 . $constantArray['value']; - $additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data - unset($space0, $space1); - break; - case 'tMemArea': - // bite off chunk of additional data - $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($additionalData); - $additionalData = substr($additionalData, $cellRangeAddressList['size']); - $formulaStrings[] = "$space1$space0{$token['data']}"; - unset($space0, $space1); - break; - case 'tArea': // cell range address - case 'tBool': // boolean - case 'tErr': // error code - case 'tInt': // integer - case 'tMemErr': - case 'tMemFunc': - case 'tMissArg': - case 'tName': - case 'tNameX': - case 'tNum': // number - case 'tRef': // single cell reference - case 'tRef3d': // 3d cell reference - case 'tArea3d': // 3d cell range reference - case 'tRefN': - case 'tAreaN': - case 'tStr': // string - $formulaStrings[] = "$space1$space0{$token['data']}"; - unset($space0, $space1); - break; - } - } - $formulaString = $formulaStrings[0]; - - // for debug: dump the human readable formula - //echo '----' . "\n"; - //echo 'Formula: ' . $formulaString; - - return $formulaString; - } - - - /** - * Fetch next token from binary formula data - * - * @param string Formula data - * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas - * @return array - * @throws PHPExcel_Reader_Exception - */ - private function _getNextToken($formulaData, $baseCell = 'A1') - { - // offset: 0; size: 1; token id - $id = ord($formulaData[0]); // token id - $name = false; // initialize token name - - switch ($id) { - case 0x03: $name = 'tAdd'; $size = 1; $data = '+'; break; - case 0x04: $name = 'tSub'; $size = 1; $data = '-'; break; - case 0x05: $name = 'tMul'; $size = 1; $data = '*'; break; - case 0x06: $name = 'tDiv'; $size = 1; $data = '/'; break; - case 0x07: $name = 'tPower'; $size = 1; $data = '^'; break; - case 0x08: $name = 'tConcat'; $size = 1; $data = '&'; break; - case 0x09: $name = 'tLT'; $size = 1; $data = '<'; break; - case 0x0A: $name = 'tLE'; $size = 1; $data = '<='; break; - case 0x0B: $name = 'tEQ'; $size = 1; $data = '='; break; - case 0x0C: $name = 'tGE'; $size = 1; $data = '>='; break; - case 0x0D: $name = 'tGT'; $size = 1; $data = '>'; break; - case 0x0E: $name = 'tNE'; $size = 1; $data = '<>'; break; - case 0x0F: $name = 'tIsect'; $size = 1; $data = ' '; break; - case 0x10: $name = 'tList'; $size = 1; $data = ','; break; - case 0x11: $name = 'tRange'; $size = 1; $data = ':'; break; - case 0x12: $name = 'tUplus'; $size = 1; $data = '+'; break; - case 0x13: $name = 'tUminus'; $size = 1; $data = '-'; break; - case 0x14: $name = 'tPercent'; $size = 1; $data = '%'; break; - case 0x15: // parenthesis - $name = 'tParen'; - $size = 1; - $data = null; - break; - case 0x16: // missing argument - $name = 'tMissArg'; - $size = 1; - $data = ''; - break; - case 0x17: // string - $name = 'tStr'; - // offset: 1; size: var; Unicode string, 8-bit string length - $string = self::_readUnicodeStringShort(substr($formulaData, 1)); - $size = 1 + $string['size']; - $data = self::_UTF8toExcelDoubleQuoted($string['value']); - break; - case 0x19: // Special attribute - // offset: 1; size: 1; attribute type flags: - switch (ord($formulaData[1])) { - case 0x01: - $name = 'tAttrVolatile'; - $size = 4; - $data = null; - break; - case 0x02: - $name = 'tAttrIf'; - $size = 4; - $data = null; - break; - case 0x04: - $name = 'tAttrChoose'; - // offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1) - $nc = self::_GetInt2d($formulaData, 2); - // offset: 4; size: 2 * $nc - // offset: 4 + 2 * $nc; size: 2 - $size = 2 * $nc + 6; - $data = null; - break; - case 0x08: - $name = 'tAttrSkip'; - $size = 4; - $data = null; - break; - case 0x10: - $name = 'tAttrSum'; - $size = 4; - $data = null; - break; - case 0x40: - case 0x41: - $name = 'tAttrSpace'; - $size = 4; - // offset: 2; size: 2; space type and position - switch (ord($formulaData[2])) { - case 0x00: - $spacetype = 'type0'; - break; - case 0x01: - $spacetype = 'type1'; - break; - case 0x02: - $spacetype = 'type2'; - break; - case 0x03: - $spacetype = 'type3'; - break; - case 0x04: - $spacetype = 'type4'; - break; - case 0x05: - $spacetype = 'type5'; - break; - default: - throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token'); - break; - } - // offset: 3; size: 1; number of inserted spaces/carriage returns - $spacecount = ord($formulaData[3]); - - $data = array('spacetype' => $spacetype, 'spacecount' => $spacecount); - break; - default: - throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token'); - break; - } - break; - case 0x1C: // error code - // offset: 1; size: 1; error code - $name = 'tErr'; - $size = 2; - $data = self::_mapErrorCode(ord($formulaData[1])); - break; - case 0x1D: // boolean - // offset: 1; size: 1; 0 = false, 1 = true; - $name = 'tBool'; - $size = 2; - $data = ord($formulaData[1]) ? 'TRUE' : 'FALSE'; - break; - case 0x1E: // integer - // offset: 1; size: 2; unsigned 16-bit integer - $name = 'tInt'; - $size = 3; - $data = self::_GetInt2d($formulaData, 1); - break; - case 0x1F: // number - // offset: 1; size: 8; - $name = 'tNum'; - $size = 9; - $data = self::_extractNumber(substr($formulaData, 1)); - $data = str_replace(',', '.', (string)$data); // in case non-English locale - break; - case 0x20: // array constant - case 0x40: - case 0x60: - // offset: 1; size: 7; not used - $name = 'tArray'; - $size = 8; - $data = null; - break; - case 0x21: // function with fixed number of arguments - case 0x41: - case 0x61: - $name = 'tFunc'; - $size = 3; - // offset: 1; size: 2; index to built-in sheet function - switch (self::_GetInt2d($formulaData, 1)) { - case 2: $function = 'ISNA'; $args = 1; break; - case 3: $function = 'ISERROR'; $args = 1; break; - case 10: $function = 'NA'; $args = 0; break; - case 15: $function = 'SIN'; $args = 1; break; - case 16: $function = 'COS'; $args = 1; break; - case 17: $function = 'TAN'; $args = 1; break; - case 18: $function = 'ATAN'; $args = 1; break; - case 19: $function = 'PI'; $args = 0; break; - case 20: $function = 'SQRT'; $args = 1; break; - case 21: $function = 'EXP'; $args = 1; break; - case 22: $function = 'LN'; $args = 1; break; - case 23: $function = 'LOG10'; $args = 1; break; - case 24: $function = 'ABS'; $args = 1; break; - case 25: $function = 'INT'; $args = 1; break; - case 26: $function = 'SIGN'; $args = 1; break; - case 27: $function = 'ROUND'; $args = 2; break; - case 30: $function = 'REPT'; $args = 2; break; - case 31: $function = 'MID'; $args = 3; break; - case 32: $function = 'LEN'; $args = 1; break; - case 33: $function = 'VALUE'; $args = 1; break; - case 34: $function = 'TRUE'; $args = 0; break; - case 35: $function = 'FALSE'; $args = 0; break; - case 38: $function = 'NOT'; $args = 1; break; - case 39: $function = 'MOD'; $args = 2; break; - case 40: $function = 'DCOUNT'; $args = 3; break; - case 41: $function = 'DSUM'; $args = 3; break; - case 42: $function = 'DAVERAGE'; $args = 3; break; - case 43: $function = 'DMIN'; $args = 3; break; - case 44: $function = 'DMAX'; $args = 3; break; - case 45: $function = 'DSTDEV'; $args = 3; break; - case 48: $function = 'TEXT'; $args = 2; break; - case 61: $function = 'MIRR'; $args = 3; break; - case 63: $function = 'RAND'; $args = 0; break; - case 65: $function = 'DATE'; $args = 3; break; - case 66: $function = 'TIME'; $args = 3; break; - case 67: $function = 'DAY'; $args = 1; break; - case 68: $function = 'MONTH'; $args = 1; break; - case 69: $function = 'YEAR'; $args = 1; break; - case 71: $function = 'HOUR'; $args = 1; break; - case 72: $function = 'MINUTE'; $args = 1; break; - case 73: $function = 'SECOND'; $args = 1; break; - case 74: $function = 'NOW'; $args = 0; break; - case 75: $function = 'AREAS'; $args = 1; break; - case 76: $function = 'ROWS'; $args = 1; break; - case 77: $function = 'COLUMNS'; $args = 1; break; - case 83: $function = 'TRANSPOSE'; $args = 1; break; - case 86: $function = 'TYPE'; $args = 1; break; - case 97: $function = 'ATAN2'; $args = 2; break; - case 98: $function = 'ASIN'; $args = 1; break; - case 99: $function = 'ACOS'; $args = 1; break; - case 105: $function = 'ISREF'; $args = 1; break; - case 111: $function = 'CHAR'; $args = 1; break; - case 112: $function = 'LOWER'; $args = 1; break; - case 113: $function = 'UPPER'; $args = 1; break; - case 114: $function = 'PROPER'; $args = 1; break; - case 117: $function = 'EXACT'; $args = 2; break; - case 118: $function = 'TRIM'; $args = 1; break; - case 119: $function = 'REPLACE'; $args = 4; break; - case 121: $function = 'CODE'; $args = 1; break; - case 126: $function = 'ISERR'; $args = 1; break; - case 127: $function = 'ISTEXT'; $args = 1; break; - case 128: $function = 'ISNUMBER'; $args = 1; break; - case 129: $function = 'ISBLANK'; $args = 1; break; - case 130: $function = 'T'; $args = 1; break; - case 131: $function = 'N'; $args = 1; break; - case 140: $function = 'DATEVALUE'; $args = 1; break; - case 141: $function = 'TIMEVALUE'; $args = 1; break; - case 142: $function = 'SLN'; $args = 3; break; - case 143: $function = 'SYD'; $args = 4; break; - case 162: $function = 'CLEAN'; $args = 1; break; - case 163: $function = 'MDETERM'; $args = 1; break; - case 164: $function = 'MINVERSE'; $args = 1; break; - case 165: $function = 'MMULT'; $args = 2; break; - case 184: $function = 'FACT'; $args = 1; break; - case 189: $function = 'DPRODUCT'; $args = 3; break; - case 190: $function = 'ISNONTEXT'; $args = 1; break; - case 195: $function = 'DSTDEVP'; $args = 3; break; - case 196: $function = 'DVARP'; $args = 3; break; - case 198: $function = 'ISLOGICAL'; $args = 1; break; - case 199: $function = 'DCOUNTA'; $args = 3; break; - case 207: $function = 'REPLACEB'; $args = 4; break; - case 210: $function = 'MIDB'; $args = 3; break; - case 211: $function = 'LENB'; $args = 1; break; - case 212: $function = 'ROUNDUP'; $args = 2; break; - case 213: $function = 'ROUNDDOWN'; $args = 2; break; - case 214: $function = 'ASC'; $args = 1; break; - case 215: $function = 'DBCS'; $args = 1; break; - case 221: $function = 'TODAY'; $args = 0; break; - case 229: $function = 'SINH'; $args = 1; break; - case 230: $function = 'COSH'; $args = 1; break; - case 231: $function = 'TANH'; $args = 1; break; - case 232: $function = 'ASINH'; $args = 1; break; - case 233: $function = 'ACOSH'; $args = 1; break; - case 234: $function = 'ATANH'; $args = 1; break; - case 235: $function = 'DGET'; $args = 3; break; - case 244: $function = 'INFO'; $args = 1; break; - case 252: $function = 'FREQUENCY'; $args = 2; break; - case 261: $function = 'ERROR.TYPE'; $args = 1; break; - case 271: $function = 'GAMMALN'; $args = 1; break; - case 273: $function = 'BINOMDIST'; $args = 4; break; - case 274: $function = 'CHIDIST'; $args = 2; break; - case 275: $function = 'CHIINV'; $args = 2; break; - case 276: $function = 'COMBIN'; $args = 2; break; - case 277: $function = 'CONFIDENCE'; $args = 3; break; - case 278: $function = 'CRITBINOM'; $args = 3; break; - case 279: $function = 'EVEN'; $args = 1; break; - case 280: $function = 'EXPONDIST'; $args = 3; break; - case 281: $function = 'FDIST'; $args = 3; break; - case 282: $function = 'FINV'; $args = 3; break; - case 283: $function = 'FISHER'; $args = 1; break; - case 284: $function = 'FISHERINV'; $args = 1; break; - case 285: $function = 'FLOOR'; $args = 2; break; - case 286: $function = 'GAMMADIST'; $args = 4; break; - case 287: $function = 'GAMMAINV'; $args = 3; break; - case 288: $function = 'CEILING'; $args = 2; break; - case 289: $function = 'HYPGEOMDIST'; $args = 4; break; - case 290: $function = 'LOGNORMDIST'; $args = 3; break; - case 291: $function = 'LOGINV'; $args = 3; break; - case 292: $function = 'NEGBINOMDIST'; $args = 3; break; - case 293: $function = 'NORMDIST'; $args = 4; break; - case 294: $function = 'NORMSDIST'; $args = 1; break; - case 295: $function = 'NORMINV'; $args = 3; break; - case 296: $function = 'NORMSINV'; $args = 1; break; - case 297: $function = 'STANDARDIZE'; $args = 3; break; - case 298: $function = 'ODD'; $args = 1; break; - case 299: $function = 'PERMUT'; $args = 2; break; - case 300: $function = 'POISSON'; $args = 3; break; - case 301: $function = 'TDIST'; $args = 3; break; - case 302: $function = 'WEIBULL'; $args = 4; break; - case 303: $function = 'SUMXMY2'; $args = 2; break; - case 304: $function = 'SUMX2MY2'; $args = 2; break; - case 305: $function = 'SUMX2PY2'; $args = 2; break; - case 306: $function = 'CHITEST'; $args = 2; break; - case 307: $function = 'CORREL'; $args = 2; break; - case 308: $function = 'COVAR'; $args = 2; break; - case 309: $function = 'FORECAST'; $args = 3; break; - case 310: $function = 'FTEST'; $args = 2; break; - case 311: $function = 'INTERCEPT'; $args = 2; break; - case 312: $function = 'PEARSON'; $args = 2; break; - case 313: $function = 'RSQ'; $args = 2; break; - case 314: $function = 'STEYX'; $args = 2; break; - case 315: $function = 'SLOPE'; $args = 2; break; - case 316: $function = 'TTEST'; $args = 4; break; - case 325: $function = 'LARGE'; $args = 2; break; - case 326: $function = 'SMALL'; $args = 2; break; - case 327: $function = 'QUARTILE'; $args = 2; break; - case 328: $function = 'PERCENTILE'; $args = 2; break; - case 331: $function = 'TRIMMEAN'; $args = 2; break; - case 332: $function = 'TINV'; $args = 2; break; - case 337: $function = 'POWER'; $args = 2; break; - case 342: $function = 'RADIANS'; $args = 1; break; - case 343: $function = 'DEGREES'; $args = 1; break; - case 346: $function = 'COUNTIF'; $args = 2; break; - case 347: $function = 'COUNTBLANK'; $args = 1; break; - case 350: $function = 'ISPMT'; $args = 4; break; - case 351: $function = 'DATEDIF'; $args = 3; break; - case 352: $function = 'DATESTRING'; $args = 1; break; - case 353: $function = 'NUMBERSTRING'; $args = 2; break; - case 360: $function = 'PHONETIC'; $args = 1; break; - case 368: $function = 'BAHTTEXT'; $args = 1; break; - default: - throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); - break; - } - $data = array('function' => $function, 'args' => $args); - break; - case 0x22: // function with variable number of arguments - case 0x42: - case 0x62: - $name = 'tFuncV'; - $size = 4; - // offset: 1; size: 1; number of arguments - $args = ord($formulaData[1]); - // offset: 2: size: 2; index to built-in sheet function - $index = self::_GetInt2d($formulaData, 2); - switch ($index) { - case 0: $function = 'COUNT'; break; - case 1: $function = 'IF'; break; - case 4: $function = 'SUM'; break; - case 5: $function = 'AVERAGE'; break; - case 6: $function = 'MIN'; break; - case 7: $function = 'MAX'; break; - case 8: $function = 'ROW'; break; - case 9: $function = 'COLUMN'; break; - case 11: $function = 'NPV'; break; - case 12: $function = 'STDEV'; break; - case 13: $function = 'DOLLAR'; break; - case 14: $function = 'FIXED'; break; - case 28: $function = 'LOOKUP'; break; - case 29: $function = 'INDEX'; break; - case 36: $function = 'AND'; break; - case 37: $function = 'OR'; break; - case 46: $function = 'VAR'; break; - case 49: $function = 'LINEST'; break; - case 50: $function = 'TREND'; break; - case 51: $function = 'LOGEST'; break; - case 52: $function = 'GROWTH'; break; - case 56: $function = 'PV'; break; - case 57: $function = 'FV'; break; - case 58: $function = 'NPER'; break; - case 59: $function = 'PMT'; break; - case 60: $function = 'RATE'; break; - case 62: $function = 'IRR'; break; - case 64: $function = 'MATCH'; break; - case 70: $function = 'WEEKDAY'; break; - case 78: $function = 'OFFSET'; break; - case 82: $function = 'SEARCH'; break; - case 100: $function = 'CHOOSE'; break; - case 101: $function = 'HLOOKUP'; break; - case 102: $function = 'VLOOKUP'; break; - case 109: $function = 'LOG'; break; - case 115: $function = 'LEFT'; break; - case 116: $function = 'RIGHT'; break; - case 120: $function = 'SUBSTITUTE'; break; - case 124: $function = 'FIND'; break; - case 125: $function = 'CELL'; break; - case 144: $function = 'DDB'; break; - case 148: $function = 'INDIRECT'; break; - case 167: $function = 'IPMT'; break; - case 168: $function = 'PPMT'; break; - case 169: $function = 'COUNTA'; break; - case 183: $function = 'PRODUCT'; break; - case 193: $function = 'STDEVP'; break; - case 194: $function = 'VARP'; break; - case 197: $function = 'TRUNC'; break; - case 204: $function = 'USDOLLAR'; break; - case 205: $function = 'FINDB'; break; - case 206: $function = 'SEARCHB'; break; - case 208: $function = 'LEFTB'; break; - case 209: $function = 'RIGHTB'; break; - case 216: $function = 'RANK'; break; - case 219: $function = 'ADDRESS'; break; - case 220: $function = 'DAYS360'; break; - case 222: $function = 'VDB'; break; - case 227: $function = 'MEDIAN'; break; - case 228: $function = 'SUMPRODUCT'; break; - case 247: $function = 'DB'; break; - case 255: $function = ''; break; - case 269: $function = 'AVEDEV'; break; - case 270: $function = 'BETADIST'; break; - case 272: $function = 'BETAINV'; break; - case 317: $function = 'PROB'; break; - case 318: $function = 'DEVSQ'; break; - case 319: $function = 'GEOMEAN'; break; - case 320: $function = 'HARMEAN'; break; - case 321: $function = 'SUMSQ'; break; - case 322: $function = 'KURT'; break; - case 323: $function = 'SKEW'; break; - case 324: $function = 'ZTEST'; break; - case 329: $function = 'PERCENTRANK'; break; - case 330: $function = 'MODE'; break; - case 336: $function = 'CONCATENATE'; break; - case 344: $function = 'SUBTOTAL'; break; - case 345: $function = 'SUMIF'; break; - case 354: $function = 'ROMAN'; break; - case 358: $function = 'GETPIVOTDATA'; break; - case 359: $function = 'HYPERLINK'; break; - case 361: $function = 'AVERAGEA'; break; - case 362: $function = 'MAXA'; break; - case 363: $function = 'MINA'; break; - case 364: $function = 'STDEVPA'; break; - case 365: $function = 'VARPA'; break; - case 366: $function = 'STDEVA'; break; - case 367: $function = 'VARA'; break; - default: - throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); - break; - } - $data = array('function' => $function, 'args' => $args); - break; - case 0x23: // index to defined name - case 0x43: - case 0x63: - $name = 'tName'; - $size = 5; - // offset: 1; size: 2; one-based index to definedname record - $definedNameIndex = self::_GetInt2d($formulaData, 1) - 1; - // offset: 2; size: 2; not used - $data = $this->_definedname[$definedNameIndex]['name']; - break; - case 0x24: // single cell reference e.g. A5 - case 0x44: - case 0x64: - $name = 'tRef'; - $size = 5; - $data = $this->_readBIFF8CellAddress(substr($formulaData, 1, 4)); - break; - case 0x25: // cell range reference to cells in the same sheet (2d) - case 0x45: - case 0x65: - $name = 'tArea'; - $size = 9; - $data = $this->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8)); - break; - case 0x26: // Constant reference sub-expression - case 0x46: - case 0x66: - $name = 'tMemArea'; - // offset: 1; size: 4; not used - // offset: 5; size: 2; size of the following subexpression - $subSize = self::_GetInt2d($formulaData, 5); - $size = 7 + $subSize; - $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); - break; - case 0x27: // Deleted constant reference sub-expression - case 0x47: - case 0x67: - $name = 'tMemErr'; - // offset: 1; size: 4; not used - // offset: 5; size: 2; size of the following subexpression - $subSize = self::_GetInt2d($formulaData, 5); - $size = 7 + $subSize; - $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); - break; - case 0x29: // Variable reference sub-expression - case 0x49: - case 0x69: - $name = 'tMemFunc'; - // offset: 1; size: 2; size of the following sub-expression - $subSize = self::_GetInt2d($formulaData, 1); - $size = 3 + $subSize; - $data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize)); - break; - - case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places - case 0x4C: - case 0x6C: - $name = 'tRefN'; - $size = 5; - $data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell); - break; - - case 0x2D: // Relative 2d range reference - case 0x4D: - case 0x6D: - $name = 'tAreaN'; - $size = 9; - $data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell); - break; - - case 0x39: // External name - case 0x59: - case 0x79: - $name = 'tNameX'; - $size = 7; - // offset: 1; size: 2; index to REF entry in EXTERNSHEET record - // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record - $index = self::_GetInt2d($formulaData, 3); - // assume index is to EXTERNNAME record - $data = $this->_externalNames[$index - 1]['name']; - // offset: 5; size: 2; not used - break; - - case 0x3A: // 3d reference to cell - case 0x5A: - case 0x7A: - $name = 'tRef3d'; - $size = 7; - - try { - // offset: 1; size: 2; index to REF entry - $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); - // offset: 3; size: 4; cell address - $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4)); - - $data = "$sheetRange!$cellAddress"; - } catch (PHPExcel_Exception $e) { - // deleted sheet reference - $data = '#REF!'; - } - - break; - case 0x3B: // 3d reference to cell range - case 0x5B: - case 0x7B: - $name = 'tArea3d'; - $size = 11; - - try { - // offset: 1; size: 2; index to REF entry - $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); - // offset: 3; size: 8; cell address - $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8)); - - $data = "$sheetRange!$cellRangeAddress"; - } catch (PHPExcel_Exception $e) { - // deleted sheet reference - $data = '#REF!'; - } - - break; - // Unknown cases // don't know how to deal with - default: - throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); - break; - } - - return array( - 'id' => $id, - 'name' => $name, - 'size' => $size, - 'data' => $data, - ); - } - - - /** - * Reads a cell address in BIFF8 e.g. 'A2' or '$A$2' - * section 3.3.4 - * - * @param string $cellAddressStructure - * @return string - */ - private function _readBIFF8CellAddress($cellAddressStructure) - { - // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) - $row = self::_GetInt2d($cellAddressStructure, 0) + 1; - - // offset: 2; size: 2; index to column or column offset + relative flags - - // bit: 7-0; mask 0x00FF; column index - $column = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($cellAddressStructure, 2)); - - // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { - $column = '$' . $column; - } - // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { - $row = '$' . $row; - } - - 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 - * section 3.3.4 - * - * @param string $cellAddressStructure - * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas - * @return string - */ - private function _readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1') - { - list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell); - $baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1; - - // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) - $rowIndex = self::_GetInt2d($cellAddressStructure, 0); - $row = self::_GetInt2d($cellAddressStructure, 0) + 1; - - // offset: 2; size: 2; index to column or column offset + relative flags - - // bit: 7-0; mask 0x00FF; column index - $colIndex = 0x00FF & self::_GetInt2d($cellAddressStructure, 2); - - // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { - $column = PHPExcel_Cell::stringFromColumnIndex($colIndex); - $column = '$' . $column; - } else { - $colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256; - $column = PHPExcel_Cell::stringFromColumnIndex($baseCol + $colIndex); - } - - // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { - $row = '$' . $row; - } else { - $rowIndex = ($rowIndex <= 32767) ? $rowIndex : $rowIndex - 65536; - $row = $baseRow + $rowIndex; - } - - return $column . $row; - } - - - /** - * Reads a cell range address in BIFF5 e.g. 'A2:B6' or 'A1' - * always fixed range - * section 2.5.14 - * - * @param string $subData - * @return string - * @throws PHPExcel_Reader_Exception - */ - private function _readBIFF5CellRangeAddressFixed($subData) - { - // offset: 0; size: 2; index to first row - $fr = self::_GetInt2d($subData, 0) + 1; - - // offset: 2; size: 2; index to last row - $lr = self::_GetInt2d($subData, 2) + 1; - - // offset: 4; size: 1; index to first column - $fc = ord($subData{4}); - - // offset: 5; size: 1; index to last column - $lc = ord($subData{5}); - - // check values - if ($fr > $lr || $fc > $lc) { - throw new PHPExcel_Reader_Exception('Not a cell range address'); - } - - // column index to letter - $fc = PHPExcel_Cell::stringFromColumnIndex($fc); - $lc = PHPExcel_Cell::stringFromColumnIndex($lc); - - if ($fr == $lr and $fc == $lc) { - return "$fc$fr"; - } - return "$fc$fr:$lc$lr"; - } - - - /** - * Reads a cell range address in BIFF8 e.g. 'A2:B6' or 'A1' - * always fixed range - * section 2.5.14 - * - * @param string $subData - * @return string - * @throws PHPExcel_Reader_Exception - */ - private function _readBIFF8CellRangeAddressFixed($subData) - { - // offset: 0; size: 2; index to first row - $fr = self::_GetInt2d($subData, 0) + 1; - - // offset: 2; size: 2; index to last row - $lr = self::_GetInt2d($subData, 2) + 1; - - // offset: 4; size: 2; index to first column - $fc = self::_GetInt2d($subData, 4); - - // offset: 6; size: 2; index to last column - $lc = self::_GetInt2d($subData, 6); - - // check values - if ($fr > $lr || $fc > $lc) { - throw new PHPExcel_Reader_Exception('Not a cell range address'); - } - - // column index to letter - $fc = PHPExcel_Cell::stringFromColumnIndex($fc); - $lc = PHPExcel_Cell::stringFromColumnIndex($lc); - - if ($fr == $lr and $fc == $lc) { - return "$fc$fr"; - } - 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 - * section 3.3.4 - * - * @param string $subData - * @return string - */ - private function _readBIFF8CellRangeAddress($subData) - { - // todo: if cell range is just a single cell, should this funciton - // not just return e.g. 'A1' and not 'A1:A1' ? - - // offset: 0; size: 2; index to first row (0... 65535) (or offset (-32768... 32767)) - $fr = self::_GetInt2d($subData, 0) + 1; - - // offset: 2; size: 2; index to last row (0... 65535) (or offset (-32768... 32767)) - $lr = self::_GetInt2d($subData, 2) + 1; - - // 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: 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; - } - - // 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: 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; - } - - 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 - * section 3.3.4 - * - * @param string $subData - * @param string $baseCell Base cell - * @return string Cell range address - */ - private function _readBIFF8CellRangeAddressB($subData, $baseCell = 'A1') - { - list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell); - $baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1; - - // TODO: if cell range is just a single cell, should this funciton - // not just return e.g. 'A1' and not 'A1:A1' ? - - // offset: 0; size: 2; first row - $frIndex = self::_GetInt2d($subData, 0); // adjust below - - // offset: 2; size: 2; relative index to first row (0... 65535) should be treated as offset (-32768... 32767) - $lrIndex = self::_GetInt2d($subData, 2); // adjust below - - // offset: 4; size: 2; first column with relative/absolute flags - - // 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: 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); - $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; - } - - return "$fc$fr:$lc$lr"; - } - - - /** - * Read BIFF8 cell range address list - * section 2.5.15 - * - * @param string $subData - * @return array - */ - private function _readBIFF8CellRangeAddressList($subData) - { - $cellRangeAddresses = array(); - - // offset: 0; size: 2; number of the following cell range addresses - $nm = self::_GetInt2d($subData, 0); - - $offset = 2; - // offset: 2; size: 8 * $nm; list of $nm (fixed) cell range addresses - for ($i = 0; $i < $nm; ++$i) { - $cellRangeAddresses[] = $this->_readBIFF8CellRangeAddressFixed(substr($subData, $offset, 8)); - $offset += 8; - } - - return array( - 'size' => 2 + 8 * $nm, - 'cellRangeAddresses' => $cellRangeAddresses, - ); - } - - - /** - * Read BIFF5 cell range address list - * section 2.5.15 - * - * @param string $subData - * @return array - */ - private function _readBIFF5CellRangeAddressList($subData) - { - $cellRangeAddresses = array(); - - // offset: 0; size: 2; number of the following cell range addresses - $nm = self::_GetInt2d($subData, 0); - - $offset = 2; - // offset: 2; size: 6 * $nm; list of $nm (fixed) cell range addresses - for ($i = 0; $i < $nm; ++$i) { - $cellRangeAddresses[] = $this->_readBIFF5CellRangeAddressFixed(substr($subData, $offset, 6)); - $offset += 6; - } - - return array( - 'size' => 2 + 6 * $nm, - 'cellRangeAddresses' => $cellRangeAddresses, - ); - } - - - /** - * 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 - * It can also happen that the REF structure uses the -1 (FFFF) code to indicate deleted sheets, - * in which case an PHPExcel_Reader_Exception is thrown - * - * @param int $index - * @return string|false - * @throws PHPExcel_Reader_Exception - */ - private function _readSheetRangeByRefIndex($index) - { - if (isset($this->_ref[$index])) { - - $type = $this->_externalBooks[$this->_ref[$index]['externalBookIndex']]['type']; - - switch ($type) { - case 'internal': - // check if we have a deleted 3d reference - if ($this->_ref[$index]['firstSheetIndex'] == 0xFFFF or $this->_ref[$index]['lastSheetIndex'] == 0xFFFF) { - throw new PHPExcel_Reader_Exception('Deleted sheet reference'); - } - - // we have normal sheet range (collapsed or uncollapsed) - $firstSheetName = $this->_sheets[$this->_ref[$index]['firstSheetIndex']]['name']; - $lastSheetName = $this->_sheets[$this->_ref[$index]['lastSheetIndex']]['name']; - - if ($firstSheetName == $lastSheetName) { - // collapsed sheet range - $sheetRange = $firstSheetName; - } else { - $sheetRange = "$firstSheetName:$lastSheetName"; - } - - // escape the single-quotes - $sheetRange = str_replace("'", "''", $sheetRange); - - // if there are special characters, we need to enclose the range in single-quotes - // todo: check if we have identified the whole set of special characters - // it seems that the following characters are not accepted for sheet names - // and we may assume that they are not present: []*/:\? - if (preg_match("/[ !\"@#£$%&{()}<>=+'|^,;-]/", $sheetRange)) { - $sheetRange = "'$sheetRange'"; - } - - return $sheetRange; - break; - - default: - // TODO: external sheet support - throw new PHPExcel_Reader_Exception('Excel5 reader only supports internal sheets in fomulas'); - break; - } - } - return false; - } - - - /** - * read BIFF8 constant value array from array data - * returns e.g. array('value' => '{1,2;3,4}', 'size' => 40} - * section 2.5.8 - * - * @param string $arrayData - * @return array - */ - private static function _readBIFF8ConstantArray($arrayData) - { - // offset: 0; size: 1; number of columns decreased by 1 - $nc = ord($arrayData[0]); - - // offset: 1; size: 2; number of rows decreased by 1 - $nr = self::_GetInt2d($arrayData, 1); - $size = 3; // initialize - $arrayData = substr($arrayData, 3); - - // offset: 3; size: var; list of ($nc + 1) * ($nr + 1) constant values - $matrixChunks = array(); - for ($r = 1; $r <= $nr + 1; ++$r) { - $items = array(); - for ($c = 1; $c <= $nc + 1; ++$c) { - $constant = self::_readBIFF8Constant($arrayData); - $items[] = $constant['value']; - $arrayData = substr($arrayData, $constant['size']); - $size += $constant['size']; - } - $matrixChunks[] = implode(',', $items); // looks like e.g. '1,"hello"' - } - $matrix = '{' . implode(';', $matrixChunks) . '}'; - - return array( - 'value' => $matrix, - 'size' => $size, - ); - } - - - /** - * read BIFF8 constant value which may be 'Empty Value', 'Number', 'String Value', 'Boolean Value', 'Error Value' - * section 2.5.7 - * returns e.g. array('value' => '5', 'size' => 9) - * - * @param string $valueData - * @return array - */ - private static function _readBIFF8Constant($valueData) - { - // offset: 0; size: 1; identifier for type of constant - $identifier = ord($valueData[0]); - - switch ($identifier) { - case 0x00: // empty constant (what is this?) - $value = ''; - $size = 9; - break; - case 0x01: // number - // offset: 1; size: 8; IEEE 754 floating-point value - $value = self::_extractNumber(substr($valueData, 1, 8)); - $size = 9; - break; - case 0x02: // string value - // offset: 1; size: var; Unicode string, 16-bit string length - $string = self::_readUnicodeStringLong(substr($valueData, 1)); - $value = '"' . $string['value'] . '"'; - $size = 1 + $string['size']; - break; - case 0x04: // boolean - // offset: 1; size: 1; 0 = FALSE, 1 = TRUE - if (ord($valueData[1])) { - $value = 'TRUE'; - } else { - $value = 'FALSE'; - } - $size = 9; - break; - case 0x10: // error code - // offset: 1; size: 1; error code - $value = self::_mapErrorCode(ord($valueData[1])); - $size = 9; - break; - } - return array( - 'value' => $value, - 'size' => $size, - ); - } - - - /** - * Extract RGB color - * OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.4 - * - * @param string $rgb Encoded RGB value (4 bytes) - * @return array - */ - private static function _readRGB($rgb) - { - // offset: 0; size 1; Red component - $r = ord($rgb{0}); - - // offset: 1; size: 1; Green component - $g = ord($rgb{1}); - - // offset: 2; size: 1; Blue component - $b = ord($rgb{2}); - - // HEX notation, e.g. 'FF00FC' - $rgb = sprintf('%02X%02X%02X', $r, $g, $b); - - return array('rgb' => $rgb); - } - - - /** - * Read byte string (8-bit string length) - * OpenOffice documentation: 2.5.2 - * - * @param string $subData - * @return array - */ - private function _readByteStringShort($subData) - { - // offset: 0; size: 1; length of the string (character count) - $ln = ord($subData[0]); - - // offset: 1: size: var; character array (8-bit characters) - $value = $this->_decodeCodepage(substr($subData, 1, $ln)); - - return array( - 'value' => $value, - 'size' => 1 + $ln, // size in bytes of data structure - ); - } - - - /** - * Read byte string (16-bit string length) - * OpenOffice documentation: 2.5.2 - * - * @param string $subData - * @return array - */ - private function _readByteStringLong($subData) - { - // offset: 0; size: 2; length of the string (character count) - $ln = self::_GetInt2d($subData, 0); - - // offset: 2: size: var; character array (8-bit characters) - $value = $this->_decodeCodepage(substr($subData, 2)); - - //return $string; - return array( - 'value' => $value, - 'size' => 2 + $ln, // size in bytes of data structure - ); - } - - - /** - * Extracts an Excel Unicode short string (8-bit string length) - * OpenOffice documentation: 2.5.3 - * function will automatically find out where the Unicode string ends. - * - * @param string $subData - * @return array - */ - private static function _readUnicodeStringShort($subData) - { - $value = ''; - - // offset: 0: size: 1; length of the string (character count) - $characterCount = ord($subData[0]); - - $string = self::_readUnicodeString(substr($subData, 1), $characterCount); - - // add 1 for the string length - $string['size'] += 1; - - return $string; - } - - - /** - * Extracts an Excel Unicode long string (16-bit string length) - * OpenOffice documentation: 2.5.3 - * this function is under construction, needs to support rich text, and Asian phonetic settings - * - * @param string $subData - * @return array - */ - private static function _readUnicodeStringLong($subData) - { - $value = ''; - - // offset: 0: size: 2; length of the string (character count) - $characterCount = self::_GetInt2d($subData, 0); - - $string = self::_readUnicodeString(substr($subData, 2), $characterCount); - - // add 2 for the string length - $string['size'] += 2; - - 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 - * OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.3 - * - * @param string $subData - * @param int $characterCount - * @return array - */ - private static function _readUnicodeString($subData, $characterCount) - { - $value = ''; - - // offset: 0: size: 1; option flags - - // bit: 0; mask: 0x01; character compression (0 = compressed 8-bit, 1 = uncompressed 16-bit) - $isCompressed = !((0x01 & ord($subData[0])) >> 0); - - // bit: 2; mask: 0x04; Asian phonetic settings - $hasAsian = (0x04) & ord($subData[0]) >> 2; - - // bit: 3; mask: 0x08; Rich-Text settings - $hasRichText = (0x08) & ord($subData[0]) >> 3; - - // offset: 1: size: var; character array - // this offset assumes richtext and Asian phonetic settings are off which is generally wrong - // needs to be fixed - $value = self::_encodeUTF16(substr($subData, 1, $isCompressed ? $characterCount : 2 * $characterCount), $isCompressed); - - return array( - 'value' => $value, - 'size' => $isCompressed ? 1 + $characterCount : 1 + 2 * $characterCount, // the size in bytes including the option flags - ); - } - - - /** - * Convert UTF-8 string to string surounded by double quotes. Used for explicit string tokens in formulas. - * Example: hello"world --> "hello""world" - * - * @param string $value UTF-8 encoded string - * @return string - */ - private static function _UTF8toExcelDoubleQuoted($value) - { - return '"' . str_replace('"', '""', $value) . '"'; - } - - - /** - * Reads first 8 bytes of a string and return IEEE 754 float - * - * @param string $data Binary string that is at least 8 bytes long - * @return float - */ - private static function _extractNumber($data) - { - $rknumhigh = self::_GetInt4d($data, 4); - $rknumlow = self::_GetInt4d($data, 0); - $sign = ($rknumhigh & 0x80000000) >> 31; - $exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023; - $mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); - $mantissalow1 = ($rknumlow & 0x80000000) >> 31; - $mantissalow2 = ($rknumlow & 0x7fffffff); - $value = $mantissa / pow( 2 , (20 - $exp)); - - if ($mantissalow1 != 0) { - $value += 1 / pow (2 , (21 - $exp)); - } - - $value += $mantissalow2 / pow (2 , (52 - $exp)); - if ($sign) { - $value *= -1; - } - - return $value; - } - - - private static function _GetIEEE754($rknum) - { - if (($rknum & 0x02) != 0) { - $value = $rknum >> 2; - } 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 - // of the 64 bit floating point value. The other 34 bits are assumed - // to be 0 so we use the upper 30 bits of $rknum as follows... - $sign = ($rknum & 0x80000000) >> 31; - $exp = ($rknum & 0x7ff00000) >> 20; - $mantissa = (0x100000 | ($rknum & 0x000ffffc)); - $value = $mantissa / pow( 2 , (20- ($exp - 1023))); - if ($sign) { - $value = -1 * $value; - } - //end of changes by mmp - } - if (($rknum & 0x01) != 0) { - $value /= 100; - } - return $value; - } - - - /** - * Get UTF-8 string from (compressed or uncompressed) UTF-16 string - * - * @param string $string - * @param bool $compressed - * @return string - */ - private static function _encodeUTF16($string, $compressed = '') - { - if ($compressed) { - $string = self::_uncompressByteString($string); - } - - return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE'); - } - - - /** - * Convert UTF-16 string in compressed notation to uncompressed form. Only used for BIFF8. - * - * @param string $string - * @return string - */ - private static function _uncompressByteString($string) - { - $uncompressedString = ''; - $strLen = strlen($string); - for ($i = 0; $i < $strLen; ++$i) { - $uncompressedString .= $string[$i] . "\0"; - } - - return $uncompressedString; - } - - - /** - * Convert string to UTF-8. Only used for BIFF5. - * - * @param string $string - * @return string - */ - private function _decodeCodepage($string) - { - return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage); - } - - - /** - * Read 16-bit unsigned integer - * - * @param string $data - * @param int $pos - * @return int - */ - public static function _GetInt2d($data, $pos) - { - return ord($data[$pos]) | (ord($data[$pos+1]) << 8); - } - - - /** - * Read 32-bit signed integer - * - * @param string $data - * @param int $pos - * @return int - */ - public static function _GetInt4d($data, $pos) - { - // FIX: represent numbers correctly on 64-bit system - // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 - // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems - $_or_24 = ord($data[$pos + 3]); - if ($_or_24 >= 128) { - // negative number - $_ord_24 = -abs((256 - $_or_24) << 24); - } else { - $_ord_24 = ($_or_24 & 127) << 24; - } - return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24; - } - - - /** - * Read color - * - * @param int $color Indexed color - * @param array $palette Color palette - * @return array RGB color value, example: array('rgb' => 'FF0000') - */ - private static function _readColor($color, $palette, $version) - { - if ($color <= 0x07 || $color >= 0x40) { - // special built-in color - return self::_mapBuiltInColor($color); - } elseif (isset($palette) && isset($palette[$color - 8])) { - // palette color, color index 0x08 maps to pallete index 0 - return $palette[$color - 8]; - } else { - // default color table - if ($version == self::XLS_BIFF8) { - return self::_mapColor($color); - } else { - // BIFF5 - return self::_mapColorBIFF5($color); - } - } - - return $color; - } - - - /** - * Map border style - * OpenOffice documentation: 2.5.11 - * - * @param int $index - * @return string - */ - private static function _mapBorderStyle($index) - { - switch ($index) { - case 0x00: return PHPExcel_Style_Border::BORDER_NONE; - case 0x01: return PHPExcel_Style_Border::BORDER_THIN; - case 0x02: return PHPExcel_Style_Border::BORDER_MEDIUM; - case 0x03: return PHPExcel_Style_Border::BORDER_DASHED; - case 0x04: return PHPExcel_Style_Border::BORDER_DOTTED; - case 0x05: return PHPExcel_Style_Border::BORDER_THICK; - case 0x06: return PHPExcel_Style_Border::BORDER_DOUBLE; - case 0x07: return PHPExcel_Style_Border::BORDER_HAIR; - case 0x08: return PHPExcel_Style_Border::BORDER_MEDIUMDASHED; - case 0x09: return PHPExcel_Style_Border::BORDER_DASHDOT; - case 0x0A: return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; - case 0x0B: return PHPExcel_Style_Border::BORDER_DASHDOTDOT; - case 0x0C: return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; - case 0x0D: return PHPExcel_Style_Border::BORDER_SLANTDASHDOT; - default: return PHPExcel_Style_Border::BORDER_NONE; - } - } - - - /** - * Get fill pattern from index - * OpenOffice documentation: 2.5.12 - * - * @param int $index - * @return string - */ - private static function _mapFillPattern($index) - { - switch ($index) { - case 0x00: return PHPExcel_Style_Fill::FILL_NONE; - case 0x01: return PHPExcel_Style_Fill::FILL_SOLID; - case 0x02: return PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; - case 0x03: return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; - case 0x04: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; - case 0x05: return PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; - case 0x06: return PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; - case 0x07: return PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; - case 0x08: return PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; - case 0x09: return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; - case 0x0A: return PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; - case 0x0B: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; - case 0x0C: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; - case 0x0D: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; - case 0x0E: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; - case 0x0F: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; - case 0x10: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; - case 0x11: return PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; - case 0x12: return PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; - default: return PHPExcel_Style_Fill::FILL_NONE; - } - } - - - /** - * Map error code, e.g. '#N/A' - * - * @param int $subData - * @return string - */ - private static function _mapErrorCode($subData) - { - switch ($subData) { - case 0x00: return '#NULL!'; break; - case 0x07: return '#DIV/0!'; break; - case 0x0F: return '#VALUE!'; break; - case 0x17: return '#REF!'; break; - case 0x1D: return '#NAME?'; break; - case 0x24: return '#NUM!'; break; - case 0x2A: return '#N/A'; break; - default: return false; - } - } - - - /** - * Map built-in color to RGB value - * - * @param int $color Indexed color - * @return array - */ - private static function _mapBuiltInColor($color) - { - switch ($color) { - case 0x00: return array('rgb' => '000000'); - case 0x01: return array('rgb' => 'FFFFFF'); - case 0x02: return array('rgb' => 'FF0000'); - case 0x03: return array('rgb' => '00FF00'); - case 0x04: return array('rgb' => '0000FF'); - case 0x05: return array('rgb' => 'FFFF00'); - case 0x06: return array('rgb' => 'FF00FF'); - case 0x07: return array('rgb' => '00FFFF'); - case 0x40: return array('rgb' => '000000'); // system window text color - case 0x41: return array('rgb' => 'FFFFFF'); // system window background color - default: return array('rgb' => '000000'); - } - } - - - /** - * Map color array from BIFF5 built-in color index - * - * @param int $subData - * @return array - */ - private static function _mapColorBIFF5($subData) - { - switch ($subData) { - case 0x08: return array('rgb' => '000000'); - case 0x09: return array('rgb' => 'FFFFFF'); - case 0x0A: return array('rgb' => 'FF0000'); - case 0x0B: return array('rgb' => '00FF00'); - case 0x0C: return array('rgb' => '0000FF'); - case 0x0D: return array('rgb' => 'FFFF00'); - case 0x0E: return array('rgb' => 'FF00FF'); - case 0x0F: return array('rgb' => '00FFFF'); - case 0x10: return array('rgb' => '800000'); - case 0x11: return array('rgb' => '008000'); - case 0x12: return array('rgb' => '000080'); - case 0x13: return array('rgb' => '808000'); - case 0x14: return array('rgb' => '800080'); - case 0x15: return array('rgb' => '008080'); - case 0x16: return array('rgb' => 'C0C0C0'); - case 0x17: return array('rgb' => '808080'); - case 0x18: return array('rgb' => '8080FF'); - case 0x19: return array('rgb' => '802060'); - case 0x1A: return array('rgb' => 'FFFFC0'); - case 0x1B: return array('rgb' => 'A0E0F0'); - case 0x1C: return array('rgb' => '600080'); - case 0x1D: return array('rgb' => 'FF8080'); - case 0x1E: return array('rgb' => '0080C0'); - case 0x1F: return array('rgb' => 'C0C0FF'); - case 0x20: return array('rgb' => '000080'); - case 0x21: return array('rgb' => 'FF00FF'); - case 0x22: return array('rgb' => 'FFFF00'); - case 0x23: return array('rgb' => '00FFFF'); - case 0x24: return array('rgb' => '800080'); - case 0x25: return array('rgb' => '800000'); - case 0x26: return array('rgb' => '008080'); - case 0x27: return array('rgb' => '0000FF'); - case 0x28: return array('rgb' => '00CFFF'); - case 0x29: return array('rgb' => '69FFFF'); - case 0x2A: return array('rgb' => 'E0FFE0'); - case 0x2B: return array('rgb' => 'FFFF80'); - case 0x2C: return array('rgb' => 'A6CAF0'); - case 0x2D: return array('rgb' => 'DD9CB3'); - case 0x2E: return array('rgb' => 'B38FEE'); - case 0x2F: return array('rgb' => 'E3E3E3'); - case 0x30: return array('rgb' => '2A6FF9'); - case 0x31: return array('rgb' => '3FB8CD'); - case 0x32: return array('rgb' => '488436'); - case 0x33: return array('rgb' => '958C41'); - case 0x34: return array('rgb' => '8E5E42'); - case 0x35: return array('rgb' => 'A0627A'); - case 0x36: return array('rgb' => '624FAC'); - case 0x37: return array('rgb' => '969696'); - case 0x38: return array('rgb' => '1D2FBE'); - case 0x39: return array('rgb' => '286676'); - case 0x3A: return array('rgb' => '004500'); - case 0x3B: return array('rgb' => '453E01'); - case 0x3C: return array('rgb' => '6A2813'); - case 0x3D: return array('rgb' => '85396A'); - case 0x3E: return array('rgb' => '4A3285'); - case 0x3F: return array('rgb' => '424242'); - default: return array('rgb' => '000000'); - } - } - - - /** - * Map color array from BIFF8 built-in color index - * - * @param int $subData - * @return array - */ - private static function _mapColor($subData) - { - switch ($subData) { - case 0x08: return array('rgb' => '000000'); - case 0x09: return array('rgb' => 'FFFFFF'); - case 0x0A: return array('rgb' => 'FF0000'); - case 0x0B: return array('rgb' => '00FF00'); - case 0x0C: return array('rgb' => '0000FF'); - case 0x0D: return array('rgb' => 'FFFF00'); - case 0x0E: return array('rgb' => 'FF00FF'); - case 0x0F: return array('rgb' => '00FFFF'); - case 0x10: return array('rgb' => '800000'); - case 0x11: return array('rgb' => '008000'); - case 0x12: return array('rgb' => '000080'); - case 0x13: return array('rgb' => '808000'); - case 0x14: return array('rgb' => '800080'); - case 0x15: return array('rgb' => '008080'); - case 0x16: return array('rgb' => 'C0C0C0'); - case 0x17: return array('rgb' => '808080'); - case 0x18: return array('rgb' => '9999FF'); - case 0x19: return array('rgb' => '993366'); - case 0x1A: return array('rgb' => 'FFFFCC'); - case 0x1B: return array('rgb' => 'CCFFFF'); - case 0x1C: return array('rgb' => '660066'); - case 0x1D: return array('rgb' => 'FF8080'); - case 0x1E: return array('rgb' => '0066CC'); - case 0x1F: return array('rgb' => 'CCCCFF'); - case 0x20: return array('rgb' => '000080'); - case 0x21: return array('rgb' => 'FF00FF'); - case 0x22: return array('rgb' => 'FFFF00'); - case 0x23: return array('rgb' => '00FFFF'); - case 0x24: return array('rgb' => '800080'); - case 0x25: return array('rgb' => '800000'); - case 0x26: return array('rgb' => '008080'); - case 0x27: return array('rgb' => '0000FF'); - case 0x28: return array('rgb' => '00CCFF'); - case 0x29: return array('rgb' => 'CCFFFF'); - case 0x2A: return array('rgb' => 'CCFFCC'); - case 0x2B: return array('rgb' => 'FFFF99'); - case 0x2C: return array('rgb' => '99CCFF'); - case 0x2D: return array('rgb' => 'FF99CC'); - case 0x2E: return array('rgb' => 'CC99FF'); - case 0x2F: return array('rgb' => 'FFCC99'); - case 0x30: return array('rgb' => '3366FF'); - case 0x31: return array('rgb' => '33CCCC'); - case 0x32: return array('rgb' => '99CC00'); - case 0x33: return array('rgb' => 'FFCC00'); - case 0x34: return array('rgb' => 'FF9900'); - case 0x35: return array('rgb' => 'FF6600'); - case 0x36: return array('rgb' => '666699'); - case 0x37: return array('rgb' => '969696'); - case 0x38: return array('rgb' => '003366'); - case 0x39: return array('rgb' => '339966'); - case 0x3A: return array('rgb' => '003300'); - case 0x3B: return array('rgb' => '333300'); - case 0x3C: return array('rgb' => '993300'); - case 0x3D: return array('rgb' => '993366'); - case 0x3E: return array('rgb' => '333399'); - case 0x3F: return array('rgb' => '333333'); - default: return array('rgb' => '000000'); - } - } - - - private function _parseRichText($is = '') { - $value = new PHPExcel_RichText(); - - $value->createText($is); - - return $value; - } - -} +<?php +/** + * PHPExcel + * + * Copyright (c) 2006 - 2015 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_Excel5 + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ + +// Original file header of ParseXL (used as the base for this class): +// -------------------------------------------------------------------------------- +// Adapted from Excel_Spreadsheet_Reader developed by users bizon153, +// trex005, and mmp11 (SourceForge.net) +// http://sourceforge.net/projects/phpexcelreader/ +// Primary changes made by canyoncasa (dvc) for ParseXL 1.00 ... +// Modelled moreso after Perl Excel Parse/Write modules +// Added Parse_Excel_Spreadsheet object +// Reads a whole worksheet or tab as row,column array or as +// associated hash of indexed rows and named column fields +// Added variables for worksheet (tab) indexes and names +// Added an object call for loading individual woorksheets +// Changed default indexing defaults to 0 based arrays +// Fixed date/time and percent formats +// Includes patches found at SourceForge... +// unicode patch by nobody +// unpack("d") machine depedency patch by matchy +// boundsheet utf16 patch by bjaenichen +// Renamed functions for shorter names +// General code cleanup and rigor, including <80 column width +// Included a testcase Excel file and PHP example calls +// Code works for PHP 5.x + +// Primary changes made by canyoncasa (dvc) for ParseXL 1.10 ... +// http://sourceforge.net/tracker/index.php?func=detail&aid=1466964&group_id=99160&atid=623334 +// Decoding of formula conditions, results, and tokens. +// Support for user-defined named cells added as an array "namedcells" +// Patch code for user-defined named cells supports single cells only. +// NOTE: this patch only works for BIFF8 as BIFF5-7 use a different +// external sheet reference structure + + +/** PHPExcel root directory */ +if (!defined('PHPEXCEL_ROOT')) { + /** + * @ignore + */ + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); +} + +/** + * PHPExcel_Reader_Excel5 + * + * This class uses {@link http://sourceforge.net/projects/phpexcelreader/parseXL} + * + * @category PHPExcel + * @package PHPExcel_Reader_Excel5 + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + */ +class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader +{ + // ParseXL definitions + const XLS_BIFF8 = 0x0600; + const XLS_BIFF7 = 0x0500; + const XLS_WorkbookGlobals = 0x0005; + const XLS_Worksheet = 0x0010; + + // record identifiers + const XLS_Type_FORMULA = 0x0006; + const XLS_Type_EOF = 0x000a; + const XLS_Type_PROTECT = 0x0012; + const XLS_Type_OBJECTPROTECT = 0x0063; + const XLS_Type_SCENPROTECT = 0x00dd; + const XLS_Type_PASSWORD = 0x0013; + const XLS_Type_HEADER = 0x0014; + const XLS_Type_FOOTER = 0x0015; + const XLS_Type_EXTERNSHEET = 0x0017; + const XLS_Type_DEFINEDNAME = 0x0018; + const XLS_Type_VERTICALPAGEBREAKS = 0x001a; + const XLS_Type_HORIZONTALPAGEBREAKS = 0x001b; + const XLS_Type_NOTE = 0x001c; + const XLS_Type_SELECTION = 0x001d; + const XLS_Type_DATEMODE = 0x0022; + const XLS_Type_EXTERNNAME = 0x0023; + const XLS_Type_LEFTMARGIN = 0x0026; + const XLS_Type_RIGHTMARGIN = 0x0027; + const XLS_Type_TOPMARGIN = 0x0028; + const XLS_Type_BOTTOMMARGIN = 0x0029; + const XLS_Type_PRINTGRIDLINES = 0x002b; + const XLS_Type_FILEPASS = 0x002f; + const XLS_Type_FONT = 0x0031; + const XLS_Type_CONTINUE = 0x003c; + const XLS_Type_PANE = 0x0041; + const XLS_Type_CODEPAGE = 0x0042; + const XLS_Type_DEFCOLWIDTH = 0x0055; + const XLS_Type_OBJ = 0x005d; + const XLS_Type_COLINFO = 0x007d; + const XLS_Type_IMDATA = 0x007f; + const XLS_Type_SHEETPR = 0x0081; + const XLS_Type_HCENTER = 0x0083; + const XLS_Type_VCENTER = 0x0084; + const XLS_Type_SHEET = 0x0085; + const XLS_Type_PALETTE = 0x0092; + const XLS_Type_SCL = 0x00a0; + const XLS_Type_PAGESETUP = 0x00a1; + const XLS_Type_MULRK = 0x00bd; + const XLS_Type_MULBLANK = 0x00be; + const XLS_Type_DBCELL = 0x00d7; + const XLS_Type_XF = 0x00e0; + const XLS_Type_MERGEDCELLS = 0x00e5; + const XLS_Type_MSODRAWINGGROUP = 0x00eb; + const XLS_Type_MSODRAWING = 0x00ec; + const XLS_Type_SST = 0x00fc; + const XLS_Type_LABELSST = 0x00fd; + const XLS_Type_EXTSST = 0x00ff; + const XLS_Type_EXTERNALBOOK = 0x01ae; + const XLS_Type_DATAVALIDATIONS = 0x01b2; + const XLS_Type_TXO = 0x01b6; + const XLS_Type_HYPERLINK = 0x01b8; + const XLS_Type_DATAVALIDATION = 0x01be; + const XLS_Type_DIMENSION = 0x0200; + const XLS_Type_BLANK = 0x0201; + const XLS_Type_NUMBER = 0x0203; + const XLS_Type_LABEL = 0x0204; + const XLS_Type_BOOLERR = 0x0205; + const XLS_Type_STRING = 0x0207; + const XLS_Type_ROW = 0x0208; + const XLS_Type_INDEX = 0x020b; + const XLS_Type_ARRAY = 0x0221; + const XLS_Type_DEFAULTROWHEIGHT = 0x0225; + const XLS_Type_WINDOW2 = 0x023e; + const XLS_Type_RK = 0x027e; + const XLS_Type_STYLE = 0x0293; + const XLS_Type_FORMAT = 0x041e; + const XLS_Type_SHAREDFMLA = 0x04bc; + const XLS_Type_BOF = 0x0809; + const XLS_Type_SHEETPROTECTION = 0x0867; + const XLS_Type_RANGEPROTECTION = 0x0868; + const XLS_Type_SHEETLAYOUT = 0x0862; + const XLS_Type_XFEXT = 0x087d; + const XLS_Type_PAGELAYOUTVIEW = 0x088b; + const XLS_Type_UNKNOWN = 0xffff; + + // Encryption type + const MS_BIFF_CRYPTO_NONE = 0; + const MS_BIFF_CRYPTO_XOR = 1; + const MS_BIFF_CRYPTO_RC4 = 2; + + // Size of stream blocks when using RC4 encryption + const REKEY_BLOCK = 0x400; + + /** + * Summary Information stream data. + * + * @var string + */ + private $_summaryInformation; + + /** + * Extended Summary Information stream data. + * + * @var string + */ + private $_documentSummaryInformation; + + /** + * User-Defined Properties stream data. + * + * @var string + */ + private $_userDefinedProperties; + + /** + * Workbook stream data. (Includes workbook globals substream as well as sheet substreams) + * + * @var string + */ + private $_data; + + /** + * Size in bytes of $this->_data + * + * @var int + */ + private $_dataSize; + + /** + * Current position in stream + * + * @var integer + */ + private $_pos; + + /** + * Workbook to be returned by the reader. + * + * @var PHPExcel + */ + private $_phpExcel; + + /** + * Worksheet that is currently being built by the reader. + * + * @var PHPExcel_Worksheet + */ + private $_phpSheet; + + /** + * BIFF version + * + * @var int + */ + private $_version; + + /** + * Codepage set in the Excel file being read. Only important for BIFF5 (Excel 5.0 - Excel 95) + * For BIFF8 (Excel 97 - Excel 2003) this will always have the value 'UTF-16LE' + * + * @var string + */ + private $_codepage; + + /** + * Shared formats + * + * @var array + */ + private $_formats; + + /** + * Shared fonts + * + * @var array + */ + private $_objFonts; + + /** + * Color palette + * + * @var array + */ + private $_palette; + + /** + * Worksheets + * + * @var array + */ + private $_sheets; + + /** + * External books + * + * @var array + */ + private $_externalBooks; + + /** + * REF structures. Only applies to BIFF8. + * + * @var array + */ + private $_ref; + + /** + * External names + * + * @var array + */ + private $_externalNames; + + /** + * Defined names + * + * @var array + */ + private $_definedname; + + /** + * Shared strings. Only applies to BIFF8. + * + * @var array + */ + private $_sst; + + /** + * Panes are frozen? (in sheet currently being read). See WINDOW2 record. + * + * @var boolean + */ + private $_frozen; + + /** + * Fit printout to number of pages? (in sheet currently being read). See SHEETPR record. + * + * @var boolean + */ + private $_isFitToPages; + + /** + * Objects. One OBJ record contributes with one entry. + * + * @var array + */ + private $_objs; + + /** + * Text Objects. One TXO record corresponds with one entry. + * + * @var array + */ + private $_textObjects; + + /** + * Cell Annotations (BIFF8) + * + * @var array + */ + private $_cellNotes; + + /** + * The combined MSODRAWINGGROUP data + * + * @var string + */ + private $_drawingGroupData; + + /** + * The combined MSODRAWING data (per sheet) + * + * @var string + */ + private $_drawingData; + + /** + * Keep track of XF index + * + * @var int + */ + private $_xfIndex; + + /** + * Mapping of XF index (that is a cell XF) to final index in cellXf collection + * + * @var array + */ + private $_mapCellXfIndex; + + /** + * Mapping of XF index (that is a style XF) to final index in cellStyleXf collection + * + * @var array + */ + private $_mapCellStyleXfIndex; + + /** + * The shared formulas in a sheet. One SHAREDFMLA record contributes with one value. + * + * @var array + */ + private $_sharedFormulas; + + /** + * The shared formula parts in a sheet. One FORMULA record contributes with one value if it + * refers to a shared formula. + * + * @var array + */ + private $_sharedFormulaParts; + + /** + * The type of encryption in use + * + * @var int + */ + private $_encryption = 0; + + /** + * The position in the stream after which contents are encrypted + * + * @var int + */ + private $_encryptionStartPos = false; + + /** + * The current RC4 decryption object + * + * @var PHPExcel_Reader_Excel5_RC4 + */ + private $_rc4Key = null; + + /** + * The position in the stream that the RC4 decryption object was left at + * + * @var int + */ + private $_rc4Pos = 0; + + /** + * The current MD5 context state + * + * @var string + */ + private $_md5Ctxt = null; + + /** + * 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 PHPExcel_Reader_Exception + */ + public function canRead($pFilename) + { + // Check if file exists + if (!file_exists($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + try { + // Use ParseXL for the hard work. + $ole = new PHPExcel_Shared_OLERead(); + + // get excel data + $res = $ole->read($pFilename); + return true; + } catch (PHPExcel_Exception $e) { + return false; + } + } + + /** + * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object + * + * @param string $pFilename + * @throws PHPExcel_Reader_Exception + */ + public function listWorksheetNames($pFilename) + { + // Check if file exists + if (!file_exists($pFilename)) { + throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + $worksheetNames = array(); + + // Read the OLE file + $this->_loadOLE($pFilename); + + // total byte size of Excel data (workbook global substream + sheet substreams) + $this->_dataSize = strlen($this->_data); + + $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; + } + } + + foreach ($this->_sheets as $sheet) { + if ($sheet['sheetType'] != 0x00) { + // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module + continue; + } + + $worksheetNames[] = $sheet['name']; + } + + return $worksheetNames; + } + + + /** + * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) + * + * @param string $pFilename + * @throws PHPExcel_Reader_Exception + */ + public function listWorksheetInfo($pFilename) + { + // Check if file exists + if (!file_exists($pFilename)) { + throw new PHPExcel_Reader_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 = $this->_readRecordData($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 + * + * @param string $pFilename + * @return PHPExcel + * @throws PHPExcel_Reader_Exception + */ + public function load($pFilename) + { + // Read the OLE file + $this->_loadOLE($pFilename); + + // Initialisations + $this->_phpExcel = new PHPExcel; + $this->_phpExcel->removeSheetByIndex(0); // remove 1st sheet + if (!$this->_readDataOnly) { + $this->_phpExcel->removeCellStyleXfByIndex(0); // remove the default style + $this->_phpExcel->removeCellXfByIndex(0); // remove the default style + } + + // Read the summary information stream (containing meta data) + $this->_readSummaryInformation(); + + // Read the Additional document summary information stream (containing application-specific meta data) + $this->_readDocumentSummaryInformation(); + + // total byte size of Excel data (workbook global substream + sheet substreams) + $this->_dataSize = strlen($this->_data); + + // initialize + $this->_pos = 0; + $this->_codepage = 'CP1252'; + $this->_formats = array(); + $this->_objFonts = array(); + $this->_palette = array(); + $this->_sheets = array(); + $this->_externalBooks = array(); + $this->_ref = array(); + $this->_definedname = array(); + $this->_sst = array(); + $this->_drawingGroupData = ''; + $this->_xfIndex = ''; + $this->_mapCellXfIndex = array(); + $this->_mapCellStyleXfIndex = 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_FILEPASS: + $this->_readFilepass(); + break; + case self::XLS_Type_CODEPAGE: + $this->_readCodepage(); + break; + case self::XLS_Type_DATEMODE: + $this->_readDateMode(); + break; + case self::XLS_Type_FONT: + $this->_readFont(); + break; + case self::XLS_Type_FORMAT: + $this->_readFormat(); + break; + case self::XLS_Type_XF: + $this->_readXf(); + break; + case self::XLS_Type_XFEXT: + $this->_readXfExt(); + break; + case self::XLS_Type_STYLE: + $this->_readStyle(); + break; + case self::XLS_Type_PALETTE: + $this->_readPalette(); + break; + case self::XLS_Type_SHEET: + $this->_readSheet(); + break; + case self::XLS_Type_EXTERNALBOOK: + $this->_readExternalBook(); + break; + case self::XLS_Type_EXTERNNAME: + $this->_readExternName(); + break; + case self::XLS_Type_EXTERNSHEET: + $this->_readExternSheet(); + break; + case self::XLS_Type_DEFINEDNAME: + $this->_readDefinedName(); + break; + case self::XLS_Type_MSODRAWINGGROUP: + $this->_readMsoDrawingGroup(); + break; + case self::XLS_Type_SST: + $this->_readSst(); + break; + case self::XLS_Type_EOF: + $this->_readDefault(); + break 2; + default: + $this->_readDefault(); + break; + } + } + + // Resolve indexed colors for font, fill, and border colors + // Cannot be resolved already in XF record, because PALETTE record comes afterwards + if (!$this->_readDataOnly) { + foreach ($this->_objFonts as $objFont) { + if (isset($objFont->colorIndex)) { + $color = self::_readColor($objFont->colorIndex, $this->_palette, $this->_version); + $objFont->getColor()->setRGB($color['rgb']); + } + } + + foreach ($this->_phpExcel->getCellXfCollection() as $objStyle) { + // fill start and end color + $fill = $objStyle->getFill(); + + if (isset($fill->startcolorIndex)) { + $startColor = self::_readColor($fill->startcolorIndex, $this->_palette, $this->_version); + $fill->getStartColor()->setRGB($startColor['rgb']); + } + if (isset($fill->endcolorIndex)) { + $endColor = self::_readColor($fill->endcolorIndex, $this->_palette, $this->_version); + $fill->getEndColor()->setRGB($endColor['rgb']); + } + + // border colors + $top = $objStyle->getBorders()->getTop(); + $right = $objStyle->getBorders()->getRight(); + $bottom = $objStyle->getBorders()->getBottom(); + $left = $objStyle->getBorders()->getLeft(); + $diagonal = $objStyle->getBorders()->getDiagonal(); + + if (isset($top->colorIndex)) { + $borderTopColor = self::_readColor($top->colorIndex, $this->_palette, $this->_version); + $top->getColor()->setRGB($borderTopColor['rgb']); + } + if (isset($right->colorIndex)) { + $borderRightColor = self::_readColor($right->colorIndex, $this->_palette, $this->_version); + $right->getColor()->setRGB($borderRightColor['rgb']); + } + if (isset($bottom->colorIndex)) { + $borderBottomColor = self::_readColor($bottom->colorIndex, $this->_palette, $this->_version); + $bottom->getColor()->setRGB($borderBottomColor['rgb']); + } + if (isset($left->colorIndex)) { + $borderLeftColor = self::_readColor($left->colorIndex, $this->_palette, $this->_version); + $left->getColor()->setRGB($borderLeftColor['rgb']); + } + if (isset($diagonal->colorIndex)) { + $borderDiagonalColor = self::_readColor($diagonal->colorIndex, $this->_palette, $this->_version); + $diagonal->getColor()->setRGB($borderDiagonalColor['rgb']); + } + } + } + + // treat MSODRAWINGGROUP records, workbook-level Escher + if (!$this->_readDataOnly && $this->_drawingGroupData) { + $escherWorkbook = new PHPExcel_Shared_Escher(); + $reader = new PHPExcel_Reader_Excel5_Escher($escherWorkbook); + $escherWorkbook = $reader->load($this->_drawingGroupData); + + // debug Escher stream + //$debug = new Debug_Escher(new PHPExcel_Shared_Escher()); + //$debug->load($this->_drawingGroupData); + } + + // Parse the individual sheets + foreach ($this->_sheets as $sheet) { + if ($sheet['sheetType'] != 0x00) { + // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module + continue; + } + + // check if sheet should be skipped + if (isset($this->_loadSheetsOnly) && !in_array($sheet['name'], $this->_loadSheetsOnly)) { + continue; + } + + // add sheet to PHPExcel object + $this->_phpSheet = $this->_phpExcel->createSheet(); + // 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']; + + // Initialize isFitToPages. May change after reading SHEETPR record. + $this->_isFitToPages = false; + + // Initialize drawingData + $this->_drawingData = ''; + + // Initialize objs + $this->_objs = array(); + + // Initialize shared formula parts + $this->_sharedFormulaParts = array(); + + // Initialize shared formulas + $this->_sharedFormulas = array(); + + // Initialize text objs + $this->_textObjects = array(); + + // Initialize cell annotations + $this->_cellNotes = array(); + $this->textObjRef = -1; + + while ($this->_pos <= $this->_dataSize - 4) { + $code = self::_GetInt2d($this->_data, $this->_pos); + + switch ($code) { + case self::XLS_Type_BOF: + $this->_readBof(); + break; + case self::XLS_Type_PRINTGRIDLINES: + $this->_readPrintGridlines(); + break; + case self::XLS_Type_DEFAULTROWHEIGHT: + $this->_readDefaultRowHeight(); + break; + case self::XLS_Type_SHEETPR: + $this->_readSheetPr(); + break; + case self::XLS_Type_HORIZONTALPAGEBREAKS: + $this->_readHorizontalPageBreaks(); + break; + case self::XLS_Type_VERTICALPAGEBREAKS: + $this->_readVerticalPageBreaks(); + break; + case self::XLS_Type_HEADER: + $this->_readHeader(); + break; + case self::XLS_Type_FOOTER: + $this->_readFooter(); + break; + case self::XLS_Type_HCENTER: + $this->_readHcenter(); + break; + case self::XLS_Type_VCENTER: + $this->_readVcenter(); + break; + case self::XLS_Type_LEFTMARGIN: + $this->_readLeftMargin(); + break; + case self::XLS_Type_RIGHTMARGIN: + $this->_readRightMargin(); + break; + case self::XLS_Type_TOPMARGIN: + $this->_readTopMargin(); + break; + case self::XLS_Type_BOTTOMMARGIN: + $this->_readBottomMargin(); + break; + case self::XLS_Type_PAGESETUP: + $this->_readPageSetup(); + break; + case self::XLS_Type_PROTECT: + $this->_readProtect(); + break; + case self::XLS_Type_SCENPROTECT: + $this->_readScenProtect(); + break; + case self::XLS_Type_OBJECTPROTECT: + $this->_readObjectProtect(); + break; + case self::XLS_Type_PASSWORD: + $this->_readPassword(); + break; + case self::XLS_Type_DEFCOLWIDTH: + $this->_readDefColWidth(); + break; + case self::XLS_Type_COLINFO: + $this->_readColInfo(); + break; + case self::XLS_Type_DIMENSION: + $this->_readDefault(); + break; + case self::XLS_Type_ROW: + $this->_readRow(); + break; + case self::XLS_Type_DBCELL: + $this->_readDefault(); + break; + case self::XLS_Type_RK: + $this->_readRk(); + break; + case self::XLS_Type_LABELSST: + $this->_readLabelSst(); + break; + case self::XLS_Type_MULRK: + $this->_readMulRk(); + break; + case self::XLS_Type_NUMBER: + $this->_readNumber(); + break; + case self::XLS_Type_FORMULA: + $this->_readFormula(); + break; + case self::XLS_Type_SHAREDFMLA: + $this->_readSharedFmla(); + break; + case self::XLS_Type_BOOLERR: + $this->_readBoolErr(); + break; + case self::XLS_Type_MULBLANK: + $this->_readMulBlank(); + break; + case self::XLS_Type_LABEL: + $this->_readLabel(); + break; + case self::XLS_Type_BLANK: + $this->_readBlank(); + break; + case self::XLS_Type_MSODRAWING: + $this->_readMsoDrawing(); + break; + case self::XLS_Type_OBJ: + $this->_readObj(); + break; + case self::XLS_Type_WINDOW2: + $this->_readWindow2(); + break; + case self::XLS_Type_PAGELAYOUTVIEW: + $this->_readPageLayoutView(); + break; + case self::XLS_Type_SCL: + $this->_readScl(); + break; + case self::XLS_Type_PANE: + $this->_readPane(); + break; + case self::XLS_Type_SELECTION: + $this->_readSelection(); + break; + case self::XLS_Type_MERGEDCELLS: + $this->_readMergedCells(); + break; + case self::XLS_Type_HYPERLINK: + $this->_readHyperLink(); + break; + case self::XLS_Type_DATAVALIDATIONS: + $this->_readDataValidations(); + break; + case self::XLS_Type_DATAVALIDATION: + $this->_readDataValidation(); + break; + case self::XLS_Type_SHEETLAYOUT: + $this->_readSheetLayout(); + break; + case self::XLS_Type_SHEETPROTECTION: + $this->_readSheetProtection(); + break; + case self::XLS_Type_RANGEPROTECTION: + $this->_readRangeProtection(); + break; + case self::XLS_Type_NOTE: + $this->_readNote(); + break; + //case self::XLS_Type_IMDATA: $this->_readImData(); break; + case self::XLS_Type_TXO: + $this->_readTextObject(); + break; + case self::XLS_Type_CONTINUE: + $this->_readContinue(); + break; + case self::XLS_Type_EOF: + $this->_readDefault(); + break 2; + default: + $this->_readDefault(); + break; + } + + } + + // treat MSODRAWING records, sheet-level Escher + if (!$this->_readDataOnly && $this->_drawingData) { + $escherWorksheet = new PHPExcel_Shared_Escher(); + $reader = new PHPExcel_Reader_Excel5_Escher($escherWorksheet); + $escherWorksheet = $reader->load($this->_drawingData); + + // debug Escher stream + //$debug = new Debug_Escher(new PHPExcel_Shared_Escher()); + //$debug->load($this->_drawingData); + + // get all spContainers in one long array, so they can be mapped to OBJ records + $allSpContainers = $escherWorksheet->getDgContainer()->getSpgrContainer()->getAllSpContainers(); + } + + // treat OBJ records + foreach ($this->_objs as $n => $obj) { +// echo '<hr /><b>Object</b> reference is ', $n,'<br />'; +// var_dump($obj); +// echo '<br />'; + + // the first shape container never has a corresponding OBJ record, hence $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<br />'; +// echo 'Object ID is ', $obj['idObjID'],'<br />'; + 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<br />'; + // 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; + } + } + } + + // treat SHAREDFMLA records + if ($this->_version == self::XLS_BIFF8) { + foreach ($this->_sharedFormulaParts as $cell => $baseCell) { + list($column, $row) = PHPExcel_Cell::coordinateFromString($cell); + 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 (!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 '<b>Cell annotation ', $note,'</b><br />'; +// var_dump($noteDetails); +// echo '<br />'; + $cellAddress = str_replace('$', '', $noteDetails['cellRef']); + $this->_phpSheet->getComment($cellAddress)->setAuthor($noteDetails['author'])->setText($this->_parseRichText($noteDetails['objTextData']['text'])); + } + } + } + + // add the named ranges (defined names) + foreach ($this->_definedname as $definedName) { + if ($definedName['isBuiltInName']) { + switch ($definedName['name']) { + case pack('C', 0x06): + // print area + // in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2 + $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? + + $extractedRanges = array(); + foreach ($ranges as $range) { + // $range should look like one of these + // Foo!$C$7:$J$66 + // Bar!$A$1:$IV$2 + $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? + $sheetName = trim($explodes[0], "'"); + if (count($explodes) == 2) { + if (strpos($explodes[1], ':') === false) { + $explodes[1] = $explodes[1] . ':' . $explodes[1]; + } + $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 + } + } + if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) { + $docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2 + } + break; + case pack('C', 0x07): + // print titles (repeating rows) + // Assuming BIFF8, there are 3 cases + // 1. repeating rows + // formula looks like this: Sheet!$A$1:$IV$2 + // rows 1-2 repeat + // 2. repeating columns + // formula looks like this: Sheet!$A$1:$B$65536 + // columns A-B repeat + // 3. both repeating rows and repeating columns + // formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2 + $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? + foreach ($ranges as $range) { + // $range should look like this one of these + // Sheet!$A$1:$B$65536 + // Sheet!$A$1:$IV$2 + $explodes = explode('!', $range); + if (count($explodes) == 2) { + if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) { + $extractedRange = $explodes[1]; + $extractedRange = str_replace('$', '', $extractedRange); + + $coordinateStrings = explode(':', $extractedRange); + if (count($coordinateStrings) == 2) { + list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]); + list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]); + + if ($firstColumn == 'A' and $lastColumn == 'IV') { + // then we have repeating rows + $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow)); + } elseif ($firstRow == 1 and $lastRow == 65536) { + // then we have repeating columns + $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn)); + } + } + } + } + } + break; + } + } else { + // Extract range + $explodes = explode('!', $definedName['formula']); + + if (count($explodes) == 2) { + 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 + } + } + } + $this->_data = null; + + return $this->_phpExcel; + } + + /** + * Read record data from stream, decrypting as required + * + * @param string $data Data stream to read from + * @param int $pos Position to start reading from + * @param int $length Record data length + * + * @return string Record data + */ + private function _readRecordData($data, $pos, $len) + { + $data = substr($data, $pos, $len); + + // File not encrypted, or record before encryption start point + if ($this->_encryption == self::MS_BIFF_CRYPTO_NONE || $pos < $this->_encryptionStartPos) { + return $data; + } + + $recordData = ''; + if ($this->_encryption == self::MS_BIFF_CRYPTO_RC4) { + $oldBlock = floor($this->_rc4Pos / self::REKEY_BLOCK); + $block = floor($pos / self::REKEY_BLOCK); + $endBlock = floor(($pos + $len) / self::REKEY_BLOCK); + + // Spin an RC4 decryptor to the right spot. If we have a decryptor sitting + // at a point earlier in the current block, re-use it as we can save some time. + if ($block != $oldBlock || $pos < $this->_rc4Pos || !$this->_rc4Key) { + $this->_rc4Key = $this->_makeKey($block, $this->_md5Ctxt); + $step = $pos % self::REKEY_BLOCK; + } else { + $step = $pos - $this->_rc4Pos; + } + $this->_rc4Key->RC4(str_repeat("\0", $step)); + + // Decrypt record data (re-keying at the end of every block) + while ($block != $endBlock) { + $step = self::REKEY_BLOCK - ($pos % self::REKEY_BLOCK); + $recordData .= $this->_rc4Key->RC4(substr($data, 0, $step)); + $data = substr($data, $step); + $pos += $step; + $len -= $step; + $block++; + $this->_rc4Key = $this->_makeKey($block, $this->_md5Ctxt); + } + $recordData .= $this->_rc4Key->RC4(substr($data, 0, $len)); + + // Keep track of the position of this decryptor. + // We'll try and re-use it later if we can to speed things up + $this->_rc4Pos = $pos + $len; + } elseif ($this->_encryption == self::MS_BIFF_CRYPTO_XOR) { + throw new PHPExcel_Reader_Exception('XOr encryption not supported'); + } + return $recordData; + } + + /** + * Use OLE reader to extract the relevant data streams from the OLE file + * + * @param string $pFilename + */ + private function _loadOLE($pFilename) + { + // OLE reader + $ole = new PHPExcel_Shared_OLERead(); + // get excel data, + $res = $ole->read($pFilename); + // Get workbook data: workbook stream + sheet streams + $this->_data = $ole->getStream($ole->wrkbook); + // Get summary information data + $this->_summaryInformation = $ole->getStream($ole->summaryInformation); + // Get additional document summary information data + $this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation); + // Get user-defined property data +// $this->_userDefinedProperties = $ole->getUserDefinedProperties(); + } + + + /** + * Read summary information + */ + private function _readSummaryInformation() + { + if (!isset($this->_summaryInformation)) { + return; + } + + // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) + // offset: 2; size: 2; + // offset: 4; size: 2; OS version + // offset: 6; size: 2; OS indicator + // offset: 8; size: 16 + // offset: 24; size: 4; section count + $secCount = self::_GetInt4d($this->_summaryInformation, 24); + + // offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9 + // offset: 44; size: 4 + $secOffset = self::_GetInt4d($this->_summaryInformation, 44); + + // section header + // offset: $secOffset; size: 4; section length + $secLength = self::_GetInt4d($this->_summaryInformation, $secOffset); + + // offset: $secOffset+4; size: 4; property count + $countProperties = self::_GetInt4d($this->_summaryInformation, $secOffset+4); + + // initialize code page (used to resolve string values) + $codePage = 'CP1252'; + + // offset: ($secOffset+8); size: var + // loop through property decarations and properties + for ($i = 0; $i < $countProperties; ++$i) { + // offset: ($secOffset+8) + (8 * $i); size: 4; property ID + $id = self::_GetInt4d($this->_summaryInformation, ($secOffset+8) + (8 * $i)); + + // Use value of property id as appropriate + // offset: ($secOffset+12) + (8 * $i); size: 4; offset from beginning of section (48) + $offset = self::_GetInt4d($this->_summaryInformation, ($secOffset+12) + (8 * $i)); + + $type = self::_GetInt4d($this->_summaryInformation, $secOffset + $offset); + + // initialize property value + $value = null; + + // extract property value based on property type + switch ($type) { + case 0x02: // 2 byte signed integer + $value = self::_GetInt2d($this->_summaryInformation, $secOffset + 4 + $offset); + break; + case 0x03: // 4 byte signed integer + $value = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset); + break; + case 0x13: // 4 byte unsigned integer + // not needed yet, fix later if necessary + break; + case 0x1E: // null-terminated string prepended by dword string length + $byteLength = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset); + $value = substr($this->_summaryInformation, $secOffset + 8 + $offset, $byteLength); + $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage); + $value = rtrim($value); + break; + case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) + // PHP-time + $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_summaryInformation, $secOffset + 4 + $offset, 8)); + break; + case 0x47: // Clipboard format + // not needed yet, fix later if necessary + break; + } + + switch ($id) { + case 0x01: // Code Page + $codePage = PHPExcel_Shared_CodePage::NumberToName($value); + break; + case 0x02: // Title + $this->_phpExcel->getProperties()->setTitle($value); + break; + case 0x03: // Subject + $this->_phpExcel->getProperties()->setSubject($value); + break; + case 0x04: // Author (Creator) + $this->_phpExcel->getProperties()->setCreator($value); + break; + case 0x05: // Keywords + $this->_phpExcel->getProperties()->setKeywords($value); + break; + case 0x06: // Comments (Description) + $this->_phpExcel->getProperties()->setDescription($value); + break; + case 0x07: // Template + // Not supported by PHPExcel + break; + case 0x08: // Last Saved By (LastModifiedBy) + $this->_phpExcel->getProperties()->setLastModifiedBy($value); + break; + case 0x09: // Revision + // Not supported by PHPExcel + break; + case 0x0A: // Total Editing Time + // Not supported by PHPExcel + break; + case 0x0B: // Last Printed + // Not supported by PHPExcel + break; + case 0x0C: // Created Date/Time + $this->_phpExcel->getProperties()->setCreated($value); + break; + case 0x0D: // Modified Date/Time + $this->_phpExcel->getProperties()->setModified($value); + break; + case 0x0E: // Number of Pages + // Not supported by PHPExcel + break; + case 0x0F: // Number of Words + // Not supported by PHPExcel + break; + case 0x10: // Number of Characters + // Not supported by PHPExcel + break; + case 0x11: // Thumbnail + // Not supported by PHPExcel + break; + case 0x12: // Name of creating application + // Not supported by PHPExcel + break; + case 0x13: // Security + // Not supported by PHPExcel + break; + } + } + } + + + /** + * Read additional document summary information + */ + private function _readDocumentSummaryInformation() + { + if (!isset($this->_documentSummaryInformation)) { + return; + } + + // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) + // offset: 2; size: 2; + // offset: 4; size: 2; OS version + // offset: 6; size: 2; OS indicator + // offset: 8; size: 16 + // offset: 24; size: 4; section count + $secCount = self::_GetInt4d($this->_documentSummaryInformation, 24); +// echo '$secCount = ', $secCount,'<br />'; + + // offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae + // offset: 44; size: 4; first section offset + $secOffset = self::_GetInt4d($this->_documentSummaryInformation, 44); +// echo '$secOffset = ', $secOffset,'<br />'; + + // section header + // offset: $secOffset; size: 4; section length + $secLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset); +// echo '$secLength = ', $secLength,'<br />'; + + // offset: $secOffset+4; size: 4; property count + $countProperties = self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4); +// echo '$countProperties = ', $countProperties,'<br />'; + + // initialize code page (used to resolve string values) + $codePage = 'CP1252'; + + // offset: ($secOffset+8); size: var + // loop through property decarations and properties + for ($i = 0; $i < $countProperties; ++$i) { +// echo 'Property ', $i,'<br />'; + // offset: ($secOffset+8) + (8 * $i); size: 4; property ID + $id = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i)); +// echo 'ID is ', $id,'<br />'; + + // Use value of property id as appropriate + // offset: 60 + 8 * $i; size: 4; offset from beginning of section (48) + $offset = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i)); + + $type = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + $offset); +// echo 'Type is ', $type,', '; + + // initialize property value + $value = null; + + // extract property value based on property type + switch ($type) { + case 0x02: // 2 byte signed integer + $value = self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset); + break; + case 0x03: // 4 byte signed integer + $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; + case 0x1E: // null-terminated string prepended by dword string length + $byteLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset); + $value = substr($this->_documentSummaryInformation, $secOffset + 8 + $offset, $byteLength); + $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage); + $value = rtrim($value); + break; + case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) + // PHP-Time + $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_documentSummaryInformation, $secOffset + 4 + $offset, 8)); + break; + case 0x47: // Clipboard format + // not needed yet, fix later if necessary + break; + } + + switch ($id) { + case 0x01: // Code Page + $codePage = PHPExcel_Shared_CodePage::NumberToName($value); + break; + case 0x02: // Category + $this->_phpExcel->getProperties()->setCategory($value); + break; + case 0x03: // Presentation Target + // Not supported by PHPExcel + break; + case 0x04: // Bytes + // Not supported by PHPExcel + break; + case 0x05: // Lines + // Not supported by PHPExcel + break; + case 0x06: // Paragraphs + // Not supported by PHPExcel + break; + case 0x07: // Slides + // Not supported by PHPExcel + break; + case 0x08: // Notes + // Not supported by PHPExcel + break; + case 0x09: // Hidden Slides + // Not supported by PHPExcel + break; + case 0x0A: // MM Clips + // Not supported by PHPExcel + break; + case 0x0B: // Scale Crop + // Not supported by PHPExcel + break; + case 0x0C: // Heading Pairs + // Not supported by PHPExcel + break; + case 0x0D: // Titles of Parts + // Not supported by PHPExcel + break; + case 0x0E: // Manager + $this->_phpExcel->getProperties()->setManager($value); + break; + case 0x0F: // Company + $this->_phpExcel->getProperties()->setCompany($value); + break; + case 0x10: // Links up-to-date + // Not supported by PHPExcel + break; + } + } + } + + + /** + * Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record. + */ + private function _readDefault() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); +// $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + } + + + /** + * The NOTE record specifies a comment associated with a particular cell. In Excel 95 (BIFF7) and earlier versions, + * this record stores a note (cell note). This feature was significantly enhanced in Excel 97. + */ + private function _readNote() + { +// echo '<b>Read Cell Annotation</b><br />'; + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly) { + return; + } + + $cellAddress = $this->_readBIFF8CellAddress(substr($recordData, 0, 4)); + if ($this->_version == self::XLS_BIFF8) { + $noteObjID = self::_GetInt2d($recordData, 6); + $noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8)); + $noteAuthor = $noteAuthor['value']; +// echo 'Note Address=', $cellAddress,'<br />'; +// echo 'Note Object ID=', $noteObjID,'<br />'; +// echo 'Note Author=', $noteAuthor,'<hr />'; +// + $this->_cellNotes[$noteObjID] = array( + 'cellRef' => $cellAddress, + 'objectID' => $noteObjID, + 'author' => $noteAuthor + ); + } else { + $extension = false; + if ($cellAddress == '$B$65536') { + // If the address row is -1 and the column is 0, (which translates as $B$65536) then this is a continuation + // note from the previous cell annotation. We're not yet handling this, so annotations longer than the + // max 2048 bytes will probably throw a wobbly. + $row = self::_GetInt2d($recordData, 0); + $extension = true; + $cellAddress = array_pop(array_keys($this->_phpSheet->getComments())); + } +// echo 'Note Address=', $cellAddress,'<br />'; + + $cellAddress = str_replace('$', '', $cellAddress); + $noteLength = self::_GetInt2d($recordData, 4); + $noteText = trim(substr($recordData, 6)); +// echo 'Note Length=', $noteLength,'<br />'; +// echo 'Note Text=', $noteText,'<br />'; + + if ($extension) { + // Concatenate this extension with the currently set comment for the cell + $comment = $this->_phpSheet->getComment($cellAddress); + $commentText = $comment->getText()->getPlainText(); + $comment->setText($this->_parseRichText($commentText.$noteText)); + } else { + // Set comment for the cell + $this->_phpSheet->getComment($cellAddress)->setText($this->_parseRichText($noteText)); +// ->setAuthor($author) + } + } + + } + + + /** + * The TEXT Object record contains the text associated with a cell annotation. + */ + private function _readTextObject() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly) { + return; + } + + // recordData consists of an array of subrecords looking like this: + // grbit: 2 bytes; Option Flags + // rot: 2 bytes; rotation + // cchText: 2 bytes; length of the text (in the first continue record) + // cbRuns: 2 bytes; length of the formatting (in the second continue record) + // followed by the continuation records containing the actual text and formatting + $grbitOpts = self::_GetInt2d($recordData, 0); + $rot = self::_GetInt2d($recordData, 2); + $cchText = self::_GetInt2d($recordData, 10); + $cbRuns = self::_GetInt2d($recordData, 12); + $text = $this->_getSplicedRecordData(); + + $this->_textObjects[$this->textObjRef] = array( + 'text' => substr($text["recordData"], $text["spliceOffsets"][0]+1, $cchText), + 'format' => substr($text["recordData"], $text["spliceOffsets"][1], $cbRuns), + 'alignment' => $grbitOpts, + 'rotation' => $rot + ); + +// echo '<b>_readTextObject()</b><br />'; +// var_dump($this->_textObjects[$this->textObjRef]); +// echo '<br />'; + } + + + /** + * Read BOF + */ + private function _readBof() + { + $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; + + // offset: 2; size: 2; type of the following data + $substreamType = self::_GetInt2d($recordData, 2); + + switch ($substreamType) { + case self::XLS_WorkbookGlobals: + $version = self::_GetInt2d($recordData, 0); + if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) { + throw new PHPExcel_Reader_Exception('Cannot read this Excel file. Version is too old.'); + } + $this->_version = $version; + break; + case self::XLS_Worksheet: + // do not use this version information for anything + // it is unreliable (OpenOffice doc, 5.8), use only version information from the global stream + break; + default: + // substream, e.g. chart + // just skip the entire substream + do { + $code = self::_GetInt2d($this->_data, $this->_pos); + $this->_readDefault(); + } while ($code != self::XLS_Type_EOF && $this->_pos < $this->_dataSize); + break; + } + } + + + /** + * FILEPASS + * + * This record is part of the File Protection Block. It + * contains information about the read/write password of the + * file. All record contents following this record will be + * encrypted. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + * + * The decryption functions and objects used from here on in + * are based on the source of Spreadsheet-ParseExcel: + * http://search.cpan.org/~jmcnamara/Spreadsheet-ParseExcel/ + */ + private function _readFilepass() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + + if ($length != 54) { + throw new PHPExcel_Reader_Exception('Unexpected file pass record length'); + } + + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_verifyPassword('VelvetSweatshop', substr($recordData, 6, 16), substr($recordData, 22, 16), substr($recordData, 38, 16), $this->_md5Ctxt)) { + throw new PHPExcel_Reader_Exception('Decryption password incorrect'); + } + + $this->_encryption = self::MS_BIFF_CRYPTO_RC4; + + // Decryption required from the record after next onwards + $this->_encryptionStartPos = $this->_pos + self::_GetInt2d($this->_data, $this->_pos + 2); + } + + /** + * Make an RC4 decryptor for the given block + * + * @var int $block Block for which to create decrypto + * @var string $valContext MD5 context state + * + * @return PHPExcel_Reader_Excel5_RC4 + */ + private function _makeKey($block, $valContext) + { + $pwarray = str_repeat("\0", 64); + + for ($i = 0; $i < 5; $i++) { + $pwarray[$i] = $valContext[$i]; + } + + $pwarray[5] = chr($block & 0xff); + $pwarray[6] = chr(($block >> 8) & 0xff); + $pwarray[7] = chr(($block >> 16) & 0xff); + $pwarray[8] = chr(($block >> 24) & 0xff); + + $pwarray[9] = "\x80"; + $pwarray[56] = "\x48"; + + $md5 = new PHPExcel_Reader_Excel5_MD5(); + $md5->add($pwarray); + + $s = $md5->getContext(); + return new PHPExcel_Reader_Excel5_RC4($s); + } + + /** + * Verify RC4 file password + * + * @var string $password Password to check + * @var string $docid Document id + * @var string $salt_data Salt data + * @var string $hashedsalt_data Hashed salt data + * @var string &$valContext Set to the MD5 context of the value + * + * @return bool Success + */ + private function _verifyPassword($password, $docid, $salt_data, $hashedsalt_data, &$valContext) + { + $pwarray = str_repeat("\0", 64); + + for ($i = 0; $i < strlen($password); $i++) { + $o = ord(substr($password, $i, 1)); + $pwarray[2 * $i] = chr($o & 0xff); + $pwarray[2 * $i + 1] = chr(($o >> 8) & 0xff); + } + $pwarray[2 * $i] = chr(0x80); + $pwarray[56] = chr(($i << 4) & 0xff); + + $md5 = new PHPExcel_Reader_Excel5_MD5(); + $md5->add($pwarray); + + $mdContext1 = $md5->getContext(); + + $offset = 0; + $keyoffset = 0; + $tocopy = 5; + + $md5->reset(); + + while ($offset != 16) { + if ((64 - $offset) < 5) { + $tocopy = 64 - $offset; + } + for ($i = 0; $i <= $tocopy; $i++) { + $pwarray[$offset + $i] = $mdContext1[$keyoffset + $i]; + } + $offset += $tocopy; + + if ($offset == 64) { + $md5->add($pwarray); + $keyoffset = $tocopy; + $tocopy = 5 - $tocopy; + $offset = 0; + continue; + } + + $keyoffset = 0; + $tocopy = 5; + for ($i = 0; $i < 16; $i++) { + $pwarray[$offset + $i] = $docid[$i]; + } + $offset += 16; + } + + $pwarray[16] = "\x80"; + for ($i = 0; $i < 47; $i++) { + $pwarray[17 + $i] = "\0"; + } + $pwarray[56] = "\x80"; + $pwarray[57] = "\x0a"; + + $md5->add($pwarray); + $valContext = $md5->getContext(); + + $key = $this->_makeKey(0, $valContext); + + $salt = $key->RC4($salt_data); + $hashedsalt = $key->RC4($hashedsalt_data); + + $salt .= "\x80" . str_repeat("\0", 47); + $salt[56] = "\x80"; + + $md5->reset(); + $md5->add($salt); + $mdContext2 = $md5->getContext(); + + return $mdContext2 == $hashedsalt; + } + + /** + * CODEPAGE + * + * This record stores the text encoding used to write byte + * strings, stored as MS Windows code page identifier. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readCodepage() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; code page identifier + $codepage = self::_GetInt2d($recordData, 0); + + $this->_codepage = PHPExcel_Shared_CodePage::NumberToName($codepage); + } + + + /** + * DATEMODE + * + * This record specifies the base date for displaying date + * values. All dates are stored as count of days past this + * base date. In BIFF2-BIFF4 this record is part of the + * Calculation Settings Block. In BIFF5-BIFF8 it is + * stored in the Workbook Globals Substream. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readDateMode() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; 0 = base 1900, 1 = base 1904 + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); + if (ord($recordData{0}) == 1) { + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); + } + } + + + /** + * Read a FONT record + */ + private function _readFont() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + $objFont = new PHPExcel_Style_Font(); + + // offset: 0; size: 2; height of the font (in twips = 1/20 of a point) + $size = self::_GetInt2d($recordData, 0); + $objFont->setSize($size / 20); + + // offset: 2; size: 2; option flags + // bit: 0; mask 0x0001; bold (redundant in BIFF5-BIFF8) + // bit: 1; mask 0x0002; italic + $isItalic = (0x0002 & self::_GetInt2d($recordData, 2)) >> 1; + if ($isItalic) { + $objFont->setItalic(true); + } + + // bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8) + // bit: 3; mask 0x0008; strike + $isStrike = (0x0008 & self::_GetInt2d($recordData, 2)) >> 3; + if ($isStrike) { + $objFont->setStrikethrough(true); + } + + // offset: 4; size: 2; colour index + $colorIndex = self::_GetInt2d($recordData, 4); + $objFont->colorIndex = $colorIndex; + + // offset: 6; size: 2; font weight + $weight = self::_GetInt2d($recordData, 6); + switch ($weight) { + case 0x02BC: + $objFont->setBold(true); + break; + } + + // offset: 8; size: 2; escapement type + $escapement = self::_GetInt2d($recordData, 8); + switch ($escapement) { + case 0x0001: + $objFont->setSuperScript(true); + break; + case 0x0002: + $objFont->setSubScript(true); + break; + } + + // offset: 10; size: 1; underline type + $underlineType = ord($recordData{10}); + switch ($underlineType) { + case 0x00: + break; // no underline + case 0x01: + $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); + break; + case 0x02: + $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE); + break; + case 0x21: + $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING); + break; + case 0x22: + $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING); + break; + } + + // offset: 11; size: 1; font family + // offset: 12; size: 1; character set + // offset: 13; size: 1; not used + // offset: 14; size: var; font name + if ($this->_version == self::XLS_BIFF8) { + $string = self::_readUnicodeStringShort(substr($recordData, 14)); + } else { + $string = $this->_readByteStringShort(substr($recordData, 14)); + } + $objFont->setName($string['value']); + + $this->_objFonts[] = $objFont; + } + } + + + /** + * FORMAT + * + * This record contains information about a number format. + * All FORMAT records occur together in a sequential list. + * + * In BIFF2-BIFF4 other records referencing a FORMAT record + * contain a zero-based index into this list. From BIFF5 on + * the FORMAT record contains the index itself that will be + * used by other records. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readFormat() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + $indexCode = self::_GetInt2d($recordData, 0); + + if ($this->_version == self::XLS_BIFF8) { + $string = self::_readUnicodeStringLong(substr($recordData, 2)); + } else { + // BIFF7 + $string = $this->_readByteStringShort(substr($recordData, 2)); + } + + $formatString = $string['value']; + $this->_formats[$indexCode] = $formatString; + } + } + + + /** + * XF - Extended Format + * + * This record contains formatting information for cells, rows, columns or styles. + * According to http://support.microsoft.com/kb/147732 there are always at least 15 cell style XF + * and 1 cell XF. + * Inspection of Excel files generated by MS Office Excel shows that XF records 0-14 are cell style XF + * and XF record 15 is a cell XF + * We only read the first cell style XF and skip the remaining cell style XF records + * We read all cell XF records. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readXf() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + $objStyle = new PHPExcel_Style(); + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; Index to FONT record + if (self::_GetInt2d($recordData, 0) < 4) { + $fontIndex = self::_GetInt2d($recordData, 0); + } else { + // this has to do with that index 4 is omitted in all BIFF versions for some strange reason + // check the OpenOffice documentation of the FONT record + $fontIndex = self::_GetInt2d($recordData, 0) - 1; + } + $objStyle->setFont($this->_objFonts[$fontIndex]); + + // offset: 2; size: 2; Index to FORMAT record + $numberFormatIndex = self::_GetInt2d($recordData, 2); + if (isset($this->_formats[$numberFormatIndex])) { + // then we have user-defined format code + $numberformat = array('code' => $this->_formats[$numberFormatIndex]); + } elseif (($code = PHPExcel_Style_NumberFormat::builtInFormatCode($numberFormatIndex)) !== '') { + // then we have built-in format code + $numberformat = array('code' => $code); + } else { + // we set the general format code + $numberformat = array('code' => 'General'); + } + $objStyle->getNumberFormat()->setFormatCode($numberformat['code']); + + // offset: 4; size: 2; XF type, cell protection, and parent style XF + // bit 2-0; mask 0x0007; XF_TYPE_PROT + $xfTypeProt = self::_GetInt2d($recordData, 4); + // bit 0; mask 0x01; 1 = cell is locked + $isLocked = (0x01 & $xfTypeProt) >> 0; + $objStyle->getProtection()->setLocked($isLocked ? PHPExcel_Style_Protection::PROTECTION_INHERIT : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); + + // bit 1; mask 0x02; 1 = Formula is hidden + $isHidden = (0x02 & $xfTypeProt) >> 1; + $objStyle->getProtection()->setHidden($isHidden ? PHPExcel_Style_Protection::PROTECTION_PROTECTED : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); + + // bit 2; mask 0x04; 0 = Cell XF, 1 = Cell Style XF + $isCellStyleXf = (0x04 & $xfTypeProt) >> 2; + + // offset: 6; size: 1; Alignment and text break + // bit 2-0, mask 0x07; horizontal alignment + $horAlign = (0x07 & ord($recordData{6})) >> 0; + switch ($horAlign) { + case 0: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_GENERAL); + break; + case 1: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); + break; + case 2: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); + break; + case 3: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); + break; + case 4: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_FILL); + break; + case 5: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY); + break; + case 6: + $objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS); + break; + } + // bit 3, mask 0x08; wrap text + $wrapText = (0x08 & ord($recordData{6})) >> 3; + switch ($wrapText) { + case 0: + $objStyle->getAlignment()->setWrapText(false); + break; + case 1: + $objStyle->getAlignment()->setWrapText(true); + break; + } + // bit 6-4, mask 0x70; vertical alignment + $vertAlign = (0x70 & ord($recordData{6})) >> 4; + switch ($vertAlign) { + case 0: + $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); + break; + case 1: + $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); + break; + case 2: + $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_BOTTOM); + break; + case 3: + $objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_JUSTIFY); + break; + } + + if ($this->_version == self::XLS_BIFF8) { + // offset: 7; size: 1; XF_ROTATION: Text rotation angle + $angle = ord($recordData{7}); + $rotation = 0; + if ($angle <= 90) { + $rotation = $angle; + } elseif ($angle <= 180) { + $rotation = 90 - $angle; + } elseif ($angle == 255) { + $rotation = -165; + } + $objStyle->getAlignment()->setTextRotation($rotation); + + // offset: 8; size: 1; Indentation, shrink to cell size, and text direction + // bit: 3-0; mask: 0x0F; indent level + $indent = (0x0F & ord($recordData{8})) >> 0; + $objStyle->getAlignment()->setIndent($indent); + + // bit: 4; mask: 0x10; 1 = shrink content to fit into cell + $shrinkToFit = (0x10 & ord($recordData{8})) >> 4; + switch ($shrinkToFit) { + case 0: + $objStyle->getAlignment()->setShrinkToFit(false); + break; + case 1: + $objStyle->getAlignment()->setShrinkToFit(true); + break; + } + + // offset: 9; size: 1; Flags used for attribute groups + + // offset: 10; size: 4; Cell border lines and background area + // bit: 3-0; mask: 0x0000000F; left style + if ($bordersLeftStyle = self::_mapBorderStyle((0x0000000F & self::_GetInt4d($recordData, 10)) >> 0)) { + $objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle); + } + // bit: 7-4; mask: 0x000000F0; right style + if ($bordersRightStyle = self::_mapBorderStyle((0x000000F0 & self::_GetInt4d($recordData, 10)) >> 4)) { + $objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle); + } + // bit: 11-8; mask: 0x00000F00; top style + if ($bordersTopStyle = self::_mapBorderStyle((0x00000F00 & self::_GetInt4d($recordData, 10)) >> 8)) { + $objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle); + } + // bit: 15-12; mask: 0x0000F000; bottom style + if ($bordersBottomStyle = self::_mapBorderStyle((0x0000F000 & self::_GetInt4d($recordData, 10)) >> 12)) { + $objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle); + } + // bit: 22-16; mask: 0x007F0000; left color + $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & self::_GetInt4d($recordData, 10)) >> 16; + + // bit: 29-23; mask: 0x3F800000; right color + $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & self::_GetInt4d($recordData, 10)) >> 23; + + // bit: 30; mask: 0x40000000; 1 = diagonal line from top left to right bottom + $diagonalDown = (0x40000000 & self::_GetInt4d($recordData, 10)) >> 30 ? true : false; + + // bit: 31; mask: 0x80000000; 1 = diagonal line from bottom left to top right + $diagonalUp = (0x80000000 & self::_GetInt4d($recordData, 10)) >> 31 ? true : false; + + if ($diagonalUp == false && $diagonalDown == false) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE); + } elseif ($diagonalUp == true && $diagonalDown == false) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP); + } elseif ($diagonalUp == false && $diagonalDown == true) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN); + } elseif ($diagonalUp == true && $diagonalDown == true) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH); + } + + // offset: 14; size: 4; + // bit: 6-0; mask: 0x0000007F; top color + $objStyle->getBorders()->getTop()->colorIndex = (0x0000007F & self::_GetInt4d($recordData, 14)) >> 0; + + // bit: 13-7; mask: 0x00003F80; bottom color + $objStyle->getBorders()->getBottom()->colorIndex = (0x00003F80 & self::_GetInt4d($recordData, 14)) >> 7; + + // bit: 20-14; mask: 0x001FC000; diagonal color + $objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 & self::_GetInt4d($recordData, 14)) >> 14; + + // bit: 24-21; mask: 0x01E00000; diagonal style + if ($bordersDiagonalStyle = self::_mapBorderStyle((0x01E00000 & self::_GetInt4d($recordData, 14)) >> 21)) { + $objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle); + } + + // bit: 31-26; mask: 0xFC000000 fill pattern + if ($fillType = self::_mapFillPattern((0xFC000000 & self::_GetInt4d($recordData, 14)) >> 26)) { + $objStyle->getFill()->setFillType($fillType); + } + // offset: 18; size: 2; pattern and background colour + // bit: 6-0; mask: 0x007F; color index for pattern color + $objStyle->getFill()->startcolorIndex = (0x007F & self::_GetInt2d($recordData, 18)) >> 0; + + // bit: 13-7; mask: 0x3F80; color index for pattern background + $objStyle->getFill()->endcolorIndex = (0x3F80 & self::_GetInt2d($recordData, 18)) >> 7; + } else { + // BIFF5 + + // offset: 7; size: 1; Text orientation and flags + $orientationAndFlags = ord($recordData{7}); + + // bit: 1-0; mask: 0x03; XF_ORIENTATION: Text orientation + $xfOrientation = (0x03 & $orientationAndFlags) >> 0; + switch ($xfOrientation) { + case 0: + $objStyle->getAlignment()->setTextRotation(0); + break; + case 1: + $objStyle->getAlignment()->setTextRotation(-165); + break; + case 2: + $objStyle->getAlignment()->setTextRotation(90); + break; + case 3: + $objStyle->getAlignment()->setTextRotation(-90); + break; + } + + // offset: 8; size: 4; cell border lines and background area + $borderAndBackground = self::_GetInt4d($recordData, 8); + + // bit: 6-0; mask: 0x0000007F; color index for pattern color + $objStyle->getFill()->startcolorIndex = (0x0000007F & $borderAndBackground) >> 0; + + // bit: 13-7; mask: 0x00003F80; color index for pattern background + $objStyle->getFill()->endcolorIndex = (0x00003F80 & $borderAndBackground) >> 7; + + // bit: 21-16; mask: 0x003F0000; fill pattern + $objStyle->getFill()->setFillType(self::_mapFillPattern((0x003F0000 & $borderAndBackground) >> 16)); + + // bit: 24-22; mask: 0x01C00000; bottom line style + $objStyle->getBorders()->getBottom()->setBorderStyle(self::_mapBorderStyle((0x01C00000 & $borderAndBackground) >> 22)); + + // bit: 31-25; mask: 0xFE000000; bottom line color + $objStyle->getBorders()->getBottom()->colorIndex = (0xFE000000 & $borderAndBackground) >> 25; + + // offset: 12; size: 4; cell border lines + $borderLines = self::_GetInt4d($recordData, 12); + + // bit: 2-0; mask: 0x00000007; top line style + $objStyle->getBorders()->getTop()->setBorderStyle(self::_mapBorderStyle((0x00000007 & $borderLines) >> 0)); + + // bit: 5-3; mask: 0x00000038; left line style + $objStyle->getBorders()->getLeft()->setBorderStyle(self::_mapBorderStyle((0x00000038 & $borderLines) >> 3)); + + // bit: 8-6; mask: 0x000001C0; right line style + $objStyle->getBorders()->getRight()->setBorderStyle(self::_mapBorderStyle((0x000001C0 & $borderLines) >> 6)); + + // bit: 15-9; mask: 0x0000FE00; top line color index + $objStyle->getBorders()->getTop()->colorIndex = (0x0000FE00 & $borderLines) >> 9; + + // bit: 22-16; mask: 0x007F0000; left line color index + $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & $borderLines) >> 16; + + // bit: 29-23; mask: 0x3F800000; right line color index + $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & $borderLines) >> 23; + } + + // add cellStyleXf or cellXf and update mapping + if ($isCellStyleXf) { + // we only read one style XF record which is always the first + if ($this->_xfIndex == 0) { + $this->_phpExcel->addCellStyleXf($objStyle); + $this->_mapCellStyleXfIndex[$this->_xfIndex] = 0; + } + } else { + // we read all cell XF records + $this->_phpExcel->addCellXf($objStyle); + $this->_mapCellXfIndex[$this->_xfIndex] = count($this->_phpExcel->getCellXfCollection()) - 1; + } + + // update XF index for when we read next record + ++$this->_xfIndex; + } + } + + + /** + * + */ + private function _readXfExt() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; 0x087D = repeated header + + // offset: 2; size: 2 + + // offset: 4; size: 8; not used + + // offset: 12; size: 2; record version + + // offset: 14; size: 2; index to XF record which this record modifies + $ixfe = self::_GetInt2d($recordData, 14); + + // offset: 16; size: 2; not used + + // offset: 18; size: 2; number of extension properties that follow + $cexts = self::_GetInt2d($recordData, 18); + + // start reading the actual extension data + $offset = 20; + while ($offset < $length) { + // extension type + $extType = self::_GetInt2d($recordData, $offset); + + // extension length + $cb = self::_GetInt2d($recordData, $offset + 2); + + // extension data + $extData = substr($recordData, $offset + 4, $cb); + + switch ($extType) { + case 4: // fill start color + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); + $fill->getStartColor()->setRGB($rgb); + unset($fill->startcolorIndex); // normal color index does not apply, discard + } + } + break; + case 5: // fill end color + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); + $fill->getEndColor()->setRGB($rgb); + unset($fill->endcolorIndex); // normal color index does not apply, discard + } + } + break; + case 7: // border color top + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $top = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getTop(); + $top->getColor()->setRGB($rgb); + unset($top->colorIndex); // normal color index does not apply, discard + } + } + break; + case 8: // border color bottom + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $bottom = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getBottom(); + $bottom->getColor()->setRGB($rgb); + unset($bottom->colorIndex); // normal color index does not apply, discard + } + } + break; + case 9: // border color left + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $left = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getLeft(); + $left->getColor()->setRGB($rgb); + unset($left->colorIndex); // normal color index does not apply, discard + } + } + break; + case 10: // border color right + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $right = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getRight(); + $right->getColor()->setRGB($rgb); + unset($right->colorIndex); // normal color index does not apply, discard + } + } + break; + case 11: // border color diagonal + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $diagonal = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getDiagonal(); + $diagonal->getColor()->setRGB($rgb); + unset($diagonal->colorIndex); // normal color index does not apply, discard + } + } + break; + case 13: // font color + $xclfType = self::_GetInt2d($extData, 0); // color type + $xclrValue = substr($extData, 4, 4); // color value (value based on color type) + + if ($xclfType == 2) { + $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); + + // modify the relevant style property + if (isset($this->_mapCellXfIndex[$ixfe])) { + $font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont(); + $font->getColor()->setRGB($rgb); + unset($font->colorIndex); // normal color index does not apply, discard + } + } + break; + } + + $offset += $cb; + } + } + + } + + + /** + * Read STYLE record + */ + private function _readStyle() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; index to XF record and flag for built-in style + $ixfe = self::_GetInt2d($recordData, 0); + + // bit: 11-0; mask 0x0FFF; index to XF record + $xfIndex = (0x0FFF & $ixfe) >> 0; + + // bit: 15; mask 0x8000; 0 = user-defined style, 1 = built-in style + $isBuiltIn = (bool) ((0x8000 & $ixfe) >> 15); + + if ($isBuiltIn) { + // offset: 2; size: 1; identifier for built-in style + $builtInId = ord($recordData{2}); + + switch ($builtInId) { + case 0x00: + // currently, we are not using this for anything + break; + default: + break; + } + } else { + // user-defined; not supported by PHPExcel + } + } + } + + + /** + * Read PALETTE record + */ + private function _readPalette() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; number of following colors + $nm = self::_GetInt2d($recordData, 0); + + // list of RGB colors + for ($i = 0; $i < $nm; ++$i) { + $rgb = substr($recordData, 2 + 4 * $i, 4); + $this->_palette[] = self::_readRGB($rgb); + } + } + } + + + /** + * SHEET + * + * This record is located in the Workbook Globals + * Substream and represents a sheet inside the workbook. + * One SHEET record is written for each sheet. It stores the + * sheet name and a stream offset to the BOF record of the + * respective Sheet Substream within the Workbook Stream. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readSheet() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // offset: 0; size: 4; absolute stream position of the BOF record of the sheet + // NOTE: not encrypted + $rec_offset = self::_GetInt4d($this->_data, $this->_pos + 4); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 4; size: 1; sheet state + switch (ord($recordData{4})) { + case 0x00: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; + break; + case 0x01: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_HIDDEN; + break; + case 0x02: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN; + break; + default: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; + break; + } + + // offset: 5; size: 1; sheet type + $sheetType = ord($recordData{5}); + + // offset: 6; size: var; sheet name + if ($this->_version == self::XLS_BIFF8) { + $string = self::_readUnicodeStringShort(substr($recordData, 6)); + $rec_name = $string['value']; + } elseif ($this->_version == self::XLS_BIFF7) { + $string = $this->_readByteStringShort(substr($recordData, 6)); + $rec_name = $string['value']; + } + + $this->_sheets[] = array( + 'name' => $rec_name, + 'offset' => $rec_offset, + 'sheetState' => $sheetState, + 'sheetType' => $sheetType, + ); + } + + + /** + * Read EXTERNALBOOK record + */ + private function _readExternalBook() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset within record data + $offset = 0; + + // there are 4 types of records + if (strlen($recordData) > 4) { + // external reference + // offset: 0; size: 2; number of sheet names ($nm) + $nm = self::_GetInt2d($recordData, 0); + $offset += 2; + + // offset: 2; size: var; encoded URL without sheet name (Unicode string, 16-bit length) + $encodedUrlString = self::_readUnicodeStringLong(substr($recordData, 2)); + $offset += $encodedUrlString['size']; + + // offset: var; size: var; list of $nm sheet names (Unicode strings, 16-bit length) + $externalSheetNames = array(); + for ($i = 0; $i < $nm; ++$i) { + $externalSheetNameString = self::_readUnicodeStringLong(substr($recordData, $offset)); + $externalSheetNames[] = $externalSheetNameString['value']; + $offset += $externalSheetNameString['size']; + } + + // store the record data + $this->_externalBooks[] = array( + 'type' => 'external', + 'encodedUrl' => $encodedUrlString['value'], + 'externalSheetNames' => $externalSheetNames, + ); + } elseif (substr($recordData, 2, 2) == pack('CC', 0x01, 0x04)) { + // internal reference + // offset: 0; size: 2; number of sheet in this document + // offset: 2; size: 2; 0x01 0x04 + $this->_externalBooks[] = array( + 'type' => 'internal', + ); + } elseif (substr($recordData, 0, 4) == pack('vCC', 0x0001, 0x01, 0x3A)) { + // add-in function + // offset: 0; size: 2; 0x0001 + $this->_externalBooks[] = array( + 'type' => 'addInFunction', + ); + } elseif (substr($recordData, 0, 2) == pack('v', 0x0000)) { + // DDE links, OLE links + // offset: 0; size: 2; 0x0000 + // offset: 2; size: var; encoded source document name + $this->_externalBooks[] = array( + 'type' => 'DDEorOLE', + ); + } + } + + + /** + * Read EXTERNNAME record. + */ + private function _readExternName() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // external sheet references provided for named cells + if ($this->_version == self::XLS_BIFF8) { + // offset: 0; size: 2; options + $options = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; + + // offset: 4; size: 2; not used + + // offset: 6; size: var + $nameString = self::_readUnicodeStringShort(substr($recordData, 6)); + + // offset: var; size: var; formula data + $offset = 6 + $nameString['size']; + $formula = $this->_getFormulaFromStructure(substr($recordData, $offset)); + + $this->_externalNames[] = array( + 'name' => $nameString['value'], + 'formula' => $formula, + ); + } + } + + + /** + * Read EXTERNSHEET record + */ + private function _readExternSheet() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // external sheet references provided for named cells + if ($this->_version == self::XLS_BIFF8) { + // offset: 0; size: 2; number of following ref structures + $nm = self::_GetInt2d($recordData, 0); + for ($i = 0; $i < $nm; ++$i) { + $this->_ref[] = array( + // offset: 2 + 6 * $i; index to EXTERNALBOOK record + 'externalBookIndex' => self::_GetInt2d($recordData, 2 + 6 * $i), + // offset: 4 + 6 * $i; index to first sheet in EXTERNALBOOK record + 'firstSheetIndex' => self::_GetInt2d($recordData, 4 + 6 * $i), + // offset: 6 + 6 * $i; index to last sheet in EXTERNALBOOK record + 'lastSheetIndex' => self::_GetInt2d($recordData, 6 + 6 * $i), + ); + } + } + } + + + /** + * DEFINEDNAME + * + * This record is part of a Link Table. It contains the name + * and the token array of an internal defined name. Token + * arrays of defined names contain tokens with aberrant + * token classes. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readDefinedName() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_version == self::XLS_BIFF8) { + // retrieves named cells + + // offset: 0; size: 2; option flags + $opts = self::_GetInt2d($recordData, 0); + + // bit: 5; mask: 0x0020; 0 = user-defined name, 1 = built-in-name + $isBuiltInName = (0x0020 & $opts) >> 5; + + // offset: 2; size: 1; keyboard shortcut + + // offset: 3; size: 1; length of the name (character count) + $nlen = ord($recordData{3}); + + // offset: 4; size: 2; size of the formula data (it can happen that this is zero) + // note: there can also be additional data, this is not included in $flen + $flen = self::_GetInt2d($recordData, 4); + + // offset: 8; size: 2; 0=Global name, otherwise index to sheet (1-based) + $scope = self::_GetInt2d($recordData, 8); + + // offset: 14; size: var; Name (Unicode string without length field) + $string = self::_readUnicodeString(substr($recordData, 14), $nlen); + + // offset: var; size: $flen; formula data + $offset = 14 + $string['size']; + $formulaStructure = pack('v', $flen) . substr($recordData, $offset); + + try { + $formula = $this->_getFormulaFromStructure($formulaStructure); + } catch (PHPExcel_Exception $e) { + $formula = ''; + } + + $this->_definedname[] = array( + 'isBuiltInName' => $isBuiltInName, + 'name' => $string['value'], + 'formula' => $formula, + 'scope' => $scope, + ); + } + } + + + /** + * Read MSODRAWINGGROUP record + */ + private function _readMsoDrawingGroup() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + + // get spliced record data + $splicedRecordData = $this->_getSplicedRecordData(); + $recordData = $splicedRecordData['recordData']; + + $this->_drawingGroupData .= $recordData; + } + + + /** + * SST - Shared String Table + * + * This record contains a list of all strings used anywhere + * in the workbook. Each string occurs only once. The + * workbook uses indexes into the list to reference the + * strings. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + **/ + private function _readSst() + { + // offset within (spliced) record data + $pos = 0; + + // get spliced record data + $splicedRecordData = $this->_getSplicedRecordData(); + + $recordData = $splicedRecordData['recordData']; + $spliceOffsets = $splicedRecordData['spliceOffsets']; + + // offset: 0; size: 4; total number of strings in the workbook + $pos += 4; + + // offset: 4; size: 4; number of following strings ($nm) + $nm = self::_GetInt4d($recordData, 4); + $pos += 4; + + // loop through the Unicode strings (16-bit length) + for ($i = 0; $i < $nm; ++$i) { + // number of characters in the Unicode string + $numChars = self::_GetInt2d($recordData, $pos); + $pos += 2; + + // option flags + $optionFlags = ord($recordData{$pos}); + ++$pos; + + // bit: 0; mask: 0x01; 0 = compressed; 1 = uncompressed + $isCompressed = (($optionFlags & 0x01) == 0) ; + + // bit: 2; mask: 0x02; 0 = ordinary; 1 = Asian phonetic + $hasAsian = (($optionFlags & 0x04) != 0); + + // bit: 3; mask: 0x03; 0 = ordinary; 1 = Rich-Text + $hasRichText = (($optionFlags & 0x08) != 0); + + if ($hasRichText) { + // number of Rich-Text formatting runs + $formattingRuns = self::_GetInt2d($recordData, $pos); + $pos += 2; + } + + if ($hasAsian) { + // size of Asian phonetic setting + $extendedRunLength = self::_GetInt4d($recordData, $pos); + $pos += 4; + } + + // expected byte length of character array if not split + $len = ($isCompressed) ? $numChars : $numChars * 2; + + // look up limit position + foreach ($spliceOffsets as $spliceOffset) { + // it can happen that the string is empty, therefore we need + // <= and not just < + if ($pos <= $spliceOffset) { + $limitpos = $spliceOffset; + break; + } + } + + if ($pos + $len <= $limitpos) { + // character array is not split between records + + $retstr = substr($recordData, $pos, $len); + $pos += $len; + } else { + // character array is split between records + + // first part of character array + $retstr = substr($recordData, $pos, $limitpos - $pos); + + $bytesRead = $limitpos - $pos; + + // remaining characters in Unicode string + $charsLeft = $numChars - (($isCompressed) ? $bytesRead : ($bytesRead / 2)); + + $pos = $limitpos; + + // keep reading the characters + while ($charsLeft > 0) { + // look up next limit position, in case the string span more than one continue record + foreach ($spliceOffsets as $spliceOffset) { + if ($pos < $spliceOffset) { + $limitpos = $spliceOffset; + break; + } + } + + // repeated option flags + // OpenOffice.org documentation 5.21 + $option = ord($recordData{$pos}); + ++$pos; + + if ($isCompressed && ($option == 0)) { + // 1st fragment compressed + // this fragment compressed + $len = min($charsLeft, $limitpos - $pos); + $retstr .= substr($recordData, $pos, $len); + $charsLeft -= $len; + $isCompressed = true; + } elseif (!$isCompressed && ($option != 0)) { + // 1st fragment uncompressed + // this fragment uncompressed + $len = min($charsLeft * 2, $limitpos - $pos); + $retstr .= substr($recordData, $pos, $len); + $charsLeft -= $len / 2; + $isCompressed = false; + } elseif (!$isCompressed && ($option == 0)) { + // 1st fragment uncompressed + // this fragment compressed + $len = min($charsLeft, $limitpos - $pos); + for ($j = 0; $j < $len; ++$j) { + $retstr .= $recordData{$pos + $j} . chr(0); + } + $charsLeft -= $len; + $isCompressed = false; + } else { + // 1st fragment compressed + // this fragment uncompressed + $newstr = ''; + for ($j = 0; $j < strlen($retstr); ++$j) { + $newstr .= $retstr[$j] . chr(0); + } + $retstr = $newstr; + $len = min($charsLeft * 2, $limitpos - $pos); + $retstr .= substr($recordData, $pos, $len); + $charsLeft -= $len / 2; + $isCompressed = false; + } + + $pos += $len; + } + } + + // convert to UTF-8 + $retstr = self::_encodeUTF16($retstr, $isCompressed); + + // read additional Rich-Text information, if any + $fmtRuns = array(); + if ($hasRichText) { + // list of formatting runs + for ($j = 0; $j < $formattingRuns; ++$j) { + // first formatted character; zero-based + $charPos = self::_GetInt2d($recordData, $pos + $j * 4); + + // index to font record + $fontIndex = self::_GetInt2d($recordData, $pos + 2 + $j * 4); + + $fmtRuns[] = array( + 'charPos' => $charPos, + 'fontIndex' => $fontIndex, + ); + } + $pos += 4 * $formattingRuns; + } + + // read additional Asian phonetics information, if any + if ($hasAsian) { + // For Asian phonetic settings, we skip the extended string data + $pos += $extendedRunLength; + } + + // store the shared sting + $this->_sst[] = array( + 'value' => $retstr, + 'fmtRuns' => $fmtRuns, + ); + } + + // _getSplicedRecordData() takes care of moving current position in data stream + } + + + /** + * Read PRINTGRIDLINES record + */ + private function _readPrintGridlines() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { + // offset: 0; size: 2; 0 = do not print sheet grid lines; 1 = print sheet gridlines + $printGridlines = (bool) self::_GetInt2d($recordData, 0); + $this->_phpSheet->setPrintGridlines($printGridlines); + } + } + + + /** + * Read DEFAULTROWHEIGHT record + */ + private function _readDefaultRowHeight() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; option flags + // offset: 2; size: 2; default height for unused rows, (twips 1/20 point) + $height = self::_GetInt2d($recordData, 2); + $this->_phpSheet->getDefaultRowDimension()->setRowHeight($height / 20); + } + + + /** + * Read SHEETPR record + */ + private function _readSheetPr() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2 + + // bit: 6; mask: 0x0040; 0 = outline buttons above outline group + $isSummaryBelow = (0x0040 & self::_GetInt2d($recordData, 0)) >> 6; + $this->_phpSheet->setShowSummaryBelow($isSummaryBelow); + + // bit: 7; mask: 0x0080; 0 = outline buttons left of outline group + $isSummaryRight = (0x0080 & self::_GetInt2d($recordData, 0)) >> 7; + $this->_phpSheet->setShowSummaryRight($isSummaryRight); + + // bit: 8; mask: 0x100; 0 = scale printout in percent, 1 = fit printout to number of pages + // this corresponds to radio button setting in page setup dialog in Excel + $this->_isFitToPages = (bool) ((0x0100 & self::_GetInt2d($recordData, 0)) >> 8); + } + + + /** + * Read HORIZONTALPAGEBREAKS record + */ + private function _readHorizontalPageBreaks() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { + // offset: 0; size: 2; number of the following row index structures + $nm = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 6 * $nm; list of $nm row index structures + for ($i = 0; $i < $nm; ++$i) { + $r = self::_GetInt2d($recordData, 2 + 6 * $i); + $cf = self::_GetInt2d($recordData, 2 + 6 * $i + 2); + $cl = self::_GetInt2d($recordData, 2 + 6 * $i + 4); + + // not sure why two column indexes are necessary? + $this->_phpSheet->setBreakByColumnAndRow($cf, $r, PHPExcel_Worksheet::BREAK_ROW); + } + } + } + + + /** + * Read VERTICALPAGEBREAKS record + */ + private function _readVerticalPageBreaks() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { + // offset: 0; size: 2; number of the following column index structures + $nm = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 6 * $nm; list of $nm row index structures + for ($i = 0; $i < $nm; ++$i) { + $c = self::_GetInt2d($recordData, 2 + 6 * $i); + $rf = self::_GetInt2d($recordData, 2 + 6 * $i + 2); + $rl = self::_GetInt2d($recordData, 2 + 6 * $i + 4); + + // not sure why two row indexes are necessary? + $this->_phpSheet->setBreakByColumnAndRow($c, $rf, PHPExcel_Worksheet::BREAK_COLUMN); + } + } + } + + + /** + * Read HEADER record + */ + private function _readHeader() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: var + // realized that $recordData can be empty even when record exists + if ($recordData) { + if ($this->_version == self::XLS_BIFF8) { + $string = self::_readUnicodeStringLong($recordData); + } else { + $string = $this->_readByteStringShort($recordData); + } + + $this->_phpSheet->getHeaderFooter()->setOddHeader($string['value']); + $this->_phpSheet->getHeaderFooter()->setEvenHeader($string['value']); + } + } + } + + + /** + * Read FOOTER record + */ + private function _readFooter() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: var + // realized that $recordData can be empty even when record exists + if ($recordData) { + if ($this->_version == self::XLS_BIFF8) { + $string = self::_readUnicodeStringLong($recordData); + } else { + $string = $this->_readByteStringShort($recordData); + } + $this->_phpSheet->getHeaderFooter()->setOddFooter($string['value']); + $this->_phpSheet->getHeaderFooter()->setEvenFooter($string['value']); + } + } + } + + + /** + * Read HCENTER record + */ + private function _readHcenter() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally + $isHorizontalCentered = (bool) self::_GetInt2d($recordData, 0); + + $this->_phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered); + } + } + + + /** + * Read VCENTER record + */ + private function _readVcenter() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered + $isVerticalCentered = (bool) self::_GetInt2d($recordData, 0); + + $this->_phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered); + } + } + + + /** + * Read LEFTMARGIN record + */ + private function _readLeftMargin() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 8 + $this->_phpSheet->getPageMargins()->setLeft(self::_extractNumber($recordData)); + } + } + + + /** + * Read RIGHTMARGIN record + */ + private function _readRightMargin() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 8 + $this->_phpSheet->getPageMargins()->setRight(self::_extractNumber($recordData)); + } + } + + + /** + * Read TOPMARGIN record + */ + private function _readTopMargin() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 8 + $this->_phpSheet->getPageMargins()->setTop(self::_extractNumber($recordData)); + } + } + + + /** + * Read BOTTOMMARGIN record + */ + private function _readBottomMargin() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 8 + $this->_phpSheet->getPageMargins()->setBottom(self::_extractNumber($recordData)); + } + } + + + /** + * Read PAGESETUP record + */ + private function _readPageSetup() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; paper size + $paperSize = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; scaling factor + $scale = self::_GetInt2d($recordData, 2); + + // offset: 6; size: 2; fit worksheet width to this number of pages, 0 = use as many as needed + $fitToWidth = self::_GetInt2d($recordData, 6); + + // offset: 8; size: 2; fit worksheet height to this number of pages, 0 = use as many as needed + $fitToHeight = self::_GetInt2d($recordData, 8); + + // offset: 10; size: 2; option flags + + // bit: 1; mask: 0x0002; 0=landscape, 1=portrait + $isPortrait = (0x0002 & self::_GetInt2d($recordData, 10)) >> 1; + + // bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init + // when this bit is set, do not use flags for those properties + $isNotInit = (0x0004 & self::_GetInt2d($recordData, 10)) >> 2; + + if (!$isNotInit) { + $this->_phpSheet->getPageSetup()->setPaperSize($paperSize); + switch ($isPortrait) { + case 0: + $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); + break; + case 1: + $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); + break; + } + + $this->_phpSheet->getPageSetup()->setScale($scale, false); + $this->_phpSheet->getPageSetup()->setFitToPage((bool) $this->_isFitToPages); + $this->_phpSheet->getPageSetup()->setFitToWidth($fitToWidth, false); + $this->_phpSheet->getPageSetup()->setFitToHeight($fitToHeight, false); + } + + // offset: 16; size: 8; header margin (IEEE 754 floating-point value) + $marginHeader = self::_extractNumber(substr($recordData, 16, 8)); + $this->_phpSheet->getPageMargins()->setHeader($marginHeader); + + // offset: 24; size: 8; footer margin (IEEE 754 floating-point value) + $marginFooter = self::_extractNumber(substr($recordData, 24, 8)); + $this->_phpSheet->getPageMargins()->setFooter($marginFooter); + } + } + + + /** + * PROTECT - Sheet protection (BIFF2 through BIFF8) + * if this record is omitted, then it also means no sheet protection + */ + private function _readProtect() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly) { + return; + } + + // offset: 0; size: 2; + + // bit 0, mask 0x01; 1 = sheet is protected + $bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0; + $this->_phpSheet->getProtection()->setSheet((bool)$bool); + } + + + /** + * SCENPROTECT + */ + private function _readScenProtect() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly) { + return; + } + + // offset: 0; size: 2; + + // bit: 0, mask 0x01; 1 = scenarios are protected + $bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0; + + $this->_phpSheet->getProtection()->setScenarios((bool)$bool); + } + + + /** + * OBJECTPROTECT + */ + private function _readObjectProtect() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly) { + return; + } + + // offset: 0; size: 2; + + // bit: 0, mask 0x01; 1 = objects are protected + $bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0; + + $this->_phpSheet->getProtection()->setObjects((bool)$bool); + } + + + /** + * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8) + */ + private function _readPassword() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; 16-bit hash value of password + $password = strtoupper(dechex(self::_GetInt2d($recordData, 0))); // the hashed password + $this->_phpSheet->getProtection()->setPassword($password, true); + } + } + + + /** + * Read DEFCOLWIDTH record + */ + private function _readDefColWidth() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; default column width + $width = self::_GetInt2d($recordData, 0); + if ($width != 8) { + $this->_phpSheet->getDefaultColumnDimension()->setWidth($width); + } + } + + + /** + * Read COLINFO record + */ + private function _readColInfo() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; index to first column in range + $fc = self::_GetInt2d($recordData, 0); // first column index + + // offset: 2; size: 2; index to last column in range + $lc = self::_GetInt2d($recordData, 2); // first column index + + // offset: 4; size: 2; width of the column in 1/256 of the width of the zero character + $width = self::_GetInt2d($recordData, 4); + + // offset: 6; size: 2; index to XF record for default column formatting + $xfIndex = self::_GetInt2d($recordData, 6); + + // offset: 8; size: 2; option flags + // bit: 0; mask: 0x0001; 1= columns are hidden + $isHidden = (0x0001 & self::_GetInt2d($recordData, 8)) >> 0; + + // bit: 10-8; mask: 0x0700; outline level of the columns (0 = no outline) + $level = (0x0700 & self::_GetInt2d($recordData, 8)) >> 8; + + // bit: 12; mask: 0x1000; 1 = collapsed + $isCollapsed = (0x1000 & self::_GetInt2d($recordData, 8)) >> 12; + + // offset: 10; size: 2; not used + + for ($i = $fc; $i <= $lc; ++$i) { + if ($lc == 255 || $lc == 256) { + $this->_phpSheet->getDefaultColumnDimension()->setWidth($width / 256); + break; + } + $this->_phpSheet->getColumnDimensionByColumn($i)->setWidth($width / 256); + $this->_phpSheet->getColumnDimensionByColumn($i)->setVisible(!$isHidden); + $this->_phpSheet->getColumnDimensionByColumn($i)->setOutlineLevel($level); + $this->_phpSheet->getColumnDimensionByColumn($i)->setCollapsed($isCollapsed); + $this->_phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + } + } + + + /** + * ROW + * + * This record contains the properties of a single row in a + * sheet. Rows and cells in a sheet are divided into blocks + * of 32 rows. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readRow() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; index of this row + $r = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; index to column of the first cell which is described by a cell record + + // offset: 4; size: 2; index to column of the last cell which is described by a cell record, increased by 1 + + // 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: 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); + } + + // offset: 8; size: 2; not used + + // offset: 10; size: 2; not used in BIFF5-BIFF8 + + // 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: 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: 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; + + if ($hasExplicitFormat) { + $this->_phpSheet->getRowDimension($r + 1)->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + } + } + + + /** + * Read RK record + * This record represents a cell that contains an RK value + * (encoded integer or floating-point value). If a + * floating-point value cannot be encoded to an RK value, + * a NUMBER record will be written. This record replaces the + * record INTEGER written in BIFF2. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readRk() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; index to row + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; index to column + $column = self::_GetInt2d($recordData, 2); + $columnString = PHPExcel_Cell::stringFromColumnIndex($column); + + // Read cell? + 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); + + // offset: 6; size: 4; RK value + $rknum = self::_GetInt4d($recordData, 6); + $numValue = self::_GetIEEE754($rknum); + + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + if (!$this->_readDataOnly) { + // add style information + $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + + // add cell + $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC); + } + } + + + /** + * Read LABELSST record + * This record represents a cell that contains a string. It + * replaces the LABEL record and RSTRING record used in + * BIFF2-BIFF5. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readLabelSst() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; index to row + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; index to column + $column = self::_GetInt2d($recordData, 2); + $columnString = PHPExcel_Cell::stringFromColumnIndex($column); + + // Read cell? + 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); + + // offset: 6; size: 4; index to SST record + $index = self::_GetInt4d($recordData, 6); + + // add cell + if (($fmtRuns = $this->_sst[$index]['fmtRuns']) && !$this->_readDataOnly) { + // then we should treat as rich text + $richText = new PHPExcel_RichText(); + $charPos = 0; + $sstCount = count($this->_sst[$index]['fmtRuns']); + for ($i = 0; $i <= $sstCount; ++$i) { + if (isset($fmtRuns[$i])) { + $text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos); + $charPos = $fmtRuns[$i]['charPos']; + } else { + $text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, PHPExcel_Shared_String::CountCharacters($this->_sst[$index]['value'])); + } + + if (PHPExcel_Shared_String::CountCharacters($text) > 0) { + if ($i == 0) { // first text run, no style + $richText->createText($text); + } else { + $textRun = $richText->createTextRun($text); + if (isset($fmtRuns[$i - 1])) { + if ($fmtRuns[$i - 1]['fontIndex'] < 4) { + $fontIndex = $fmtRuns[$i - 1]['fontIndex']; + } else { + // this has to do with that index 4 is omitted in all BIFF versions for some strange reason + // check the OpenOffice documentation of the FONT record + $fontIndex = $fmtRuns[$i - 1]['fontIndex'] - 1; + } + $textRun->setFont(clone $this->_objFonts[$fontIndex]); + } + } + } + } + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + $cell->setValueExplicit($richText, PHPExcel_Cell_DataType::TYPE_STRING); + } else { + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + $cell->setValueExplicit($this->_sst[$index]['value'], PHPExcel_Cell_DataType::TYPE_STRING); + } + + if (!$this->_readDataOnly) { + // add style information + $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + } + } + + + /** + * Read MULRK record + * This record represents a cell range containing RK value + * cells. All cells are located in the same row. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readMulRk() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; index to row + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; index to first column + $colFirst = self::_GetInt2d($recordData, 2); + + // offset: var; size: 2; index to last column + $colLast = self::_GetInt2d($recordData, $length - 2); + $columns = $colLast - $colFirst + 1; + + // offset within record data + $offset = 4; + + for ($i = 0; $i < $columns; ++$i) { + $columnString = PHPExcel_Cell::stringFromColumnIndex($colFirst + $i); + + // Read cell? + 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); + + // offset: var; size: 4; RK value + $numValue = self::_GetIEEE754(self::_GetInt4d($recordData, $offset + 2)); + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + if (!$this->_readDataOnly) { + // add style + $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + + // add cell value + $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC); + } + + $offset += 6; + } + } + + + /** + * Read NUMBER record + * This record represents a cell that contains a + * floating-point value. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readNumber() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; index to row + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size 2; index to column + $column = self::_GetInt2d($recordData, 2); + $columnString = PHPExcel_Cell::stringFromColumnIndex($column); + + // Read cell? + 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); + + $numValue = self::_extractNumber(substr($recordData, 6, 8)); + + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + if (!$this->_readDataOnly) { + // add cell style + $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + + // add cell value + $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC); + } + } + + + /** + * 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 + * formula cell. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readFormula() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; row index + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; col index + $column = self::_GetInt2d($recordData, 2); + $columnString = PHPExcel_Cell::stringFromColumnIndex($column); + + // offset: 20: size: variable; formula structure + $formulaStructure = substr($recordData, 20); + + // offset: 14: size: 2; option flags, recalculate always, recalculate on open etc. + $options = self::_GetInt2d($recordData, 14); + + // bit: 0; mask: 0x0001; 1 = recalculate always + // bit: 1; mask: 0x0002; 1 = calculate on open + // bit: 2; mask: 0x0008; 1 = part of a shared formula + $isPartOfSharedFormula = (bool) (0x0008 & $options); + + // WARNING: + // We can apparently not rely on $isPartOfSharedFormula. Even when $isPartOfSharedFormula = true + // the formula data may be ordinary formula data, therefore we need to check + // explicitly for the tExp token (0x01) + $isPartOfSharedFormula = $isPartOfSharedFormula && ord($formulaStructure{2}) == 0x01; + + if ($isPartOfSharedFormula) { + // part of shared formula which means there will be a formula with a tExp token and nothing else + // get the base cell, grab tExp token + $baseRow = self::_GetInt2d($formulaStructure, 3); + $baseCol = self::_GetInt2d($formulaStructure, 5); + $this->_baseCell = PHPExcel_Cell::stringFromColumnIndex($baseCol). ($baseRow + 1); + } + + // Read cell? + 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 + $this->_sharedFormulaParts[$columnString . ($row + 1)] = $this->_baseCell; + } + + // offset: 16: size: 4; not used + + // offset: 4; size: 2; XF index + $xfIndex = self::_GetInt2d($recordData, 4); + + // offset: 6; size: 8; result of the formula + if ((ord($recordData{6}) == 0) && (ord($recordData{12}) == 255) && (ord($recordData{13}) == 255)) { + // String formula. Result follows in appended STRING record + $dataType = PHPExcel_Cell_DataType::TYPE_STRING; + + // read possible SHAREDFMLA record + $code = self::_GetInt2d($this->_data, $this->_pos); + if ($code == self::XLS_Type_SHAREDFMLA) { + $this->_readSharedFmla(); + } + + // read STRING record + $value = $this->_readString(); + } elseif ((ord($recordData{6}) == 1) + && (ord($recordData{12}) == 255) + && (ord($recordData{13}) == 255)) { + // Boolean formula. Result is in +2; 0=false, 1=true + $dataType = PHPExcel_Cell_DataType::TYPE_BOOL; + $value = (bool) ord($recordData{8}); + } elseif ((ord($recordData{6}) == 2) + && (ord($recordData{12}) == 255) + && (ord($recordData{13}) == 255)) { + // Error formula. Error code is in +2 + $dataType = PHPExcel_Cell_DataType::TYPE_ERROR; + $value = self::_mapErrorCode(ord($recordData{8})); + } elseif ((ord($recordData{6}) == 3) + && (ord($recordData{12}) == 255) + && (ord($recordData{13}) == 255)) { + // Formula result is a null string + $dataType = PHPExcel_Cell_DataType::TYPE_NULL; + $value = ''; + } else { + // forumla result is a number, first 14 bytes like _NUMBER record + $dataType = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $value = self::_extractNumber(substr($recordData, 6, 8)); + } + + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + if (!$this->_readDataOnly) { + // add cell style + $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + + // store the formula + if (!$isPartOfSharedFormula) { + // not part of shared formula + // add cell value. If we can read formula, populate with formula, otherwise just used cached value + try { + if ($this->_version != self::XLS_BIFF8) { + throw new PHPExcel_Reader_Exception('Not BIFF8. Can only read BIFF8 formulas'); + } + $formula = $this->_getFormulaFromStructure($formulaStructure); // get formula in human language + $cell->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA); + + } catch (PHPExcel_Exception $e) { + $cell->setValueExplicit($value, $dataType); + } + } else { + if ($this->_version == self::XLS_BIFF8) { + // do nothing at this point, formula id added later in the code + } else { + $cell->setValueExplicit($value, $dataType); + } + } + + // store the cached calculated value + $cell->setCalculatedValue($value); + } + } + + + /** + * Read a SHAREDFMLA record. This function just stores the binary shared formula in the reader, + * which usually contains relative references. + * These will be used to construct the formula in each shared formula part after the sheet is read. + */ + private function _readSharedFmla() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0, size: 6; cell range address of the area used by the shared formula, not used for anything + $cellRange = substr($recordData, 0, 6); + $cellRange = $this->_readBIFF5CellRangeAddressFixed($cellRange); // note: even BIFF8 uses BIFF5 syntax + + // offset: 6, size: 1; not used + + // offset: 7, size: 1; number of existing FORMULA records for this shared formula + $no = ord($recordData{7}); + + // offset: 8, size: var; Binary token array of the shared formula + $formula = substr($recordData, 8); + + // at this point we only store the shared formula for later use + $this->_sharedFormulas[$this->_baseCell] = $formula; + } + + + /** + * 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 + * it occurs directly after the FORMULA record + * + * @return string The string contents as UTF-8 + */ + private function _readString() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_version == self::XLS_BIFF8) { + $string = self::_readUnicodeStringLong($recordData); + $value = $string['value']; + } else { + $string = $this->_readByteStringLong($recordData); + $value = $string['value']; + } + + return $value; + } + + + /** + * Read BOOLERR record + * This record represents a Boolean value or error value + * cell. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readBoolErr() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; row index + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; column index + $column = self::_GetInt2d($recordData, 2); + $columnString = PHPExcel_Cell::stringFromColumnIndex($column); + + // Read cell? + 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); + + // offset: 6; size: 1; the boolean value or error value + $boolErr = ord($recordData{6}); + + // offset: 7; size: 1; 0=boolean; 1=error + $isError = ord($recordData{7}); + + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + switch ($isError) { + case 0: // boolean + $value = (bool) $boolErr; + + // add cell value + $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_BOOL); + break; + case 1: // error type + $value = self::_mapErrorCode($boolErr); + + // add cell value + $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_ERROR); + break; + } + + if (!$this->_readDataOnly) { + // add cell style + $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + } + } + + + /** + * Read MULBLANK record + * This record represents a cell range of empty cells. All + * cells are located in the same row + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readMulBlank() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; index to row + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; index to first column + $fc = self::_GetInt2d($recordData, 2); + + // offset: 4; size: 2 x nc; list of indexes to XF records + // add style information + if (!$this->_readDataOnly) { + for ($i = 0; $i < $length / 2 - 3; ++$i) { + $columnString = PHPExcel_Cell::stringFromColumnIndex($fc + $i); + + // Read cell? + 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]); + } + } + } + + // offset: 6; size 2; index to last column (not needed) + } + + + /** + * Read LABEL record + * This record represents a cell that contains a string. In + * BIFF8 it is usually replaced by the LABELSST record. + * Excel still uses this record, if it copies unformatted + * text cells to the clipboard. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readLabel() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; index to row + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; index to column + $column = self::_GetInt2d($recordData, 2); + $columnString = PHPExcel_Cell::stringFromColumnIndex($column); + + // Read cell? + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { + // offset: 4; size: 2; XF index + $xfIndex = self::_GetInt2d($recordData, 4); + + // add cell value + // todo: what if string is very long? continue record + if ($this->_version == self::XLS_BIFF8) { + $string = self::_readUnicodeStringLong(substr($recordData, 6)); + $value = $string['value']; + } else { + $string = $this->_readByteStringLong(substr($recordData, 6)); + $value = $string['value']; + } + $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); + $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); + + if (!$this->_readDataOnly) { + // add cell style + $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + } + } + + + /** + * Read BLANK record + */ + private function _readBlank() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; row index + $row = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; col index + $col = self::_GetInt2d($recordData, 2); + $columnString = PHPExcel_Cell::stringFromColumnIndex($col); + + // Read cell? + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { + // offset: 4; size: 2; XF index + $xfIndex = self::_GetInt2d($recordData, 4); + + // add style information + if (!$this->_readDataOnly) { + $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]); + } + } + + } + + + /** + * Read MSODRAWING record + */ + private function _readMsoDrawing() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + + // get spliced record data + $splicedRecordData = $this->_getSplicedRecordData(); + $recordData = $splicedRecordData['recordData']; + + $this->_drawingData .= $recordData; + } + + + /** + * Read OBJ record + */ + private function _readObj() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly || $this->_version != self::XLS_BIFF8) { + return; + } + + // recordData consists of an array of subrecords looking like this: + // ft: 2 bytes; ftCmo type (0x15) + // cb: 2 bytes; size in bytes of ftCmo data + // ot: 2 bytes; Object Type + // id: 2 bytes; Object id number + // grbit: 2 bytes; Option Flags + // data: var; subrecord data + + // for now, we are just interested in the second subrecord containing the object type + $ftCmoType = self::_GetInt2d($recordData, 0); + $cbCmoSize = self::_GetInt2d($recordData, 2); + $otObjType = self::_GetInt2d($recordData, 4); + $idObjID = self::_GetInt2d($recordData, 6); + $grbitOpts = self::_GetInt2d($recordData, 6); + + $this->_objs[] = array( + 'ftCmoType' => $ftCmoType, + 'cbCmoSize' => $cbCmoSize, + 'otObjType' => $otObjType, + 'idObjID' => $idObjID, + 'grbitOpts' => $grbitOpts + ); + $this->textObjRef = $idObjID; + +// echo '<b>_readObj()</b><br />'; +// var_dump(end($this->_objs)); +// echo '<br />'; + } + + + /** + * Read WINDOW2 record + */ + private function _readWindow2() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; option flags + $options = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; index to first visible row + $firstVisibleRow = self::_GetInt2d($recordData, 2); + + // offset: 4; size: 2; index to first visible colum + $firstVisibleColumn = self::_GetInt2d($recordData, 4); + if ($this->_version === self::XLS_BIFF8) { + // offset: 8; size: 2; not used + // offset: 10; size: 2; cached magnification factor in page break preview (in percent); 0 = Default (60%) + // offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%) + // offset: 14; size: 4; not used + $zoomscaleInPageBreakPreview = self::_GetInt2d($recordData, 10); + if ($zoomscaleInPageBreakPreview === 0) { + $zoomscaleInPageBreakPreview = 60; + } + $zoomscaleInNormalView = self::_GetInt2d($recordData, 12); + if ($zoomscaleInNormalView === 0) { + $zoomscaleInNormalView = 100; + } + } + + // bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines + $showGridlines = (bool) ((0x0002 & $options) >> 1); + $this->_phpSheet->setShowGridlines($showGridlines); + + // bit: 2; mask: 0x0004; 0 = do not show headers, 1 = show headers + $showRowColHeaders = (bool) ((0x0004 & $options) >> 2); + $this->_phpSheet->setShowRowColHeaders($showRowColHeaders); + + // bit: 3; mask: 0x0008; 0 = panes are not frozen, 1 = panes are frozen + $this->_frozen = (bool) ((0x0008 & $options) >> 3); + + // bit: 6; mask: 0x0040; 0 = columns from left to right, 1 = columns from right to left + $this->_phpSheet->setRightToLeft((bool)((0x0040 & $options) >> 6)); + + // bit: 10; mask: 0x0400; 0 = sheet not active, 1 = sheet active + $isActive = (bool) ((0x0400 & $options) >> 10); + if ($isActive) { + $this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet)); + } + + // bit: 11; mask: 0x0800; 0 = normal view, 1 = page break view + $isPageBreakPreview = (bool) ((0x0800 & $options) >> 11); + + //FIXME: set $firstVisibleRow and $firstVisibleColumn + + if ($this->_phpSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT) { + //NOTE: this setting is inferior to page layout view(Excel2007-) + $view = $isPageBreakPreview ? PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW : PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL; + $this->_phpSheet->getSheetView()->setView($view); + if ($this->_version === self::XLS_BIFF8) { + $zoomScale = $isPageBreakPreview ? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView; + $this->_phpSheet->getSheetView()->setZoomScale($zoomScale); + $this->_phpSheet->getSheetView()->setZoomScaleNormal($zoomscaleInNormalView); + } + } + } + + /** + * Read PLV Record(Created by Excel2007 or upper) + */ + private function _readPageLayoutView() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + //var_dump(unpack("vrt/vgrbitFrt/V2reserved/vwScalePLV/vgrbit", $recordData)); + + // offset: 0; size: 2; rt + //->ignore + $rt = self::_GetInt2d($recordData, 0); + // offset: 2; size: 2; grbitfr + //->ignore + $grbitFrt = self::_GetInt2d($recordData, 2); + // offset: 4; size: 8; reserved + //->ignore + + // offset: 12; size 2; zoom scale + $wScalePLV = self::_GetInt2d($recordData, 12); + // offset: 14; size 2; grbit + $grbit = self::_GetInt2d($recordData, 14); + + // decomprise grbit + $fPageLayoutView = $grbit & 0x01; + $fRulerVisible = ($grbit >> 1) & 0x01; //no support + $fWhitespaceHidden = ($grbit >> 3) & 0x01; //no support + + if ($fPageLayoutView === 1) { + $this->_phpSheet->getSheetView()->setView(PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT); + $this->_phpSheet->getSheetView()->setZoomScale($wScalePLV); //set by Excel2007 only if SHEETVIEW_PAGE_LAYOUT + } + //otherwise, we cannot know whether SHEETVIEW_PAGE_LAYOUT or SHEETVIEW_PAGE_BREAK_PREVIEW. + } + + /** + * Read SCL record + */ + private function _readScl() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // offset: 0; size: 2; numerator of the view magnification + $numerator = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; numerator of the view magnification + $denumerator = self::_GetInt2d($recordData, 2); + + // set the zoom scale (in percent) + $this->_phpSheet->getSheetView()->setZoomScale($numerator * 100 / $denumerator); + } + + + /** + * Read PANE record + */ + private function _readPane() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; position of vertical split + $px = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; position of horizontal split + $py = self::_GetInt2d($recordData, 2); + + if ($this->_frozen) { + // frozen panes + $this->_phpSheet->freezePane(PHPExcel_Cell::stringFromColumnIndex($px) . ($py + 1)); + } else { + // unfrozen panes; split windows; not supported by PHPExcel core + } + } + } + + + /** + * Read SELECTION record. There is one such record for each pane in the sheet. + */ + private function _readSelection() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 1; pane identifier + $paneId = ord($recordData{0}); + + // offset: 1; size: 2; index to row of the active cell + $r = self::_GetInt2d($recordData, 1); + + // offset: 3; size: 2; index to column of the active cell + $c = self::_GetInt2d($recordData, 3); + + // offset: 5; size: 2; index into the following cell range list to the + // entry that contains the active cell + $index = self::_GetInt2d($recordData, 5); + + // offset: 7; size: var; cell range address list containing all selected cell ranges + $data = substr($recordData, 7); + $cellRangeAddressList = $this->_readBIFF5CellRangeAddressList($data); // note: also BIFF8 uses BIFF5 syntax + + $selectedCells = $cellRangeAddressList['cellRangeAddresses'][0]; + + // first row '1' + last row '16384' indicates that full column is selected (apparently also in BIFF8!) + if (preg_match('/^([A-Z]+1\:[A-Z]+)16384$/', $selectedCells)) { + $selectedCells = preg_replace('/^([A-Z]+1\:[A-Z]+)16384$/', '${1}1048576', $selectedCells); + } + + // first row '1' + last row '65536' indicates that full column is selected + if (preg_match('/^([A-Z]+1\:[A-Z]+)65536$/', $selectedCells)) { + $selectedCells = preg_replace('/^([A-Z]+1\:[A-Z]+)65536$/', '${1}1048576', $selectedCells); + } + + // first column 'A' + last column 'IV' indicates that full row is selected + if (preg_match('/^(A[0-9]+\:)IV([0-9]+)$/', $selectedCells)) { + $selectedCells = preg_replace('/^(A[0-9]+\:)IV([0-9]+)$/', '${1}XFD${2}', $selectedCells); + } + + $this->_phpSheet->setSelectedCells($selectedCells); + } + } + + + private function _includeCellRangeFiltered($cellRangeAddress) + { + $includeCellRange = true; + if ($this->getReadFilter() !== null) { + $includeCellRange = false; + $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($cellRangeAddress); + $rangeBoundaries[1][0]++; + for ($row = $rangeBoundaries[0][1]; $row <= $rangeBoundaries[1][1]; $row++) { + for ($column = $rangeBoundaries[0][0]; $column != $rangeBoundaries[1][0]; $column++) { + if ($this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle())) { + $includeCellRange = true; + break 2; + } + } + } + } + return $includeCellRange; + } + + + /** + * MERGEDCELLS + * + * This record contains the addresses of merged cell ranges + * in the current sheet. + * + * -- "OpenOffice.org's Documentation of the Microsoft + * Excel File Format" + */ + private function _readMergedCells() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { + $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData); + foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) { + if ((strpos($cellRangeAddress, ':') !== false) && + ($this->_includeCellRangeFiltered($cellRangeAddress))) { + $this->_phpSheet->mergeCells($cellRangeAddress); + } + } + } + } + + + /** + * Read HYPERLINK record + */ + private function _readHyperLink() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer forward to next record + $this->_pos += 4 + $length; + + if (!$this->_readDataOnly) { + // offset: 0; size: 8; cell range address of all cells containing this hyperlink + try { + $cellRange = $this->_readBIFF8CellRangeAddressFixed($recordData, 0, 8); + } catch (PHPExcel_Exception $e) { + return; + } + + // offset: 8, size: 16; GUID of StdLink + + // offset: 24, size: 4; unknown value + + // offset: 28, size: 4; option flags + // bit: 0; mask: 0x00000001; 0 = no link or extant, 1 = file link or URL + $isFileLinkOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 0; + + // bit: 1; mask: 0x00000002; 0 = relative path, 1 = absolute path or URL + $isAbsPathOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 1; + + // bit: 2 (and 4); mask: 0x00000014; 0 = no description + $hasDesc = (0x00000014 & self::_GetInt2d($recordData, 28)) >> 2; + + // bit: 3; mask: 0x00000008; 0 = no text, 1 = has text + $hasText = (0x00000008 & self::_GetInt2d($recordData, 28)) >> 3; + + // bit: 7; mask: 0x00000080; 0 = no target frame, 1 = has target frame + $hasFrame = (0x00000080 & self::_GetInt2d($recordData, 28)) >> 7; + + // bit: 8; mask: 0x00000100; 0 = file link or URL, 1 = UNC path (inc. server name) + $isUNC = (0x00000100 & self::_GetInt2d($recordData, 28)) >> 8; + + // offset within record data + $offset = 32; + + if ($hasDesc) { + // offset: 32; size: var; character count of description text + $dl = self::_GetInt4d($recordData, 32); + // offset: 36; size: var; character array of description text, no Unicode string header, always 16-bit characters, zero terminated + $desc = self::_encodeUTF16(substr($recordData, 36, 2 * ($dl - 1)), false); + $offset += 4 + 2 * $dl; + } + if ($hasFrame) { + $fl = self::_GetInt4d($recordData, $offset); + $offset += 4 + 2 * $fl; + } + + // detect type of hyperlink (there are 4 types) + $hyperlinkType = null; + + if ($isUNC) { + $hyperlinkType = 'UNC'; + } elseif (!$isFileLinkOrUrl) { + $hyperlinkType = 'workbook'; + } elseif (ord($recordData{$offset}) == 0x03) { + $hyperlinkType = 'local'; + } elseif (ord($recordData{$offset}) == 0xE0) { + $hyperlinkType = 'URL'; + } + + switch ($hyperlinkType) { + case 'URL': + // section 5.58.2: Hyperlink containing a URL + // e.g. http://example.org/index.php + + // offset: var; size: 16; GUID of URL Moniker + $offset += 16; + // offset: var; size: 4; size (in bytes) of character array of the URL including trailing zero word + $us = self::_GetInt4d($recordData, $offset); + $offset += 4; + // offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated + $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false); + $nullOffset = strpos($url, 0x00); + if ($nullOffset) { + $url = substr($url, 0, $nullOffset); + } + $url .= $hasText ? '#' : ''; + $offset += $us; + break; + case 'local': + // section 5.58.3: Hyperlink to local file + // examples: + // mydoc.txt + // ../../somedoc.xls#Sheet!A1 + + // offset: var; size: 16; GUI of File Moniker + $offset += 16; + + // offset: var; size: 2; directory up-level count. + $upLevelCount = self::_GetInt2d($recordData, $offset); + $offset += 2; + + // offset: var; size: 4; character count of the shortened file path and name, including trailing zero word + $sl = self::_GetInt4d($recordData, $offset); + $offset += 4; + + // offset: var; size: sl; character array of the shortened file path and name in 8.3-DOS-format (compressed Unicode string) + $shortenedFilePath = substr($recordData, $offset, $sl); + $shortenedFilePath = self::_encodeUTF16($shortenedFilePath, true); + $shortenedFilePath = substr($shortenedFilePath, 0, -1); // remove trailing zero + + $offset += $sl; + + // offset: var; size: 24; unknown sequence + $offset += 24; + + // extended file path + // offset: var; size: 4; size of the following file link field including string lenth mark + $sz = self::_GetInt4d($recordData, $offset); + $offset += 4; + + // only present if $sz > 0 + if ($sz > 0) { + // offset: var; size: 4; size of the character array of the extended file path and name + $xl = self::_GetInt4d($recordData, $offset); + $offset += 4; + + // offset: var; size 2; unknown + $offset += 2; + + // offset: var; size $xl; character array of the extended file path and name. + $extendedFilePath = substr($recordData, $offset, $xl); + $extendedFilePath = self::_encodeUTF16($extendedFilePath, false); + $offset += $xl; + } + + // construct the path + $url = str_repeat('..\\', $upLevelCount); + $url .= ($sz > 0) ? $extendedFilePath : $shortenedFilePath; // use extended path if available + $url .= $hasText ? '#' : ''; + + break; + case 'UNC': + // section 5.58.4: Hyperlink to a File with UNC (Universal Naming Convention) Path + // todo: implement + return; + case 'workbook': + // section 5.58.5: Hyperlink to the Current Workbook + // e.g. Sheet2!B1:C2, stored in text mark field + $url = 'sheet://'; + break; + default: + return; + } + + if ($hasText) { + // offset: var; size: 4; character count of text mark including trailing zero word + $tl = self::_GetInt4d($recordData, $offset); + $offset += 4; + // offset: var; size: var; character array of the text mark without the # sign, no Unicode header, always 16-bit characters, zero-terminated + $text = self::_encodeUTF16(substr($recordData, $offset, 2 * ($tl - 1)), false); + $url .= $text; + } + + // apply the hyperlink to all the relevant cells + foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cellRange) as $coordinate) { + $this->_phpSheet->getCell($coordinate)->getHyperLink()->setUrl($url); + } + } + } + + + /** + * Read DATAVALIDATIONS record + */ + private function _readDataValidations() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer forward to next record + $this->_pos += 4 + $length; + } + + + /** + * Read DATAVALIDATION record + */ + private function _readDataValidation() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer forward to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly) { + return; + } + + // offset: 0; size: 4; Options + $options = self::_GetInt4d($recordData, 0); + + // bit: 0-3; mask: 0x0000000F; type + $type = (0x0000000F & $options) >> 0; + switch ($type) { + case 0x00: + $type = PHPExcel_Cell_DataValidation::TYPE_NONE; + break; + case 0x01: + $type = PHPExcel_Cell_DataValidation::TYPE_WHOLE; + break; + case 0x02: + $type = PHPExcel_Cell_DataValidation::TYPE_DECIMAL; + break; + case 0x03: + $type = PHPExcel_Cell_DataValidation::TYPE_LIST; + break; + case 0x04: + $type = PHPExcel_Cell_DataValidation::TYPE_DATE; + break; + case 0x05: + $type = PHPExcel_Cell_DataValidation::TYPE_TIME; + break; + case 0x06: + $type = PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH; + break; + case 0x07: + $type = PHPExcel_Cell_DataValidation::TYPE_CUSTOM; + break; + } + + // bit: 4-6; mask: 0x00000070; error type + $errorStyle = (0x00000070 & $options) >> 4; + switch ($errorStyle) { + case 0x00: + $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; + break; + case 0x01: + $errorStyle = PHPExcel_Cell_DataValidation::STYLE_WARNING; + break; + case 0x02: + $errorStyle = PHPExcel_Cell_DataValidation::STYLE_INFORMATION; + break; + } + + // bit: 7; mask: 0x00000080; 1= formula is explicit (only applies to list) + // I have only seen cases where this is 1 + $explicitFormula = (0x00000080 & $options) >> 7; + + // bit: 8; mask: 0x00000100; 1= empty cells allowed + $allowBlank = (0x00000100 & $options) >> 8; + + // bit: 9; mask: 0x00000200; 1= suppress drop down arrow in list type validity + $suppressDropDown = (0x00000200 & $options) >> 9; + + // bit: 18; mask: 0x00040000; 1= show prompt box if cell selected + $showInputMessage = (0x00040000 & $options) >> 18; + + // bit: 19; mask: 0x00080000; 1= show error box if invalid values entered + $showErrorMessage = (0x00080000 & $options) >> 19; + + // bit: 20-23; mask: 0x00F00000; condition operator + $operator = (0x00F00000 & $options) >> 20; + switch ($operator) { + case 0x00: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN; + break; + case 0x01: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN; + break; + case 0x02: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_EQUAL; + break; + case 0x03: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL; + break; + case 0x04: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN; + break; + case 0x05: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN; + break; + case 0x06: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL; + break; + case 0x07: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL; + break; + } + + // offset: 4; size: var; title of the prompt box + $offset = 4; + $string = self::_readUnicodeStringLong(substr($recordData, $offset)); + $promptTitle = $string['value'] !== chr(0) ? $string['value'] : ''; + $offset += $string['size']; + + // offset: var; size: var; title of the error box + $string = self::_readUnicodeStringLong(substr($recordData, $offset)); + $errorTitle = $string['value'] !== chr(0) ? $string['value'] : ''; + $offset += $string['size']; + + // offset: var; size: var; text of the prompt box + $string = self::_readUnicodeStringLong(substr($recordData, $offset)); + $prompt = $string['value'] !== chr(0) ? $string['value'] : ''; + $offset += $string['size']; + + // offset: var; size: var; text of the error box + $string = self::_readUnicodeStringLong(substr($recordData, $offset)); + $error = $string['value'] !== chr(0) ? $string['value'] : ''; + $offset += $string['size']; + + // offset: var; size: 2; size of the formula data for the first condition + $sz1 = self::_GetInt2d($recordData, $offset); + $offset += 2; + + // offset: var; size: 2; not used + $offset += 2; + + // offset: var; size: $sz1; formula data for first condition (without size field) + $formula1 = substr($recordData, $offset, $sz1); + $formula1 = pack('v', $sz1) . $formula1; // prepend the length + try { + $formula1 = $this->_getFormulaFromStructure($formula1); + + // in list type validity, null characters are used as item separators + if ($type == PHPExcel_Cell_DataValidation::TYPE_LIST) { + $formula1 = str_replace(chr(0), ',', $formula1); + } + } catch (PHPExcel_Exception $e) { + return; + } + $offset += $sz1; + + // offset: var; size: 2; size of the formula data for the first condition + $sz2 = self::_GetInt2d($recordData, $offset); + $offset += 2; + + // offset: var; size: 2; not used + $offset += 2; + + // offset: var; size: $sz2; formula data for second condition (without size field) + $formula2 = substr($recordData, $offset, $sz2); + $formula2 = pack('v', $sz2) . $formula2; // prepend the length + try { + $formula2 = $this->_getFormulaFromStructure($formula2); + } catch (PHPExcel_Exception $e) { + return; + } + $offset += $sz2; + + // offset: var; size: var; cell range address list with + $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList(substr($recordData, $offset)); + $cellRangeAddresses = $cellRangeAddressList['cellRangeAddresses']; + + foreach ($cellRangeAddresses as $cellRange) { + $stRange = $this->_phpSheet->shrinkRangeToFit($cellRange); + $stRange = PHPExcel_Cell::extractAllCellReferencesInRange($stRange); + foreach ($stRange as $coordinate) { + $objValidation = $this->_phpSheet->getCell($coordinate)->getDataValidation(); + $objValidation->setType($type); + $objValidation->setErrorStyle($errorStyle); + $objValidation->setAllowBlank((bool)$allowBlank); + $objValidation->setShowInputMessage((bool)$showInputMessage); + $objValidation->setShowErrorMessage((bool)$showErrorMessage); + $objValidation->setShowDropDown(!$suppressDropDown); + $objValidation->setOperator($operator); + $objValidation->setErrorTitle($errorTitle); + $objValidation->setError($error); + $objValidation->setPromptTitle($promptTitle); + $objValidation->setPrompt($prompt); + $objValidation->setFormula1($formula1); + $objValidation->setFormula2($formula2); + } + } + } + + /** + * Read SHEETLAYOUT record. Stores sheet tab color information. + */ + private function _readSheetLayout() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // local pointer in record data + $offset = 0; + + if (!$this->_readDataOnly) { + // offset: 0; size: 2; repeated record identifier 0x0862 + + // offset: 2; size: 10; not used + + // offset: 12; size: 4; size of record data + // Excel 2003 uses size of 0x14 (documented), Excel 2007 uses size of 0x28 (not documented?) + $sz = self::_GetInt4d($recordData, 12); + + switch ($sz) { + case 0x14: + // offset: 16; size: 2; color index for sheet tab + $colorIndex = self::_GetInt2d($recordData, 16); + $color = self::_readColor($colorIndex, $this->_palette, $this->_version); + $this->_phpSheet->getTabColor()->setRGB($color['rgb']); + break; + case 0x28: + // TODO: Investigate structure for .xls SHEETLAYOUT record as saved by MS Office Excel 2007 + return; + break; + } + } + } + + + /** + * Read SHEETPROTECTION record (FEATHEADR) + */ + private function _readSheetProtection() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + if ($this->_readDataOnly) { + return; + } + + // offset: 0; size: 2; repeated record header + + // offset: 2; size: 2; FRT cell reference flag (=0 currently) + + // offset: 4; size: 8; Currently not used and set to 0 + + // offset: 12; size: 2; Shared feature type index (2=Enhanced Protetion, 4=SmartTag) + $isf = self::_GetInt2d($recordData, 12); + if ($isf != 2) { + return; + } + + // offset: 14; size: 1; =1 since this is a feat header + + // offset: 15; size: 4; size of rgbHdrSData + + // rgbHdrSData, assume "Enhanced Protection" + // offset: 19; size: 2; option flags + $options = self::_GetInt2d($recordData, 19); + + // bit: 0; mask 0x0001; 1 = user may edit objects, 0 = users must not edit objects + $bool = (0x0001 & $options) >> 0; + $this->_phpSheet->getProtection()->setObjects(!$bool); + + // bit: 1; mask 0x0002; edit scenarios + $bool = (0x0002 & $options) >> 1; + $this->_phpSheet->getProtection()->setScenarios(!$bool); + + // bit: 2; mask 0x0004; format cells + $bool = (0x0004 & $options) >> 2; + $this->_phpSheet->getProtection()->setFormatCells(!$bool); + + // bit: 3; mask 0x0008; format columns + $bool = (0x0008 & $options) >> 3; + $this->_phpSheet->getProtection()->setFormatColumns(!$bool); + + // bit: 4; mask 0x0010; format rows + $bool = (0x0010 & $options) >> 4; + $this->_phpSheet->getProtection()->setFormatRows(!$bool); + + // bit: 5; mask 0x0020; insert columns + $bool = (0x0020 & $options) >> 5; + $this->_phpSheet->getProtection()->setInsertColumns(!$bool); + + // bit: 6; mask 0x0040; insert rows + $bool = (0x0040 & $options) >> 6; + $this->_phpSheet->getProtection()->setInsertRows(!$bool); + + // bit: 7; mask 0x0080; insert hyperlinks + $bool = (0x0080 & $options) >> 7; + $this->_phpSheet->getProtection()->setInsertHyperlinks(!$bool); + + // bit: 8; mask 0x0100; delete columns + $bool = (0x0100 & $options) >> 8; + $this->_phpSheet->getProtection()->setDeleteColumns(!$bool); + + // bit: 9; mask 0x0200; delete rows + $bool = (0x0200 & $options) >> 9; + $this->_phpSheet->getProtection()->setDeleteRows(!$bool); + + // bit: 10; mask 0x0400; select locked cells + $bool = (0x0400 & $options) >> 10; + $this->_phpSheet->getProtection()->setSelectLockedCells(!$bool); + + // bit: 11; mask 0x0800; sort cell range + $bool = (0x0800 & $options) >> 11; + $this->_phpSheet->getProtection()->setSort(!$bool); + + // bit: 12; mask 0x1000; auto filter + $bool = (0x1000 & $options) >> 12; + $this->_phpSheet->getProtection()->setAutoFilter(!$bool); + + // bit: 13; mask 0x2000; pivot tables + $bool = (0x2000 & $options) >> 13; + $this->_phpSheet->getProtection()->setPivotTables(!$bool); + + // bit: 14; mask 0x4000; select unlocked cells + $bool = (0x4000 & $options) >> 14; + $this->_phpSheet->getProtection()->setSelectUnlockedCells(!$bool); + + // 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, + * where it is referred to as FEAT record + */ + private function _readRangeProtection() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // move stream pointer to next record + $this->_pos += 4 + $length; + + // local pointer in record data + $offset = 0; + + if (!$this->_readDataOnly) { + $offset += 12; + + // offset: 12; size: 2; shared feature type, 2 = enhanced protection, 4 = smart tag + $isf = self::_GetInt2d($recordData, 12); + if ($isf != 2) { + // we only read FEAT records of type 2 + return; + } + $offset += 2; + + $offset += 5; + + // offset: 19; size: 2; count of ref ranges this feature is on + $cref = self::_GetInt2d($recordData, 19); + $offset += 2; + + $offset += 6; + + // offset: 27; size: 8 * $cref; list of cell ranges (like in hyperlink record) + $cellRanges = array(); + for ($i = 0; $i < $cref; ++$i) { + try { + $cellRange = $this->_readBIFF8CellRangeAddressFixed(substr($recordData, 27 + 8 * $i, 8)); + } catch (PHPExcel_Exception $e) { + return; + } + $cellRanges[] = $cellRange; + $offset += 8; + } + + // offset: var; size: var; variable length of feature specific data + $rgbFeat = substr($recordData, $offset); + $offset += 4; + + // offset: var; size: 4; the encrypted password (only 16-bit although field is 32-bit) + $wPassword = self::_GetInt4d($recordData, $offset); + $offset += 4; + + // Apply range protection to sheet + if ($cellRanges) { + $this->_phpSheet->protectCells(implode(' ', $cellRanges), strtoupper(dechex($wPassword)), true); + } + } + } + + + /** + * Read IMDATA record + */ + private function _readImData() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + + // get spliced record data + $splicedRecordData = $this->_getSplicedRecordData(); + $recordData = $splicedRecordData['recordData']; + + // UNDER CONSTRUCTION + + // offset: 0; size: 2; image format + $cf = self::_GetInt2d($recordData, 0); + + // offset: 2; size: 2; environment from which the file was written + $env = self::_GetInt2d($recordData, 2); + + // offset: 4; size: 4; length of the image data + $lcb = self::_GetInt4d($recordData, 4); + + // offset: 8; size: var; image data + $iData = substr($recordData, 8); + + switch ($cf) { + case 0x09: // Windows bitmap format + // BITMAPCOREINFO + // 1. BITMAPCOREHEADER + // offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure + $bcSize = self::_GetInt4d($iData, 0); + // var_dump($bcSize); + + // offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels + $bcWidth = self::_GetInt2d($iData, 4); + // var_dump($bcWidth); + + // offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels. + $bcHeight = self::_GetInt2d($iData, 6); + // var_dump($bcHeight); + $ih = imagecreatetruecolor($bcWidth, $bcHeight); + + // offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1 + + // offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24 + $bcBitCount = self::_GetInt2d($iData, 10); + // var_dump($bcBitCount); + + $rgbString = substr($iData, 12); + $rgbTriples = array(); + while (strlen($rgbString) > 0) { + $rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString); + $rgbString = substr($rgbString, 3); + } + $x = 0; + $y = 0; + foreach ($rgbTriples as $i => $rgbTriple) { + $color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']); + imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color); + $x = ($x + 1) % $bcWidth; + $y = $y + floor(($x + 1) / $bcWidth); + } + //imagepng($ih, 'image.png'); + + $drawing = new PHPExcel_Worksheet_Drawing(); + $drawing->setPath($filename); + $drawing->setWorksheet($this->_phpSheet); + break; + case 0x02: // Windows metafile or Macintosh PICT format + case 0x0e: // native format + default: + break; + } + + // _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. + * In this case, we must treat the CONTINUE record as a MSODRAWING record + */ + private function _readContinue() + { + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + // check if we are reading drawing data + // this is in case a free CONTINUE record occurs in other circumstances we are unaware of + if ($this->_drawingData == '') { + // move stream pointer to next record + $this->_pos += 4 + $length; + + return; + } + + // check if record data is at least 4 bytes long, otherwise there is no chance this is MSODRAWING data + if ($length < 4) { + // move stream pointer to next record + $this->_pos += 4 + $length; + + return; + } + + // dirty check to see if CONTINUE record could be a camouflaged MSODRAWING record + // look inside CONTINUE record to see if it looks like a part of an Escher stream + // we know that Escher stream may be split at least at + // 0xF003 MsofbtSpgrContainer + // 0xF004 MsofbtSpContainer + // 0xF00D MsofbtClientTextbox + $validSplitPoints = array(0xF003, 0xF004, 0xF00D); // add identifiers if we find more + + $splitPoint = self::_GetInt2d($recordData, 2); + if (in_array($splitPoint, $validSplitPoints)) { + // get spliced record data (and move pointer to next record) + $splicedRecordData = $this->_getSplicedRecordData(); + $this->_drawingData .= $splicedRecordData['recordData']; + + return; + } + + // move stream pointer to next record + $this->_pos += 4 + $length; + } + + + /** + * Reads a record from current position in data stream and continues reading data as long as CONTINUE + * records are found. Splices the record data pieces and returns the combined string as if record data + * is in one piece. + * Moves to next current position in data stream to start of next record different from a CONtINUE record + * + * @return array + */ + private function _getSplicedRecordData() + { + $data = ''; + $spliceOffsets = array(); + + $i = 0; + $spliceOffsets[0] = 0; + + do { + ++$i; + + // offset: 0; size: 2; identifier + $identifier = self::_GetInt2d($this->_data, $this->_pos); + // offset: 2; size: 2; length + $length = self::_GetInt2d($this->_data, $this->_pos + 2); + $data .= $this->_readRecordData($this->_data, $this->_pos + 4, $length); + + $spliceOffsets[$i] = $spliceOffsets[$i - 1] + $length; + + $this->_pos += 4 + $length; + $nextIdentifier = self::_GetInt2d($this->_data, $this->_pos); + } while ($nextIdentifier == self::XLS_Type_CONTINUE); + + $splicedData = array( + 'recordData' => $data, + 'spliceOffsets' => $spliceOffsets, + ); + + return $splicedData; + + } + + + /** + * Convert formula structure into human readable Excel formula like 'A3+A5*5' + * + * @param string $formulaStructure The complete binary data for the formula + * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas + * @return string Human readable formula + */ + private function _getFormulaFromStructure($formulaStructure, $baseCell = 'A1') + { + // offset: 0; size: 2; size of the following formula data + $sz = self::_GetInt2d($formulaStructure, 0); + + // offset: 2; size: sz + $formulaData = substr($formulaStructure, 2, $sz); + + // for debug: dump the formula data + //echo '<xmp>'; + //echo 'size: ' . $sz . "\n"; + //echo 'the entire formula data: '; + //Debug::dump($formulaData); + //echo "\n----\n"; + + // offset: 2 + sz; size: variable (optional) + if (strlen($formulaStructure) > 2 + $sz) { + $additionalData = substr($formulaStructure, 2 + $sz); + + // for debug: dump the additional data + //echo 'the entire additional data: '; + //Debug::dump($additionalData); + //echo "\n----\n"; + } else { + $additionalData = ''; + } + + return $this->_getFormulaFromData($formulaData, $additionalData, $baseCell); + } + + + /** + * Take formula data and additional data for formula and return human readable formula + * + * @param string $formulaData The binary data for the formula itself + * @param string $additionalData Additional binary data going with the formula + * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas + * @return string Human readable formula + */ + private function _getFormulaFromData($formulaData, $additionalData = '', $baseCell = 'A1') + { + // start parsing the formula data + $tokens = array(); + + while (strlen($formulaData) > 0 and $token = $this->_getNextToken($formulaData, $baseCell)) { + $tokens[] = $token; + $formulaData = substr($formulaData, $token['size']); + + // for debug: dump the token + //var_dump($token); + } + + $formulaString = $this->_createFormulaFromTokens($tokens, $additionalData); + + return $formulaString; + } + + + /** + * Take array of tokens together with additional data for formula and return human readable formula + * + * @param array $tokens + * @param array $additionalData Additional binary data going with the formula + * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas + * @return string Human readable formula + */ + private function _createFormulaFromTokens($tokens, $additionalData) + { + // empty formula? + if (empty($tokens)) { + return ''; + } + + $formulaStrings = array(); + foreach ($tokens as $token) { + // initialize spaces + $space0 = isset($space0) ? $space0 : ''; // spaces before next token, not tParen + $space1 = isset($space1) ? $space1 : ''; // carriage returns before next token, not tParen + $space2 = isset($space2) ? $space2 : ''; // spaces before opening parenthesis + $space3 = isset($space3) ? $space3 : ''; // carriage returns before opening parenthesis + $space4 = isset($space4) ? $space4 : ''; // spaces before closing parenthesis + $space5 = isset($space5) ? $space5 : ''; // carriage returns before closing parenthesis + + switch ($token['name']) { + case 'tAdd': // addition + case 'tConcat': // addition + case 'tDiv': // division + case 'tEQ': // equality + case 'tGE': // greater than or equal + case 'tGT': // greater than + case 'tIsect': // intersection + case 'tLE': // less than or equal + case 'tList': // less than or equal + case 'tLT': // less than + case 'tMul': // multiplication + case 'tNE': // multiplication + case 'tPower': // power + case 'tRange': // range + case 'tSub': // subtraction + $op2 = array_pop($formulaStrings); + $op1 = array_pop($formulaStrings); + $formulaStrings[] = "$op1$space1$space0{$token['data']}$op2"; + unset($space0, $space1); + break; + case 'tUplus': // unary plus + case 'tUminus': // unary minus + $op = array_pop($formulaStrings); + $formulaStrings[] = "$space1$space0{$token['data']}$op"; + unset($space0, $space1); + break; + case 'tPercent': // percent sign + $op = array_pop($formulaStrings); + $formulaStrings[] = "$op$space1$space0{$token['data']}"; + unset($space0, $space1); + break; + case 'tAttrVolatile': // indicates volatile function + case 'tAttrIf': + case 'tAttrSkip': + case 'tAttrChoose': + // token is only important for Excel formula evaluator + // do nothing + break; + case 'tAttrSpace': // space / carriage return + // space will be used when next token arrives, do not alter formulaString stack + switch ($token['data']['spacetype']) { + case 'type0': + $space0 = str_repeat(' ', $token['data']['spacecount']); + break; + case 'type1': + $space1 = str_repeat("\n", $token['data']['spacecount']); + break; + case 'type2': + $space2 = str_repeat(' ', $token['data']['spacecount']); + break; + case 'type3': + $space3 = str_repeat("\n", $token['data']['spacecount']); + break; + case 'type4': + $space4 = str_repeat(' ', $token['data']['spacecount']); + break; + case 'type5': + $space5 = str_repeat("\n", $token['data']['spacecount']); + break; + } + break; + case 'tAttrSum': // SUM function with one parameter + $op = array_pop($formulaStrings); + $formulaStrings[] = "{$space1}{$space0}SUM($op)"; + unset($space0, $space1); + break; + case 'tFunc': // function with fixed number of arguments + case 'tFuncV': // function with variable number of arguments + if ($token['data']['function'] != '') { + // normal function + $ops = array(); // array of operators + for ($i = 0; $i < $token['data']['args']; ++$i) { + $ops[] = array_pop($formulaStrings); + } + $ops = array_reverse($ops); + $formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")"; + unset($space0, $space1); + } else { + // add-in function + $ops = array(); // array of operators + for ($i = 0; $i < $token['data']['args'] - 1; ++$i) { + $ops[] = array_pop($formulaStrings); + } + $ops = array_reverse($ops); + $function = array_pop($formulaStrings); + $formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")"; + unset($space0, $space1); + } + break; + case 'tParen': // parenthesis + $expression = array_pop($formulaStrings); + $formulaStrings[] = "$space3$space2($expression$space5$space4)"; + unset($space2, $space3, $space4, $space5); + break; + case 'tArray': // array constant + $constantArray = self::_readBIFF8ConstantArray($additionalData); + $formulaStrings[] = $space1 . $space0 . $constantArray['value']; + $additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data + unset($space0, $space1); + break; + case 'tMemArea': + // bite off chunk of additional data + $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($additionalData); + $additionalData = substr($additionalData, $cellRangeAddressList['size']); + $formulaStrings[] = "$space1$space0{$token['data']}"; + unset($space0, $space1); + break; + case 'tArea': // cell range address + case 'tBool': // boolean + case 'tErr': // error code + case 'tInt': // integer + case 'tMemErr': + case 'tMemFunc': + case 'tMissArg': + case 'tName': + case 'tNameX': + case 'tNum': // number + case 'tRef': // single cell reference + case 'tRef3d': // 3d cell reference + case 'tArea3d': // 3d cell range reference + case 'tRefN': + case 'tAreaN': + case 'tStr': // string + $formulaStrings[] = "$space1$space0{$token['data']}"; + unset($space0, $space1); + break; + } + } + $formulaString = $formulaStrings[0]; + + // for debug: dump the human readable formula + //echo '----' . "\n"; + //echo 'Formula: ' . $formulaString; + + return $formulaString; + } + + + /** + * Fetch next token from binary formula data + * + * @param string Formula data + * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas + * @return array + * @throws PHPExcel_Reader_Exception + */ + private function _getNextToken($formulaData, $baseCell = 'A1') + { + // offset: 0; size: 1; token id + $id = ord($formulaData[0]); // token id + $name = false; // initialize token name + + switch ($id) { + case 0x03: + $name = 'tAdd'; + $size = 1; + $data = '+'; + break; + case 0x04: + $name = 'tSub'; + $size = 1; + $data = '-'; + break; + case 0x05: + $name = 'tMul'; + $size = 1; + $data = '*'; + break; + case 0x06: + $name = 'tDiv'; + $size = 1; + $data = '/'; + break; + case 0x07: + $name = 'tPower'; + $size = 1; + $data = '^'; + break; + case 0x08: + $name = 'tConcat'; + $size = 1; + $data = '&'; + break; + case 0x09: + $name = 'tLT'; + $size = 1; + $data = '<'; + break; + case 0x0A: + $name = 'tLE'; + $size = 1; + $data = '<='; + break; + case 0x0B: + $name = 'tEQ'; + $size = 1; + $data = '='; + break; + case 0x0C: + $name = 'tGE'; + $size = 1; + $data = '>='; + break; + case 0x0D: + $name = 'tGT'; + $size = 1; + $data = '>'; + break; + case 0x0E: + $name = 'tNE'; + $size = 1; + $data = '<>'; + break; + case 0x0F: + $name = 'tIsect'; + $size = 1; + $data = ' '; + break; + case 0x10: + $name = 'tList'; + $size = 1; + $data = ','; + break; + case 0x11: + $name = 'tRange'; + $size = 1; + $data = ':'; + break; + case 0x12: + $name = 'tUplus'; + $size = 1; + $data = '+'; + break; + case 0x13: + $name = 'tUminus'; + $size = 1; + $data = '-'; + break; + case 0x14: + $name = 'tPercent'; + $size = 1; + $data = '%'; + break; + case 0x15: // parenthesis + $name = 'tParen'; + $size = 1; + $data = null; + break; + case 0x16: // missing argument + $name = 'tMissArg'; + $size = 1; + $data = ''; + break; + case 0x17: // string + $name = 'tStr'; + // offset: 1; size: var; Unicode string, 8-bit string length + $string = self::_readUnicodeStringShort(substr($formulaData, 1)); + $size = 1 + $string['size']; + $data = self::_UTF8toExcelDoubleQuoted($string['value']); + break; + case 0x19: // Special attribute + // offset: 1; size: 1; attribute type flags: + switch (ord($formulaData[1])) { + case 0x01: + $name = 'tAttrVolatile'; + $size = 4; + $data = null; + break; + case 0x02: + $name = 'tAttrIf'; + $size = 4; + $data = null; + break; + case 0x04: + $name = 'tAttrChoose'; + // offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1) + $nc = self::_GetInt2d($formulaData, 2); + // offset: 4; size: 2 * $nc + // offset: 4 + 2 * $nc; size: 2 + $size = 2 * $nc + 6; + $data = null; + break; + case 0x08: + $name = 'tAttrSkip'; + $size = 4; + $data = null; + break; + case 0x10: + $name = 'tAttrSum'; + $size = 4; + $data = null; + break; + case 0x40: + case 0x41: + $name = 'tAttrSpace'; + $size = 4; + // offset: 2; size: 2; space type and position + switch (ord($formulaData[2])) { + case 0x00: + $spacetype = 'type0'; + break; + case 0x01: + $spacetype = 'type1'; + break; + case 0x02: + $spacetype = 'type2'; + break; + case 0x03: + $spacetype = 'type3'; + break; + case 0x04: + $spacetype = 'type4'; + break; + case 0x05: + $spacetype = 'type5'; + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token'); + break; + } + // offset: 3; size: 1; number of inserted spaces/carriage returns + $spacecount = ord($formulaData[3]); + + $data = array('spacetype' => $spacetype, 'spacecount' => $spacecount); + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token'); + break; + } + break; + case 0x1C: // error code + // offset: 1; size: 1; error code + $name = 'tErr'; + $size = 2; + $data = self::_mapErrorCode(ord($formulaData[1])); + break; + case 0x1D: // boolean + // offset: 1; size: 1; 0 = false, 1 = true; + $name = 'tBool'; + $size = 2; + $data = ord($formulaData[1]) ? 'TRUE' : 'FALSE'; + break; + case 0x1E: // integer + // offset: 1; size: 2; unsigned 16-bit integer + $name = 'tInt'; + $size = 3; + $data = self::_GetInt2d($formulaData, 1); + break; + case 0x1F: // number + // offset: 1; size: 8; + $name = 'tNum'; + $size = 9; + $data = self::_extractNumber(substr($formulaData, 1)); + $data = str_replace(',', '.', (string)$data); // in case non-English locale + break; + case 0x20: // array constant + case 0x40: + case 0x60: + // offset: 1; size: 7; not used + $name = 'tArray'; + $size = 8; + $data = null; + break; + case 0x21: // function with fixed number of arguments + case 0x41: + case 0x61: + $name = 'tFunc'; + $size = 3; + // offset: 1; size: 2; index to built-in sheet function + switch (self::_GetInt2d($formulaData, 1)) { + case 2: + $function = 'ISNA'; + $args = 1; + break; + case 3: + $function = 'ISERROR'; + $args = 1; + break; + case 10: + $function = 'NA'; + $args = 0; + break; + case 15: + $function = 'SIN'; + $args = 1; + break; + case 16: + $function = 'COS'; + $args = 1; + break; + case 17: + $function = 'TAN'; + $args = 1; + break; + case 18: + $function = 'ATAN'; + $args = 1; + break; + case 19: + $function = 'PI'; + $args = 0; + break; + case 20: + $function = 'SQRT'; + $args = 1; + break; + case 21: + $function = 'EXP'; + $args = 1; + break; + case 22: + $function = 'LN'; + $args = 1; + break; + case 23: + $function = 'LOG10'; + $args = 1; + break; + case 24: + $function = 'ABS'; + $args = 1; + break; + case 25: + $function = 'INT'; + $args = 1; + break; + case 26: + $function = 'SIGN'; + $args = 1; + break; + case 27: + $function = 'ROUND'; + $args = 2; + break; + case 30: + $function = 'REPT'; + $args = 2; + break; + case 31: + $function = 'MID'; + $args = 3; + break; + case 32: + $function = 'LEN'; + $args = 1; + break; + case 33: + $function = 'VALUE'; + $args = 1; + break; + case 34: + $function = 'TRUE'; + $args = 0; + break; + case 35: + $function = 'FALSE'; + $args = 0; + break; + case 38: + $function = 'NOT'; + $args = 1; + break; + case 39: + $function = 'MOD'; + $args = 2; + break; + case 40: + $function = 'DCOUNT'; + $args = 3; + break; + case 41: + $function = 'DSUM'; + $args = 3; + break; + case 42: + $function = 'DAVERAGE'; + $args = 3; + break; + case 43: + $function = 'DMIN'; + $args = 3; + break; + case 44: + $function = 'DMAX'; + $args = 3; + break; + case 45: + $function = 'DSTDEV'; + $args = 3; + break; + case 48: + $function = 'TEXT'; + $args = 2; + break; + case 61: + $function = 'MIRR'; + $args = 3; + break; + case 63: + $function = 'RAND'; + $args = 0; + break; + case 65: + $function = 'DATE'; + $args = 3; + break; + case 66: + $function = 'TIME'; + $args = 3; + break; + case 67: + $function = 'DAY'; + $args = 1; + break; + case 68: + $function = 'MONTH'; + $args = 1; + break; + case 69: + $function = 'YEAR'; + $args = 1; + break; + case 71: + $function = 'HOUR'; + $args = 1; + break; + case 72: + $function = 'MINUTE'; + $args = 1; + break; + case 73: + $function = 'SECOND'; + $args = 1; + break; + case 74: + $function = 'NOW'; + $args = 0; + break; + case 75: + $function = 'AREAS'; + $args = 1; + break; + case 76: + $function = 'ROWS'; + $args = 1; + break; + case 77: + $function = 'COLUMNS'; + $args = 1; + break; + case 83: + $function = 'TRANSPOSE'; + $args = 1; + break; + case 86: + $function = 'TYPE'; + $args = 1; + break; + case 97: + $function = 'ATAN2'; + $args = 2; + break; + case 98: + $function = 'ASIN'; + $args = 1; + break; + case 99: + $function = 'ACOS'; + $args = 1; + break; + case 105: + $function = 'ISREF'; + $args = 1; + break; + case 111: + $function = 'CHAR'; + $args = 1; + break; + case 112: + $function = 'LOWER'; + $args = 1; + break; + case 113: + $function = 'UPPER'; + $args = 1; + break; + case 114: + $function = 'PROPER'; + $args = 1; + break; + case 117: + $function = 'EXACT'; + $args = 2; + break; + case 118: + $function = 'TRIM'; + $args = 1; + break; + case 119: + $function = 'REPLACE'; + $args = 4; + break; + case 121: + $function = 'CODE'; + $args = 1; + break; + case 126: + $function = 'ISERR'; + $args = 1; + break; + case 127: + $function = 'ISTEXT'; + $args = 1; + break; + case 128: + $function = 'ISNUMBER'; + $args = 1; + break; + case 129: + $function = 'ISBLANK'; + $args = 1; + break; + case 130: + $function = 'T'; + $args = 1; + break; + case 131: + $function = 'N'; + $args = 1; + break; + case 140: + $function = 'DATEVALUE'; + $args = 1; + break; + case 141: + $function = 'TIMEVALUE'; + $args = 1; + break; + case 142: + $function = 'SLN'; + $args = 3; + break; + case 143: + $function = 'SYD'; + $args = 4; + break; + case 162: + $function = 'CLEAN'; + $args = 1; + break; + case 163: + $function = 'MDETERM'; + $args = 1; + break; + case 164: + $function = 'MINVERSE'; + $args = 1; + break; + case 165: + $function = 'MMULT'; + $args = 2; + break; + case 184: + $function = 'FACT'; + $args = 1; + break; + case 189: + $function = 'DPRODUCT'; + $args = 3; + break; + case 190: + $function = 'ISNONTEXT'; + $args = 1; + break; + case 195: + $function = 'DSTDEVP'; + $args = 3; + break; + case 196: + $function = 'DVARP'; + $args = 3; + break; + case 198: + $function = 'ISLOGICAL'; + $args = 1; + break; + case 199: + $function = 'DCOUNTA'; + $args = 3; + break; + case 207: + $function = 'REPLACEB'; + $args = 4; + break; + case 210: + $function = 'MIDB'; + $args = 3; + break; + case 211: + $function = 'LENB'; + $args = 1; + break; + case 212: + $function = 'ROUNDUP'; + $args = 2; + break; + case 213: + $function = 'ROUNDDOWN'; + $args = 2; + break; + case 214: + $function = 'ASC'; + $args = 1; + break; + case 215: + $function = 'DBCS'; + $args = 1; + break; + case 221: + $function = 'TODAY'; + $args = 0; + break; + case 229: + $function = 'SINH'; + $args = 1; + break; + case 230: + $function = 'COSH'; + $args = 1; + break; + case 231: + $function = 'TANH'; + $args = 1; + break; + case 232: + $function = 'ASINH'; + $args = 1; + break; + case 233: + $function = 'ACOSH'; + $args = 1; + break; + case 234: + $function = 'ATANH'; + $args = 1; + break; + case 235: + $function = 'DGET'; + $args = 3; + break; + case 244: + $function = 'INFO'; + $args = 1; + break; + case 252: + $function = 'FREQUENCY'; + $args = 2; + break; + case 261: + $function = 'ERROR.TYPE'; + $args = 1; + break; + case 271: + $function = 'GAMMALN'; + $args = 1; + break; + case 273: + $function = 'BINOMDIST'; + $args = 4; + break; + case 274: + $function = 'CHIDIST'; + $args = 2; + break; + case 275: + $function = 'CHIINV'; + $args = 2; + break; + case 276: + $function = 'COMBIN'; + $args = 2; + break; + case 277: + $function = 'CONFIDENCE'; + $args = 3; + break; + case 278: + $function = 'CRITBINOM'; + $args = 3; + break; + case 279: + $function = 'EVEN'; + $args = 1; + break; + case 280: + $function = 'EXPONDIST'; + $args = 3; + break; + case 281: + $function = 'FDIST'; + $args = 3; + break; + case 282: + $function = 'FINV'; + $args = 3; + break; + case 283: + $function = 'FISHER'; + $args = 1; + break; + case 284: + $function = 'FISHERINV'; + $args = 1; + break; + case 285: + $function = 'FLOOR'; + $args = 2; + break; + case 286: + $function = 'GAMMADIST'; + $args = 4; + break; + case 287: + $function = 'GAMMAINV'; + $args = 3; + break; + case 288: + $function = 'CEILING'; + $args = 2; + break; + case 289: + $function = 'HYPGEOMDIST'; + $args = 4; + break; + case 290: + $function = 'LOGNORMDIST'; + $args = 3; + break; + case 291: + $function = 'LOGINV'; + $args = 3; + break; + case 292: + $function = 'NEGBINOMDIST'; + $args = 3; + break; + case 293: + $function = 'NORMDIST'; + $args = 4; + break; + case 294: + $function = 'NORMSDIST'; + $args = 1; + break; + case 295: + $function = 'NORMINV'; + $args = 3; + break; + case 296: + $function = 'NORMSINV'; + $args = 1; + break; + case 297: + $function = 'STANDARDIZE'; + $args = 3; + break; + case 298: + $function = 'ODD'; + $args = 1; + break; + case 299: + $function = 'PERMUT'; + $args = 2; + break; + case 300: + $function = 'POISSON'; + $args = 3; + break; + case 301: + $function = 'TDIST'; + $args = 3; + break; + case 302: + $function = 'WEIBULL'; + $args = 4; + break; + case 303: + $function = 'SUMXMY2'; + $args = 2; + break; + case 304: + $function = 'SUMX2MY2'; + $args = 2; + break; + case 305: + $function = 'SUMX2PY2'; + $args = 2; + break; + case 306: + $function = 'CHITEST'; + $args = 2; + break; + case 307: + $function = 'CORREL'; + $args = 2; + break; + case 308: + $function = 'COVAR'; + $args = 2; + break; + case 309: + $function = 'FORECAST'; + $args = 3; + break; + case 310: + $function = 'FTEST'; + $args = 2; + break; + case 311: + $function = 'INTERCEPT'; + $args = 2; + break; + case 312: + $function = 'PEARSON'; + $args = 2; + break; + case 313: + $function = 'RSQ'; + $args = 2; + break; + case 314: + $function = 'STEYX'; + $args = 2; + break; + case 315: + $function = 'SLOPE'; + $args = 2; + break; + case 316: + $function = 'TTEST'; + $args = 4; + break; + case 325: + $function = 'LARGE'; + $args = 2; + break; + case 326: + $function = 'SMALL'; + $args = 2; + break; + case 327: + $function = 'QUARTILE'; + $args = 2; + break; + case 328: + $function = 'PERCENTILE'; + $args = 2; + break; + case 331: + $function = 'TRIMMEAN'; + $args = 2; + break; + case 332: + $function = 'TINV'; + $args = 2; + break; + case 337: + $function = 'POWER'; + $args = 2; + break; + case 342: + $function = 'RADIANS'; + $args = 1; + break; + case 343: + $function = 'DEGREES'; + $args = 1; + break; + case 346: + $function = 'COUNTIF'; + $args = 2; + break; + case 347: + $function = 'COUNTBLANK'; + $args = 1; + break; + case 350: + $function = 'ISPMT'; + $args = 4; + break; + case 351: + $function = 'DATEDIF'; + $args = 3; + break; + case 352: + $function = 'DATESTRING'; + $args = 1; + break; + case 353: + $function = 'NUMBERSTRING'; + $args = 2; + break; + case 360: + $function = 'PHONETIC'; + $args = 1; + break; + case 368: + $function = 'BAHTTEXT'; + $args = 1; + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); + break; + } + $data = array('function' => $function, 'args' => $args); + break; + case 0x22: // function with variable number of arguments + case 0x42: + case 0x62: + $name = 'tFuncV'; + $size = 4; + // offset: 1; size: 1; number of arguments + $args = ord($formulaData[1]); + // offset: 2: size: 2; index to built-in sheet function + $index = self::_GetInt2d($formulaData, 2); + switch ($index) { + case 0: + $function = 'COUNT'; + break; + case 1: + $function = 'IF'; + break; + case 4: + $function = 'SUM'; + break; + case 5: + $function = 'AVERAGE'; + break; + case 6: + $function = 'MIN'; + break; + case 7: + $function = 'MAX'; + break; + case 8: + $function = 'ROW'; + break; + case 9: + $function = 'COLUMN'; + break; + case 11: + $function = 'NPV'; + break; + case 12: + $function = 'STDEV'; + break; + case 13: + $function = 'DOLLAR'; + break; + case 14: + $function = 'FIXED'; + break; + case 28: + $function = 'LOOKUP'; + break; + case 29: + $function = 'INDEX'; + break; + case 36: + $function = 'AND'; + break; + case 37: + $function = 'OR'; + break; + case 46: + $function = 'VAR'; + break; + case 49: + $function = 'LINEST'; + break; + case 50: + $function = 'TREND'; + break; + case 51: + $function = 'LOGEST'; + break; + case 52: + $function = 'GROWTH'; + break; + case 56: + $function = 'PV'; + break; + case 57: + $function = 'FV'; + break; + case 58: + $function = 'NPER'; + break; + case 59: + $function = 'PMT'; + break; + case 60: + $function = 'RATE'; + break; + case 62: + $function = 'IRR'; + break; + case 64: + $function = 'MATCH'; + break; + case 70: + $function = 'WEEKDAY'; + break; + case 78: + $function = 'OFFSET'; + break; + case 82: + $function = 'SEARCH'; + break; + case 100: + $function = 'CHOOSE'; + break; + case 101: + $function = 'HLOOKUP'; + break; + case 102: + $function = 'VLOOKUP'; + break; + case 109: + $function = 'LOG'; + break; + case 115: + $function = 'LEFT'; + break; + case 116: + $function = 'RIGHT'; + break; + case 120: + $function = 'SUBSTITUTE'; + break; + case 124: + $function = 'FIND'; + break; + case 125: + $function = 'CELL'; + break; + case 144: + $function = 'DDB'; + break; + case 148: + $function = 'INDIRECT'; + break; + case 167: + $function = 'IPMT'; + break; + case 168: + $function = 'PPMT'; + break; + case 169: + $function = 'COUNTA'; + break; + case 183: + $function = 'PRODUCT'; + break; + case 193: + $function = 'STDEVP'; + break; + case 194: + $function = 'VARP'; + break; + case 197: + $function = 'TRUNC'; + break; + case 204: + $function = 'USDOLLAR'; + break; + case 205: + $function = 'FINDB'; + break; + case 206: + $function = 'SEARCHB'; + break; + case 208: + $function = 'LEFTB'; + break; + case 209: + $function = 'RIGHTB'; + break; + case 216: + $function = 'RANK'; + break; + case 219: + $function = 'ADDRESS'; + break; + case 220: + $function = 'DAYS360'; + break; + case 222: + $function = 'VDB'; + break; + case 227: + $function = 'MEDIAN'; + break; + case 228: + $function = 'SUMPRODUCT'; + break; + case 247: + $function = 'DB'; + break; + case 255: + $function = ''; + break; + case 269: + $function = 'AVEDEV'; + break; + case 270: + $function = 'BETADIST'; + break; + case 272: + $function = 'BETAINV'; + break; + case 317: + $function = 'PROB'; + break; + case 318: + $function = 'DEVSQ'; + break; + case 319: + $function = 'GEOMEAN'; + break; + case 320: + $function = 'HARMEAN'; + break; + case 321: + $function = 'SUMSQ'; + break; + case 322: + $function = 'KURT'; + break; + case 323: + $function = 'SKEW'; + break; + case 324: + $function = 'ZTEST'; + break; + case 329: + $function = 'PERCENTRANK'; + break; + case 330: + $function = 'MODE'; + break; + case 336: + $function = 'CONCATENATE'; + break; + case 344: + $function = 'SUBTOTAL'; + break; + case 345: + $function = 'SUMIF'; + break; + case 354: + $function = 'ROMAN'; + break; + case 358: + $function = 'GETPIVOTDATA'; + break; + case 359: + $function = 'HYPERLINK'; + break; + case 361: + $function = 'AVERAGEA'; + break; + case 362: + $function = 'MAXA'; + break; + case 363: + $function = 'MINA'; + break; + case 364: + $function = 'STDEVPA'; + break; + case 365: + $function = 'VARPA'; + break; + case 366: + $function = 'STDEVA'; + break; + case 367: + $function = 'VARA'; + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); + break; + } + $data = array('function' => $function, 'args' => $args); + break; + case 0x23: // index to defined name + case 0x43: + case 0x63: + $name = 'tName'; + $size = 5; + // offset: 1; size: 2; one-based index to definedname record + $definedNameIndex = self::_GetInt2d($formulaData, 1) - 1; + // offset: 2; size: 2; not used + $data = $this->_definedname[$definedNameIndex]['name']; + break; + case 0x24: // single cell reference e.g. A5 + case 0x44: + case 0x64: + $name = 'tRef'; + $size = 5; + $data = $this->_readBIFF8CellAddress(substr($formulaData, 1, 4)); + break; + case 0x25: // cell range reference to cells in the same sheet (2d) + case 0x45: + case 0x65: + $name = 'tArea'; + $size = 9; + $data = $this->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8)); + break; + case 0x26: // Constant reference sub-expression + case 0x46: + case 0x66: + $name = 'tMemArea'; + // offset: 1; size: 4; not used + // offset: 5; size: 2; size of the following subexpression + $subSize = self::_GetInt2d($formulaData, 5); + $size = 7 + $subSize; + $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); + break; + case 0x27: // Deleted constant reference sub-expression + case 0x47: + case 0x67: + $name = 'tMemErr'; + // offset: 1; size: 4; not used + // offset: 5; size: 2; size of the following subexpression + $subSize = self::_GetInt2d($formulaData, 5); + $size = 7 + $subSize; + $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); + break; + case 0x29: // Variable reference sub-expression + case 0x49: + case 0x69: + $name = 'tMemFunc'; + // offset: 1; size: 2; size of the following sub-expression + $subSize = self::_GetInt2d($formulaData, 1); + $size = 3 + $subSize; + $data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize)); + break; + case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places + case 0x4C: + case 0x6C: + $name = 'tRefN'; + $size = 5; + $data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell); + break; + case 0x2D: // Relative 2d range reference + case 0x4D: + case 0x6D: + $name = 'tAreaN'; + $size = 9; + $data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell); + break; + case 0x39: // External name + case 0x59: + case 0x79: + $name = 'tNameX'; + $size = 7; + // offset: 1; size: 2; index to REF entry in EXTERNSHEET record + // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record + $index = self::_GetInt2d($formulaData, 3); + // assume index is to EXTERNNAME record + $data = $this->_externalNames[$index - 1]['name']; + // offset: 5; size: 2; not used + break; + case 0x3A: // 3d reference to cell + case 0x5A: + case 0x7A: + $name = 'tRef3d'; + $size = 7; + + try { + // offset: 1; size: 2; index to REF entry + $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); + // offset: 3; size: 4; cell address + $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4)); + + $data = "$sheetRange!$cellAddress"; + } catch (PHPExcel_Exception $e) { + // deleted sheet reference + $data = '#REF!'; + } + break; + case 0x3B: // 3d reference to cell range + case 0x5B: + case 0x7B: + $name = 'tArea3d'; + $size = 11; + + try { + // offset: 1; size: 2; index to REF entry + $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); + // offset: 3; size: 8; cell address + $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8)); + + $data = "$sheetRange!$cellRangeAddress"; + } catch (PHPExcel_Exception $e) { + // deleted sheet reference + $data = '#REF!'; + } + break; + // Unknown cases // don't know how to deal with + default: + throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); + break; + } + + return array( + 'id' => $id, + 'name' => $name, + 'size' => $size, + 'data' => $data, + ); + } + + + /** + * Reads a cell address in BIFF8 e.g. 'A2' or '$A$2' + * section 3.3.4 + * + * @param string $cellAddressStructure + * @return string + */ + private function _readBIFF8CellAddress($cellAddressStructure) + { + // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) + $row = self::_GetInt2d($cellAddressStructure, 0) + 1; + + // offset: 2; size: 2; index to column or column offset + relative flags + // bit: 7-0; mask 0x00FF; column index + $column = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($cellAddressStructure, 2)); + + // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) + if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { + $column = '$' . $column; + } + // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) + if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { + $row = '$' . $row; + } + + 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 + * section 3.3.4 + * + * @param string $cellAddressStructure + * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas + * @return string + */ + private function _readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1') + { + list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell); + $baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1; + + // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) + $rowIndex = self::_GetInt2d($cellAddressStructure, 0); + $row = self::_GetInt2d($cellAddressStructure, 0) + 1; + + // offset: 2; size: 2; index to column or column offset + relative flags + // bit: 7-0; mask 0x00FF; column index + $colIndex = 0x00FF & self::_GetInt2d($cellAddressStructure, 2); + + // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) + if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { + $column = PHPExcel_Cell::stringFromColumnIndex($colIndex); + $column = '$' . $column; + } else { + $colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256; + $column = PHPExcel_Cell::stringFromColumnIndex($baseCol + $colIndex); + } + + // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) + if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { + $row = '$' . $row; + } else { + $rowIndex = ($rowIndex <= 32767) ? $rowIndex : $rowIndex - 65536; + $row = $baseRow + $rowIndex; + } + + return $column . $row; + } + + + /** + * Reads a cell range address in BIFF5 e.g. 'A2:B6' or 'A1' + * always fixed range + * section 2.5.14 + * + * @param string $subData + * @return string + * @throws PHPExcel_Reader_Exception + */ + private function _readBIFF5CellRangeAddressFixed($subData) + { + // offset: 0; size: 2; index to first row + $fr = self::_GetInt2d($subData, 0) + 1; + + // offset: 2; size: 2; index to last row + $lr = self::_GetInt2d($subData, 2) + 1; + + // offset: 4; size: 1; index to first column + $fc = ord($subData{4}); + + // offset: 5; size: 1; index to last column + $lc = ord($subData{5}); + + // check values + if ($fr > $lr || $fc > $lc) { + throw new PHPExcel_Reader_Exception('Not a cell range address'); + } + + // column index to letter + $fc = PHPExcel_Cell::stringFromColumnIndex($fc); + $lc = PHPExcel_Cell::stringFromColumnIndex($lc); + + if ($fr == $lr and $fc == $lc) { + return "$fc$fr"; + } + return "$fc$fr:$lc$lr"; + } + + + /** + * Reads a cell range address in BIFF8 e.g. 'A2:B6' or 'A1' + * always fixed range + * section 2.5.14 + * + * @param string $subData + * @return string + * @throws PHPExcel_Reader_Exception + */ + private function _readBIFF8CellRangeAddressFixed($subData) + { + // offset: 0; size: 2; index to first row + $fr = self::_GetInt2d($subData, 0) + 1; + + // offset: 2; size: 2; index to last row + $lr = self::_GetInt2d($subData, 2) + 1; + + // offset: 4; size: 2; index to first column + $fc = self::_GetInt2d($subData, 4); + + // offset: 6; size: 2; index to last column + $lc = self::_GetInt2d($subData, 6); + + // check values + if ($fr > $lr || $fc > $lc) { + throw new PHPExcel_Reader_Exception('Not a cell range address'); + } + + // column index to letter + $fc = PHPExcel_Cell::stringFromColumnIndex($fc); + $lc = PHPExcel_Cell::stringFromColumnIndex($lc); + + if ($fr == $lr and $fc == $lc) { + return "$fc$fr"; + } + 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 + * section 3.3.4 + * + * @param string $subData + * @return string + */ + private function _readBIFF8CellRangeAddress($subData) + { + // todo: if cell range is just a single cell, should this funciton + // not just return e.g. 'A1' and not 'A1:A1' ? + + // offset: 0; size: 2; index to first row (0... 65535) (or offset (-32768... 32767)) + $fr = self::_GetInt2d($subData, 0) + 1; + + // offset: 2; size: 2; index to last row (0... 65535) (or offset (-32768... 32767)) + $lr = self::_GetInt2d($subData, 2) + 1; + + // 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: 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; + } + + // 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: 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; + } + + 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 + * section 3.3.4 + * + * @param string $subData + * @param string $baseCell Base cell + * @return string Cell range address + */ + private function _readBIFF8CellRangeAddressB($subData, $baseCell = 'A1') + { + list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell); + $baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1; + + // TODO: if cell range is just a single cell, should this funciton + // not just return e.g. 'A1' and not 'A1:A1' ? + + // offset: 0; size: 2; first row + $frIndex = self::_GetInt2d($subData, 0); // adjust below + + // offset: 2; size: 2; relative index to first row (0... 65535) should be treated as offset (-32768... 32767) + $lrIndex = self::_GetInt2d($subData, 2); // adjust below + + // offset: 4; size: 2; first column with relative/absolute flags + + // 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: 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); + $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; + } + + return "$fc$fr:$lc$lr"; + } + + + /** + * Read BIFF8 cell range address list + * section 2.5.15 + * + * @param string $subData + * @return array + */ + private function _readBIFF8CellRangeAddressList($subData) + { + $cellRangeAddresses = array(); + + // offset: 0; size: 2; number of the following cell range addresses + $nm = self::_GetInt2d($subData, 0); + + $offset = 2; + // offset: 2; size: 8 * $nm; list of $nm (fixed) cell range addresses + for ($i = 0; $i < $nm; ++$i) { + $cellRangeAddresses[] = $this->_readBIFF8CellRangeAddressFixed(substr($subData, $offset, 8)); + $offset += 8; + } + + return array( + 'size' => 2 + 8 * $nm, + 'cellRangeAddresses' => $cellRangeAddresses, + ); + } + + + /** + * Read BIFF5 cell range address list + * section 2.5.15 + * + * @param string $subData + * @return array + */ + private function _readBIFF5CellRangeAddressList($subData) + { + $cellRangeAddresses = array(); + + // offset: 0; size: 2; number of the following cell range addresses + $nm = self::_GetInt2d($subData, 0); + + $offset = 2; + // offset: 2; size: 6 * $nm; list of $nm (fixed) cell range addresses + for ($i = 0; $i < $nm; ++$i) { + $cellRangeAddresses[] = $this->_readBIFF5CellRangeAddressFixed(substr($subData, $offset, 6)); + $offset += 6; + } + + return array( + 'size' => 2 + 6 * $nm, + 'cellRangeAddresses' => $cellRangeAddresses, + ); + } + + + /** + * 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 + * It can also happen that the REF structure uses the -1 (FFFF) code to indicate deleted sheets, + * in which case an PHPExcel_Reader_Exception is thrown + * + * @param int $index + * @return string|false + * @throws PHPExcel_Reader_Exception + */ + private function _readSheetRangeByRefIndex($index) + { + if (isset($this->_ref[$index])) { + $type = $this->_externalBooks[$this->_ref[$index]['externalBookIndex']]['type']; + + switch ($type) { + case 'internal': + // check if we have a deleted 3d reference + if ($this->_ref[$index]['firstSheetIndex'] == 0xFFFF or $this->_ref[$index]['lastSheetIndex'] == 0xFFFF) { + throw new PHPExcel_Reader_Exception('Deleted sheet reference'); + } + + // we have normal sheet range (collapsed or uncollapsed) + $firstSheetName = $this->_sheets[$this->_ref[$index]['firstSheetIndex']]['name']; + $lastSheetName = $this->_sheets[$this->_ref[$index]['lastSheetIndex']]['name']; + + if ($firstSheetName == $lastSheetName) { + // collapsed sheet range + $sheetRange = $firstSheetName; + } else { + $sheetRange = "$firstSheetName:$lastSheetName"; + } + + // escape the single-quotes + $sheetRange = str_replace("'", "''", $sheetRange); + + // if there are special characters, we need to enclose the range in single-quotes + // todo: check if we have identified the whole set of special characters + // it seems that the following characters are not accepted for sheet names + // and we may assume that they are not present: []*/:\? + if (preg_match("/[ !\"@#£$%&{()}<>=+'|^,;-]/", $sheetRange)) { + $sheetRange = "'$sheetRange'"; + } + + return $sheetRange; + break; + default: + // TODO: external sheet support + throw new PHPExcel_Reader_Exception('Excel5 reader only supports internal sheets in fomulas'); + break; + } + } + return false; + } + + + /** + * read BIFF8 constant value array from array data + * returns e.g. array('value' => '{1,2;3,4}', 'size' => 40} + * section 2.5.8 + * + * @param string $arrayData + * @return array + */ + private static function _readBIFF8ConstantArray($arrayData) + { + // offset: 0; size: 1; number of columns decreased by 1 + $nc = ord($arrayData[0]); + + // offset: 1; size: 2; number of rows decreased by 1 + $nr = self::_GetInt2d($arrayData, 1); + $size = 3; // initialize + $arrayData = substr($arrayData, 3); + + // offset: 3; size: var; list of ($nc + 1) * ($nr + 1) constant values + $matrixChunks = array(); + for ($r = 1; $r <= $nr + 1; ++$r) { + $items = array(); + for ($c = 1; $c <= $nc + 1; ++$c) { + $constant = self::_readBIFF8Constant($arrayData); + $items[] = $constant['value']; + $arrayData = substr($arrayData, $constant['size']); + $size += $constant['size']; + } + $matrixChunks[] = implode(',', $items); // looks like e.g. '1,"hello"' + } + $matrix = '{' . implode(';', $matrixChunks) . '}'; + + return array( + 'value' => $matrix, + 'size' => $size, + ); + } + + + /** + * read BIFF8 constant value which may be 'Empty Value', 'Number', 'String Value', 'Boolean Value', 'Error Value' + * section 2.5.7 + * returns e.g. array('value' => '5', 'size' => 9) + * + * @param string $valueData + * @return array + */ + private static function _readBIFF8Constant($valueData) + { + // offset: 0; size: 1; identifier for type of constant + $identifier = ord($valueData[0]); + + switch ($identifier) { + case 0x00: // empty constant (what is this?) + $value = ''; + $size = 9; + break; + case 0x01: // number + // offset: 1; size: 8; IEEE 754 floating-point value + $value = self::_extractNumber(substr($valueData, 1, 8)); + $size = 9; + break; + case 0x02: // string value + // offset: 1; size: var; Unicode string, 16-bit string length + $string = self::_readUnicodeStringLong(substr($valueData, 1)); + $value = '"' . $string['value'] . '"'; + $size = 1 + $string['size']; + break; + case 0x04: // boolean + // offset: 1; size: 1; 0 = FALSE, 1 = TRUE + if (ord($valueData[1])) { + $value = 'TRUE'; + } else { + $value = 'FALSE'; + } + $size = 9; + break; + case 0x10: // error code + // offset: 1; size: 1; error code + $value = self::_mapErrorCode(ord($valueData[1])); + $size = 9; + break; + } + return array( + 'value' => $value, + 'size' => $size, + ); + } + + + /** + * Extract RGB color + * OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.4 + * + * @param string $rgb Encoded RGB value (4 bytes) + * @return array + */ + private static function _readRGB($rgb) + { + // offset: 0; size 1; Red component + $r = ord($rgb{0}); + + // offset: 1; size: 1; Green component + $g = ord($rgb{1}); + + // offset: 2; size: 1; Blue component + $b = ord($rgb{2}); + + // HEX notation, e.g. 'FF00FC' + $rgb = sprintf('%02X%02X%02X', $r, $g, $b); + + return array('rgb' => $rgb); + } + + + /** + * Read byte string (8-bit string length) + * OpenOffice documentation: 2.5.2 + * + * @param string $subData + * @return array + */ + private function _readByteStringShort($subData) + { + // offset: 0; size: 1; length of the string (character count) + $ln = ord($subData[0]); + + // offset: 1: size: var; character array (8-bit characters) + $value = $this->_decodeCodepage(substr($subData, 1, $ln)); + + return array( + 'value' => $value, + 'size' => 1 + $ln, // size in bytes of data structure + ); + } + + + /** + * Read byte string (16-bit string length) + * OpenOffice documentation: 2.5.2 + * + * @param string $subData + * @return array + */ + private function _readByteStringLong($subData) + { + // offset: 0; size: 2; length of the string (character count) + $ln = self::_GetInt2d($subData, 0); + + // offset: 2: size: var; character array (8-bit characters) + $value = $this->_decodeCodepage(substr($subData, 2)); + + //return $string; + return array( + 'value' => $value, + 'size' => 2 + $ln, // size in bytes of data structure + ); + } + + + /** + * Extracts an Excel Unicode short string (8-bit string length) + * OpenOffice documentation: 2.5.3 + * function will automatically find out where the Unicode string ends. + * + * @param string $subData + * @return array + */ + private static function _readUnicodeStringShort($subData) + { + $value = ''; + + // offset: 0: size: 1; length of the string (character count) + $characterCount = ord($subData[0]); + + $string = self::_readUnicodeString(substr($subData, 1), $characterCount); + + // add 1 for the string length + $string['size'] += 1; + + return $string; + } + + + /** + * Extracts an Excel Unicode long string (16-bit string length) + * OpenOffice documentation: 2.5.3 + * this function is under construction, needs to support rich text, and Asian phonetic settings + * + * @param string $subData + * @return array + */ + private static function _readUnicodeStringLong($subData) + { + $value = ''; + + // offset: 0: size: 2; length of the string (character count) + $characterCount = self::_GetInt2d($subData, 0); + + $string = self::_readUnicodeString(substr($subData, 2), $characterCount); + + // add 2 for the string length + $string['size'] += 2; + + 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 + * OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.3 + * + * @param string $subData + * @param int $characterCount + * @return array + */ + private static function _readUnicodeString($subData, $characterCount) + { + $value = ''; + + // offset: 0: size: 1; option flags + // bit: 0; mask: 0x01; character compression (0 = compressed 8-bit, 1 = uncompressed 16-bit) + $isCompressed = !((0x01 & ord($subData[0])) >> 0); + + // bit: 2; mask: 0x04; Asian phonetic settings + $hasAsian = (0x04) & ord($subData[0]) >> 2; + + // bit: 3; mask: 0x08; Rich-Text settings + $hasRichText = (0x08) & ord($subData[0]) >> 3; + + // offset: 1: size: var; character array + // this offset assumes richtext and Asian phonetic settings are off which is generally wrong + // needs to be fixed + $value = self::_encodeUTF16(substr($subData, 1, $isCompressed ? $characterCount : 2 * $characterCount), $isCompressed); + + return array( + 'value' => $value, + 'size' => $isCompressed ? 1 + $characterCount : 1 + 2 * $characterCount, // the size in bytes including the option flags + ); + } + + + /** + * Convert UTF-8 string to string surounded by double quotes. Used for explicit string tokens in formulas. + * Example: hello"world --> "hello""world" + * + * @param string $value UTF-8 encoded string + * @return string + */ + private static function _UTF8toExcelDoubleQuoted($value) + { + return '"' . str_replace('"', '""', $value) . '"'; + } + + + /** + * Reads first 8 bytes of a string and return IEEE 754 float + * + * @param string $data Binary string that is at least 8 bytes long + * @return float + */ + private static function _extractNumber($data) + { + $rknumhigh = self::_GetInt4d($data, 4); + $rknumlow = self::_GetInt4d($data, 0); + $sign = ($rknumhigh & 0x80000000) >> 31; + $exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023; + $mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); + $mantissalow1 = ($rknumlow & 0x80000000) >> 31; + $mantissalow2 = ($rknumlow & 0x7fffffff); + $value = $mantissa / pow(2, (20 - $exp)); + + if ($mantissalow1 != 0) { + $value += 1 / pow(2, (21 - $exp)); + } + + $value += $mantissalow2 / pow(2, (52 - $exp)); + if ($sign) { + $value *= -1; + } + + return $value; + } + + + private static function _GetIEEE754($rknum) + { + if (($rknum & 0x02) != 0) { + $value = $rknum >> 2; + } 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 + // of the 64 bit floating point value. The other 34 bits are assumed + // to be 0 so we use the upper 30 bits of $rknum as follows... + $sign = ($rknum & 0x80000000) >> 31; + $exp = ($rknum & 0x7ff00000) >> 20; + $mantissa = (0x100000 | ($rknum & 0x000ffffc)); + $value = $mantissa / pow(2, (20- ($exp - 1023))); + if ($sign) { + $value = -1 * $value; + } + //end of changes by mmp + } + if (($rknum & 0x01) != 0) { + $value /= 100; + } + return $value; + } + + + /** + * Get UTF-8 string from (compressed or uncompressed) UTF-16 string + * + * @param string $string + * @param bool $compressed + * @return string + */ + private static function _encodeUTF16($string, $compressed = '') + { + if ($compressed) { + $string = self::_uncompressByteString($string); + } + + return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE'); + } + + + /** + * Convert UTF-16 string in compressed notation to uncompressed form. Only used for BIFF8. + * + * @param string $string + * @return string + */ + private static function _uncompressByteString($string) + { + $uncompressedString = ''; + $strLen = strlen($string); + for ($i = 0; $i < $strLen; ++$i) { + $uncompressedString .= $string[$i] . "\0"; + } + + return $uncompressedString; + } + + + /** + * Convert string to UTF-8. Only used for BIFF5. + * + * @param string $string + * @return string + */ + private function _decodeCodepage($string) + { + return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage); + } + + + /** + * Read 16-bit unsigned integer + * + * @param string $data + * @param int $pos + * @return int + */ + public static function _GetInt2d($data, $pos) + { + return ord($data[$pos]) | (ord($data[$pos+1]) << 8); + } + + + /** + * Read 32-bit signed integer + * + * @param string $data + * @param int $pos + * @return int + */ + public static function _GetInt4d($data, $pos) + { + // FIX: represent numbers correctly on 64-bit system + // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 + // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems + $_or_24 = ord($data[$pos + 3]); + if ($_or_24 >= 128) { + // negative number + $_ord_24 = -abs((256 - $_or_24) << 24); + } else { + $_ord_24 = ($_or_24 & 127) << 24; + } + return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24; + } + + + /** + * Read color + * + * @param int $color Indexed color + * @param array $palette Color palette + * @return array RGB color value, example: array('rgb' => 'FF0000') + */ + private static function _readColor($color, $palette, $version) + { + if ($color <= 0x07 || $color >= 0x40) { + // special built-in color + return self::_mapBuiltInColor($color); + } elseif (isset($palette) && isset($palette[$color - 8])) { + // palette color, color index 0x08 maps to pallete index 0 + return $palette[$color - 8]; + } else { + // default color table + if ($version == self::XLS_BIFF8) { + return self::_mapColor($color); + } else { + // BIFF5 + return self::_mapColorBIFF5($color); + } + } + + return $color; + } + + + /** + * Map border style + * OpenOffice documentation: 2.5.11 + * + * @param int $index + * @return string + */ + private static function _mapBorderStyle($index) + { + switch ($index) { + case 0x00: + return PHPExcel_Style_Border::BORDER_NONE; + case 0x01: + return PHPExcel_Style_Border::BORDER_THIN; + case 0x02: + return PHPExcel_Style_Border::BORDER_MEDIUM; + case 0x03: + return PHPExcel_Style_Border::BORDER_DASHED; + case 0x04: + return PHPExcel_Style_Border::BORDER_DOTTED; + case 0x05: + return PHPExcel_Style_Border::BORDER_THICK; + case 0x06: + return PHPExcel_Style_Border::BORDER_DOUBLE; + case 0x07: + return PHPExcel_Style_Border::BORDER_HAIR; + case 0x08: + return PHPExcel_Style_Border::BORDER_MEDIUMDASHED; + case 0x09: + return PHPExcel_Style_Border::BORDER_DASHDOT; + case 0x0A: + return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; + case 0x0B: + return PHPExcel_Style_Border::BORDER_DASHDOTDOT; + case 0x0C: + return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; + case 0x0D: + return PHPExcel_Style_Border::BORDER_SLANTDASHDOT; + default: + return PHPExcel_Style_Border::BORDER_NONE; + } + } + + + /** + * Get fill pattern from index + * OpenOffice documentation: 2.5.12 + * + * @param int $index + * @return string + */ + private static function _mapFillPattern($index) + { + switch ($index) { + case 0x00: + return PHPExcel_Style_Fill::FILL_NONE; + case 0x01: + return PHPExcel_Style_Fill::FILL_SOLID; + case 0x02: + return PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; + case 0x03: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; + case 0x04: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; + case 0x05: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; + case 0x06: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; + case 0x07: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; + case 0x08: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; + case 0x09: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; + case 0x0A: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; + case 0x0B: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; + case 0x0C: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; + case 0x0D: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; + case 0x0E: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; + case 0x0F: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; + case 0x10: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; + case 0x11: + return PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; + case 0x12: + return PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; + default: + return PHPExcel_Style_Fill::FILL_NONE; + } + } + + + /** + * Map error code, e.g. '#N/A' + * + * @param int $subData + * @return string + */ + private static function _mapErrorCode($subData) + { + switch ($subData) { + case 0x00: + return '#NULL!'; + break; + case 0x07: + return '#DIV/0!'; + break; + case 0x0F: + return '#VALUE!'; + break; + case 0x17: + return '#REF!'; + break; + case 0x1D: + return '#NAME?'; + break; + case 0x24: + return '#NUM!'; + break; + case 0x2A: + return '#N/A'; + break; + default: + return false; + } + } + + + /** + * Map built-in color to RGB value + * + * @param int $color Indexed color + * @return array + */ + private static function _mapBuiltInColor($color) + { + switch ($color) { + case 0x00: + return array('rgb' => '000000'); + case 0x01: + return array('rgb' => 'FFFFFF'); + case 0x02: + return array('rgb' => 'FF0000'); + case 0x03: + return array('rgb' => '00FF00'); + case 0x04: + return array('rgb' => '0000FF'); + case 0x05: + return array('rgb' => 'FFFF00'); + case 0x06: + return array('rgb' => 'FF00FF'); + case 0x07: + return array('rgb' => '00FFFF'); + case 0x40: + return array('rgb' => '000000'); // system window text color + case 0x41: + return array('rgb' => 'FFFFFF'); // system window background color + default: + return array('rgb' => '000000'); + } + } + + + /** + * Map color array from BIFF5 built-in color index + * + * @param int $subData + * @return array + */ + private static function _mapColorBIFF5($subData) + { + switch ($subData) { + case 0x08: + return array('rgb' => '000000'); + case 0x09: + return array('rgb' => 'FFFFFF'); + case 0x0A: + return array('rgb' => 'FF0000'); + case 0x0B: + return array('rgb' => '00FF00'); + case 0x0C: + return array('rgb' => '0000FF'); + case 0x0D: + return array('rgb' => 'FFFF00'); + case 0x0E: + return array('rgb' => 'FF00FF'); + case 0x0F: + return array('rgb' => '00FFFF'); + case 0x10: + return array('rgb' => '800000'); + case 0x11: + return array('rgb' => '008000'); + case 0x12: + return array('rgb' => '000080'); + case 0x13: + return array('rgb' => '808000'); + case 0x14: + return array('rgb' => '800080'); + case 0x15: + return array('rgb' => '008080'); + case 0x16: + return array('rgb' => 'C0C0C0'); + case 0x17: + return array('rgb' => '808080'); + case 0x18: + return array('rgb' => '8080FF'); + case 0x19: + return array('rgb' => '802060'); + case 0x1A: + return array('rgb' => 'FFFFC0'); + case 0x1B: + return array('rgb' => 'A0E0F0'); + case 0x1C: + return array('rgb' => '600080'); + case 0x1D: + return array('rgb' => 'FF8080'); + case 0x1E: + return array('rgb' => '0080C0'); + case 0x1F: + return array('rgb' => 'C0C0FF'); + case 0x20: + return array('rgb' => '000080'); + case 0x21: + return array('rgb' => 'FF00FF'); + case 0x22: + return array('rgb' => 'FFFF00'); + case 0x23: + return array('rgb' => '00FFFF'); + case 0x24: + return array('rgb' => '800080'); + case 0x25: + return array('rgb' => '800000'); + case 0x26: + return array('rgb' => '008080'); + case 0x27: + return array('rgb' => '0000FF'); + case 0x28: + return array('rgb' => '00CFFF'); + case 0x29: + return array('rgb' => '69FFFF'); + case 0x2A: + return array('rgb' => 'E0FFE0'); + case 0x2B: + return array('rgb' => 'FFFF80'); + case 0x2C: + return array('rgb' => 'A6CAF0'); + case 0x2D: + return array('rgb' => 'DD9CB3'); + case 0x2E: + return array('rgb' => 'B38FEE'); + case 0x2F: + return array('rgb' => 'E3E3E3'); + case 0x30: + return array('rgb' => '2A6FF9'); + case 0x31: + return array('rgb' => '3FB8CD'); + case 0x32: + return array('rgb' => '488436'); + case 0x33: + return array('rgb' => '958C41'); + case 0x34: + return array('rgb' => '8E5E42'); + case 0x35: + return array('rgb' => 'A0627A'); + case 0x36: + return array('rgb' => '624FAC'); + case 0x37: + return array('rgb' => '969696'); + case 0x38: + return array('rgb' => '1D2FBE'); + case 0x39: + return array('rgb' => '286676'); + case 0x3A: + return array('rgb' => '004500'); + case 0x3B: + return array('rgb' => '453E01'); + case 0x3C: + return array('rgb' => '6A2813'); + case 0x3D: + return array('rgb' => '85396A'); + case 0x3E: + return array('rgb' => '4A3285'); + case 0x3F: + return array('rgb' => '424242'); + default: + return array('rgb' => '000000'); + } + } + + + /** + * Map color array from BIFF8 built-in color index + * + * @param int $subData + * @return array + */ + private static function _mapColor($subData) + { + switch ($subData) { + case 0x08: + return array('rgb' => '000000'); + case 0x09: + return array('rgb' => 'FFFFFF'); + case 0x0A: + return array('rgb' => 'FF0000'); + case 0x0B: + return array('rgb' => '00FF00'); + case 0x0C: + return array('rgb' => '0000FF'); + case 0x0D: + return array('rgb' => 'FFFF00'); + case 0x0E: + return array('rgb' => 'FF00FF'); + case 0x0F: + return array('rgb' => '00FFFF'); + case 0x10: + return array('rgb' => '800000'); + case 0x11: + return array('rgb' => '008000'); + case 0x12: + return array('rgb' => '000080'); + case 0x13: + return array('rgb' => '808000'); + case 0x14: + return array('rgb' => '800080'); + case 0x15: + return array('rgb' => '008080'); + case 0x16: + return array('rgb' => 'C0C0C0'); + case 0x17: + return array('rgb' => '808080'); + case 0x18: + return array('rgb' => '9999FF'); + case 0x19: + return array('rgb' => '993366'); + case 0x1A: + return array('rgb' => 'FFFFCC'); + case 0x1B: + return array('rgb' => 'CCFFFF'); + case 0x1C: + return array('rgb' => '660066'); + case 0x1D: + return array('rgb' => 'FF8080'); + case 0x1E: + return array('rgb' => '0066CC'); + case 0x1F: + return array('rgb' => 'CCCCFF'); + case 0x20: + return array('rgb' => '000080'); + case 0x21: + return array('rgb' => 'FF00FF'); + case 0x22: + return array('rgb' => 'FFFF00'); + case 0x23: + return array('rgb' => '00FFFF'); + case 0x24: + return array('rgb' => '800080'); + case 0x25: + return array('rgb' => '800000'); + case 0x26: + return array('rgb' => '008080'); + case 0x27: + return array('rgb' => '0000FF'); + case 0x28: + return array('rgb' => '00CCFF'); + case 0x29: + return array('rgb' => 'CCFFFF'); + case 0x2A: + return array('rgb' => 'CCFFCC'); + case 0x2B: + return array('rgb' => 'FFFF99'); + case 0x2C: + return array('rgb' => '99CCFF'); + case 0x2D: + return array('rgb' => 'FF99CC'); + case 0x2E: + return array('rgb' => 'CC99FF'); + case 0x2F: + return array('rgb' => 'FFCC99'); + case 0x30: + return array('rgb' => '3366FF'); + case 0x31: + return array('rgb' => '33CCCC'); + case 0x32: + return array('rgb' => '99CC00'); + case 0x33: + return array('rgb' => 'FFCC00'); + case 0x34: + return array('rgb' => 'FF9900'); + case 0x35: + return array('rgb' => 'FF6600'); + case 0x36: + return array('rgb' => '666699'); + case 0x37: + return array('rgb' => '969696'); + case 0x38: + return array('rgb' => '003366'); + case 0x39: + return array('rgb' => '339966'); + case 0x3A: + return array('rgb' => '003300'); + case 0x3B: + return array('rgb' => '333300'); + case 0x3C: + return array('rgb' => '993300'); + case 0x3D: + return array('rgb' => '993366'); + case 0x3E: + return array('rgb' => '333399'); + case 0x3F: + return array('rgb' => '333333'); + default: + return array('rgb' => '000000'); + } + } + + private function _parseRichText($is = '') + { + $value = new PHPExcel_RichText(); + + $value->createText($is); + + return $value; + } +} diff --git a/Classes/PHPExcel/Reader/Excel5/Escher.php b/Classes/PHPExcel/Reader/Excel5/Escher.php index 9b2338c2..b4575e6a 100644 --- a/Classes/PHPExcel/Reader/Excel5/Escher.php +++ b/Classes/PHPExcel/Reader/Excel5/Escher.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Reader_Excel5_Escher * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,62 +25,54 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Reader_Excel5_Escher - * - * @category PHPExcel - * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Reader_Excel5_Escher { - const DGGCONTAINER = 0xF000; - const BSTORECONTAINER = 0xF001; - const DGCONTAINER = 0xF002; - const SPGRCONTAINER = 0xF003; - const SPCONTAINER = 0xF004; - const DGG = 0xF006; - const BSE = 0xF007; + const DGGCONTAINER = 0xF000; + const BSTORECONTAINER = 0xF001; + const DGCONTAINER = 0xF002; + const SPGRCONTAINER = 0xF003; + const SPCONTAINER = 0xF004; + const DGG = 0xF006; + const BSE = 0xF007; const DG = 0xF008; - const SPGR = 0xF009; + const SPGR = 0xF009; const SP = 0xF00A; - const OPT = 0xF00B; - const CLIENTTEXTBOX = 0xF00D; - const CLIENTANCHOR = 0xF010; + const OPT = 0xF00B; + const CLIENTTEXTBOX = 0xF00D; + const CLIENTANCHOR = 0xF010; const CLIENTDATA = 0xF011; - const BLIPJPEG = 0xF01D; - const BLIPPNG = 0xF01E; - const SPLITMENUCOLORS = 0xF11E; - const TERTIARYOPT = 0xF122; + const BLIPJPEG = 0xF01D; + const BLIPPNG = 0xF01E; + const SPLITMENUCOLORS = 0xF11E; + const TERTIARYOPT = 0xF122; /** * Escher stream data (binary) * * @var string */ - private $_data; + private $data; /** * Size in bytes of the Escher stream data * * @var int */ - private $_dataSize; + private $dataSize; /** * Current position of stream pointer in Escher stream data * * @var int */ - private $_pos; + private $pos; /** * The object to be returned by the reader. Modified during load. * * @var mixed */ - private $_object; + private $object; /** * Create a new PHPExcel_Reader_Excel5_Escher instance @@ -88,7 +81,7 @@ class PHPExcel_Reader_Excel5_Escher */ public function __construct($object) { - $this->_object = $object; + $this->object = $object; } /** @@ -98,80 +91,117 @@ class PHPExcel_Reader_Excel5_Escher */ public function load($data) { - $this->_data = $data; + $this->data = $data; // total byte size of Excel data (workbook global substream + sheet substreams) - $this->_dataSize = strlen($this->_data); + $this->dataSize = strlen($this->data); - $this->_pos = 0; + $this->pos = 0; // Parse Escher stream - while ($this->_pos < $this->_dataSize) { - + while ($this->pos < $this->dataSize) { // offset: 2; size: 2: Record Type - $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2); + $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos + 2); switch ($fbt) { - case self::DGGCONTAINER: $this->_readDggContainer(); break; - case self::DGG: $this->_readDgg(); break; - case self::BSTORECONTAINER: $this->_readBstoreContainer(); break; - case self::BSE: $this->_readBSE(); break; - case self::BLIPJPEG: $this->_readBlipJPEG(); break; - case self::BLIPPNG: $this->_readBlipPNG(); break; - case self::OPT: $this->_readOPT(); break; - case self::TERTIARYOPT: $this->_readTertiaryOPT(); break; - case self::SPLITMENUCOLORS: $this->_readSplitMenuColors(); break; - case self::DGCONTAINER: $this->_readDgContainer(); break; - case self::DG: $this->_readDg(); break; - case self::SPGRCONTAINER: $this->_readSpgrContainer(); break; - case self::SPCONTAINER: $this->_readSpContainer(); break; - case self::SPGR: $this->_readSpgr(); break; - case self::SP: $this->_readSp(); break; - case self::CLIENTTEXTBOX: $this->_readClientTextbox(); break; - case self::CLIENTANCHOR: $this->_readClientAnchor(); break; - case self::CLIENTDATA: $this->_readClientData(); break; - default: $this->_readDefault(); break; + case self::DGGCONTAINER: + $this->readDggContainer(); + break; + case self::DGG: + $this->readDgg(); + break; + case self::BSTORECONTAINER: + $this->readBstoreContainer(); + break; + case self::BSE: + $this->readBSE(); + break; + case self::BLIPJPEG: + $this->readBlipJPEG(); + break; + case self::BLIPPNG: + $this->readBlipPNG(); + break; + case self::OPT: + $this->readOPT(); + break; + case self::TERTIARYOPT: + $this->readTertiaryOPT(); + break; + case self::SPLITMENUCOLORS: + $this->readSplitMenuColors(); + break; + case self::DGCONTAINER: + $this->readDgContainer(); + break; + case self::DG: + $this->readDg(); + break; + case self::SPGRCONTAINER: + $this->readSpgrContainer(); + break; + case self::SPCONTAINER: + $this->readSpContainer(); + break; + case self::SPGR: + $this->readSpgr(); + break; + case self::SP: + $this->readSp(); + break; + case self::CLIENTTEXTBOX: + $this->readClientTextbox(); + break; + case self::CLIENTANCHOR: + $this->readClientAnchor(); + break; + case self::CLIENTDATA: + $this->readClientData(); + break; + default: + $this->readDefault(); + break; } } - return $this->_object; + return $this->object; } /** * Read a generic record */ - private function _readDefault() + private function readDefault() { // offset 0; size: 2; recVer and recInstance - $verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos); + $verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos); // offset: 2; size: 2: Record Type - $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2); + $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos + 2); // bit: 0-3; mask: 0x000F; recVer $recVer = (0x000F & $verInstance) >> 0; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read DggContainer record (Drawing Group Container) */ - private function _readDggContainer() + private function readDggContainer() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; // record is a container, read contents $dggContainer = new PHPExcel_Shared_Escher_DggContainer(); - $this->_object->setDggContainer($dggContainer); + $this->object->setDggContainer($dggContainer); $reader = new PHPExcel_Reader_Excel5_Escher($dggContainer); $reader->load($recordData); } @@ -179,29 +209,29 @@ class PHPExcel_Reader_Excel5_Escher /** * Read Dgg record (Drawing Group) */ - private function _readDgg() + private function readDgg() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read BstoreContainer record (Blip Store Container) */ - private function _readBstoreContainer() + private function readBstoreContainer() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; // record is a container, read contents $bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer(); - $this->_object->setBstoreContainer($bstoreContainer); + $this->object->setBstoreContainer($bstoreContainer); $reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer); $reader->load($recordData); } @@ -209,22 +239,22 @@ class PHPExcel_Reader_Excel5_Escher /** * Read BSE record */ - private function _readBSE() + private function readBSE() { // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; + $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; // add BSE to BstoreContainer $BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE(); - $this->_object->addBSE($BSE); + $this->object->addBSE($BSE); $BSE->setBLIPType($recInstance); @@ -275,18 +305,18 @@ class PHPExcel_Reader_Excel5_Escher /** * Read BlipJPEG record. Holds raw JPEG image data */ - private function _readBlipJPEG() + private function readBlipJPEG() { // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; + $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; $pos = 0; @@ -310,24 +340,24 @@ class PHPExcel_Reader_Excel5_Escher $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); $blip->setData($data); - $this->_object->setBlip($blip); + $this->object->setBlip($blip); } /** * Read BlipPNG record. Holds raw PNG image data */ - private function _readBlipPNG() + private function readBlipPNG() { // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; + $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; $pos = 0; @@ -351,71 +381,71 @@ class PHPExcel_Reader_Excel5_Escher $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); $blip->setData($data); - $this->_object->setBlip($blip); + $this->object->setBlip($blip); } /** * Read OPT record. This record may occur within DggContainer record or SpContainer */ - private function _readOPT() + private function readOPT() { // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; + $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; - $this->_readOfficeArtRGFOPTE($recordData, $recInstance); + $this->readOfficeArtRGFOPTE($recordData, $recInstance); } /** * Read TertiaryOPT record */ - private function _readTertiaryOPT() + private function readTertiaryOPT() { // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; + $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read SplitMenuColors record */ - private function _readSplitMenuColors() + private function readSplitMenuColors() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read DgContainer record (Drawing Container) */ - private function _readDgContainer() + private function readDgContainer() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; // record is a container, read contents $dgContainer = new PHPExcel_Shared_Escher_DgContainer(); - $this->_object->setDgContainer($dgContainer); + $this->object->setDgContainer($dgContainer); $reader = new PHPExcel_Reader_Excel5_Escher($dgContainer); $escher = $reader->load($recordData); } @@ -423,37 +453,37 @@ class PHPExcel_Reader_Excel5_Escher /** * Read Dg record (Drawing) */ - private function _readDg() + private function readDg() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read SpgrContainer record (Shape Group Container) */ - private function _readSpgrContainer() + private function readSpgrContainer() { // context is either context DgContainer or SpgrContainer - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; // record is a container, read contents $spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer(); - if ($this->_object instanceof PHPExcel_Shared_Escher_DgContainer) { + if ($this->object instanceof PHPExcel_Shared_Escher_DgContainer) { // DgContainer - $this->_object->setSpgrContainer($spgrContainer); + $this->object->setSpgrContainer($spgrContainer); } else { // SpgrContainer - $this->_object->addChild($spgrContainer); + $this->object->addChild($spgrContainer); } $reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer); @@ -463,17 +493,17 @@ class PHPExcel_Reader_Excel5_Escher /** * Read SpContainer record (Shape Container) */ - private function _readSpContainer() + private function readSpContainer() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // add spContainer to spgrContainer $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer(); - $this->_object->addChild($spContainer); + $this->object->addChild($spContainer); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; // record is a container, read contents $reader = new PHPExcel_Reader_Excel5_Escher($spContainer); @@ -483,59 +513,59 @@ class PHPExcel_Reader_Excel5_Escher /** * Read Spgr record (Shape Group) */ - private function _readSpgr() + private function readSpgr() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read Sp record (Shape) */ - private function _readSp() + private function readSp() { // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; + $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read ClientTextbox record */ - private function _readClientTextbox() + private function readClientTextbox() { // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4; + $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** * Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet */ - private function _readClientAnchor() + private function readClientAnchor() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; // offset: 2; size: 2; upper-left corner column index (0-based) $c1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 2); @@ -562,34 +592,34 @@ class PHPExcel_Reader_Excel5_Escher $endOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 16); // set the start coordinates - $this->_object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1)); + $this->object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1)); // set the start offsetX - $this->_object->setStartOffsetX($startOffsetX); + $this->object->setStartOffsetX($startOffsetX); // set the start offsetY - $this->_object->setStartOffsetY($startOffsetY); + $this->object->setStartOffsetY($startOffsetY); // set the end coordinates - $this->_object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1)); + $this->object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1)); // set the end offsetX - $this->_object->setEndOffsetX($endOffsetX); + $this->object->setEndOffsetX($endOffsetX); // set the end offsetY - $this->_object->setEndOffsetY($endOffsetY); + $this->object->setEndOffsetY($endOffsetY); } /** * Read ClientData record */ - private function _readClientData() + private function readClientData() { - $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4); - $recordData = substr($this->_data, $this->_pos + 8, $length); + $length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); + $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record - $this->_pos += 8 + $length; + $this->pos += 8 + $length; } /** @@ -598,8 +628,8 @@ class PHPExcel_Reader_Excel5_Escher * @param string $data Binary data * @param int $n Number of properties */ - private function _readOfficeArtRGFOPTE($data, $n) { - + private function readOfficeArtRGFOPTE($data, $n) + { $splicedComplexData = substr($data, 6 * $n); // loop through property-value pairs @@ -633,8 +663,7 @@ class PHPExcel_Reader_Excel5_Escher $value = $op; } - $this->_object->setOPT($opidOpid, $value); + $this->object->setOPT($opidOpid, $value); } } - } diff --git a/Classes/PHPExcel/Reader/Excel5/MD5.php b/Classes/PHPExcel/Reader/Excel5/MD5.php index 1c9ede02..1141d43a 100644 --- a/Classes/PHPExcel/Reader/Excel5/MD5.php +++ b/Classes/PHPExcel/Reader/Excel5/MD5.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Reader_Excel5_MD5 * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,15 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - - -/** - * PHPExcel_Reader_Excel5_MD5 - * - * @category PHPExcel - * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Reader_Excel5_MD5 { // Context @@ -41,7 +33,6 @@ class PHPExcel_Reader_Excel5_MD5 private $c; private $d; - /** * MD5 stream constructor */ @@ -50,7 +41,6 @@ class PHPExcel_Reader_Excel5_MD5 $this->reset(); } - /** * Reset the MD5 stream context */ @@ -62,10 +52,9 @@ class PHPExcel_Reader_Excel5_MD5 $this->d = 0x10325476; } - /** * Get MD5 stream context - * + * * @return string */ public function getContext() @@ -82,10 +71,9 @@ class PHPExcel_Reader_Excel5_MD5 return $s; } - /** * Add data to context - * + * * @param string $data Data to add */ public function add($data) @@ -180,31 +168,26 @@ class PHPExcel_Reader_Excel5_MD5 $this->d = ($this->d + $D) & 0xffffffff; } - private static function F($X, $Y, $Z) { return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z } - private static function G($X, $Y, $Z) { return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z } - private static function H($X, $Y, $Z) { return ($X ^ $Y ^ $Z); // X XOR Y XOR Z } - private static function I($X, $Y, $Z) { return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z) } - private static function step($func, &$A, $B, $C, $D, $M, $s, $t) { $A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff; @@ -212,10 +195,9 @@ class PHPExcel_Reader_Excel5_MD5 $A = ($B + $A) & 0xffffffff; } - private static function rotate($decimal, $bits) { $binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT); return bindec(substr($binary, $bits).substr($binary, 0, $bits)); } -} \ No newline at end of file +} diff --git a/Classes/PHPExcel/Reader/Excel5/RC4.php b/Classes/PHPExcel/Reader/Excel5/RC4.php index 9130b45a..5640539c 100644 --- a/Classes/PHPExcel/Reader/Excel5/RC4.php +++ b/Classes/PHPExcel/Reader/Excel5/RC4.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Reader_Excel5_RC4 * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,24 +25,16 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Reader_Excel5_RC4 - * - * @category PHPExcel - * @package PHPExcel_Reader_Excel5 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Reader_Excel5_RC4 { // Context - var $s = array(); - var $i = 0; - var $j = 0; + protected $s = array(); + protected $i = 0; + protected $j = 0; /** * RC4 stream decryption/encryption constrcutor - * + * * @param string $key Encryption key/passphrase */ public function __construct($key) @@ -64,9 +57,9 @@ class PHPExcel_Reader_Excel5_RC4 /** * Symmetric decryption/encryption function - * + * * @param string $data Data to encrypt/decrypt - * + * * @return string */ public function RC4($data) diff --git a/Classes/PHPExcel/Reader/Gnumeric.php b/Classes/PHPExcel/Reader/Gnumeric.php index 72a6755f..e5bf84bb 100644 --- a/Classes/PHPExcel/Reader/Gnumeric.php +++ b/Classes/PHPExcel/Reader/Gnumeric.php @@ -1,6 +1,16 @@ <?php + +/** PHPExcel root directory */ +if (!defined('PHPEXCEL_ROOT')) { + /** + * @ignore + */ + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); +} + /** - * PHPExcel + * PHPExcel_Reader_Gnumeric * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,24 +34,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - - -/** PHPExcel root directory */ -if (!defined('PHPEXCEL_ROOT')) { - /** - * @ignore - */ - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); -} - -/** - * PHPExcel_Reader_Gnumeric - * - * @category PHPExcel - * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { /** @@ -49,27 +41,26 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx * * @var array */ - private $_styles = array(); + private $styles = array(); /** * Shared Expressions * * @var array */ - private $_expressions = array(); - - private $_referenceHelper = null; + private $expressions = array(); + private $referenceHelper = null; /** * Create a new PHPExcel_Reader_Gnumeric */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); - $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); + $this->referenceHelper = PHPExcel_ReferenceHelper::getInstance(); } - /** * Can the current PHPExcel_Reader_IReader read the file? * @@ -101,7 +92,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return true; } - /** * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * @@ -116,10 +106,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } $xml = new XMLReader(); - $xml->xml( - $this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions() - ); - $xml->setParserProperty(2,true); + $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml->setParserProperty(2, true); $worksheetNames = array(); while ($xml->read()) { @@ -135,7 +123,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $worksheetNames; } - /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * @@ -150,10 +137,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } $xml = new XMLReader(); - $xml->xml( - $this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions() - ); - $xml->setParserProperty(2,true); + $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml->setParserProperty(2, true); $worksheetInfo = array(); while ($xml->read()) { @@ -188,8 +173,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $worksheetInfo; } - - private function _gzfileGetContents($filename) { + private function _gzfileGetContents($filename) + { $file = @gzopen($filename, 'rb'); if ($file !== false) { $data = ''; @@ -201,7 +186,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $data; } - /** * Loads PHPExcel from file * @@ -218,7 +202,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $this->loadIntoExisting($pFilename, $objPHPExcel); } - /** * Loads PHPExcel from file into PHPExcel instance * @@ -258,7 +241,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $officeDocMetaXML = $officeDocXML->meta; foreach ($officeDocMetaXML as $officePropertyData) { - $officePropertyDC = array(); if (isset($namespacesMeta['dc'])) { $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); @@ -266,24 +248,24 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx foreach ($officePropertyDC as $propertyName => $propertyValue) { $propertyValue = (string) $propertyValue; switch ($propertyName) { - case 'title' : - $docProps->setTitle(trim($propertyValue)); - break; - case 'subject' : - $docProps->setSubject(trim($propertyValue)); - break; - case 'creator' : - $docProps->setCreator(trim($propertyValue)); - $docProps->setLastModifiedBy(trim($propertyValue)); - break; - case 'date' : - $creationDate = strtotime(trim($propertyValue)); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - break; - case 'description' : - $docProps->setDescription(trim($propertyValue)); - break; + case 'title': + $docProps->setTitle(trim($propertyValue)); + break; + case 'subject': + $docProps->setSubject(trim($propertyValue)); + break; + case 'creator': + $docProps->setCreator(trim($propertyValue)); + $docProps->setLastModifiedBy(trim($propertyValue)); + break; + case 'date': + $creationDate = strtotime(trim($propertyValue)); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + break; + case 'description': + $docProps->setDescription(trim($propertyValue)); + break; } } $officePropertyMeta = array(); @@ -294,32 +276,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $attributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValue = (string) $propertyValue; switch ($propertyName) { - case 'keyword' : - $docProps->setKeywords(trim($propertyValue)); - break; - case 'initial-creator' : - $docProps->setCreator(trim($propertyValue)); - $docProps->setLastModifiedBy(trim($propertyValue)); - break; - case 'creation-date' : - $creationDate = strtotime(trim($propertyValue)); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - break; - case 'user-defined' : - list(, $attrName) = explode(':', $attributes['name']); - switch ($attrName) { - case 'publisher' : - $docProps->setCompany(trim($propertyValue)); - break; - case 'category' : - $docProps->setCategory(trim($propertyValue)); - break; - case 'manager' : - $docProps->setManager(trim($propertyValue)); - break; - } - break; + case 'keyword': + $docProps->setKeywords(trim($propertyValue)); + break; + case 'initial-creator': + $docProps->setCreator(trim($propertyValue)); + $docProps->setLastModifiedBy(trim($propertyValue)); + break; + case 'creation-date': + $creationDate = strtotime(trim($propertyValue)); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + break; + case 'user-defined': + list(, $attrName) = explode(':', $attributes['name']); + switch ($attrName) { + case 'publisher': + $docProps->setCompany(trim($propertyValue)); + break; + case 'category': + $docProps->setCategory(trim($propertyValue)); + break; + case 'manager': + $docProps->setManager(trim($propertyValue)); + break; + } + break; } } } @@ -328,26 +310,26 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $propertyName = $summaryItem->name; $propertyValue = $summaryItem->{'val-string'}; switch ($propertyName) { - case 'title' : + case 'title': $docProps->setTitle(trim($propertyValue)); break; - case 'comments' : + case 'comments': $docProps->setDescription(trim($propertyValue)); break; - case 'keywords' : + case 'keywords': $docProps->setKeywords(trim($propertyValue)); break; - case 'category' : + case 'category': $docProps->setCategory(trim($propertyValue)); break; - case 'manager' : + case 'manager': $docProps->setManager(trim($propertyValue)); break; - case 'author' : + case 'author': $docProps->setCreator(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue)); break; - case 'company' : + case 'company': $docProps->setCompany(trim($propertyValue)); break; } @@ -370,35 +352,35 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // 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); + $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) { if (isset($sheet->PrintInformation->Margins)) { - foreach ($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) { + foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) { $marginAttributes = $margin->attributes(); $marginSize = 72 / 100; // Default switch ($marginAttributes['PrefUnit']) { - case 'mm' : + case 'mm': $marginSize = intval($marginAttributes['Points']) / 100; break; } switch ($key) { - case 'top' : + case 'top': $objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize); break; - case 'bottom' : + case 'bottom': $objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize); break; - case 'left' : + case 'left': $objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize); break; - case 'right' : + case 'right': $objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize); break; - case 'header' : + case 'header': $objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize); break; - case 'footer' : + case 'footer': $objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize); break; } @@ -411,13 +393,17 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $row = (int) $cellAttributes->Row + 1; $column = (int) $cellAttributes->Col; - if ($row > $maxRow) $maxRow = $row; - if ($column > $maxCol) $maxCol = $column; + if ($row > $maxRow) { + $maxRow = $row; + } + if ($column > $maxCol) { + $maxCol = $column; + } $column = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if ($this->getReadFilter() !== NULL) { + if ($this->getReadFilter() !== null) { if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) { continue; } @@ -431,60 +417,53 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $type = PHPExcel_Cell_DataType::TYPE_FORMULA; if ($ExprID > '') { if (((string) $cell) > '') { - - $this->_expressions[$ExprID] = array( 'column' => $cellAttributes->Col, - 'row' => $cellAttributes->Row, - 'formula' => (string) $cell - ); + $this->expressions[$ExprID] = array( + 'column' => $cellAttributes->Col, + 'row' => $cellAttributes->Row, + 'formula' => (string) $cell + ); // echo 'NEW EXPRESSION ', $ExprID,'<br />'; } else { - $expression = $this->_expressions[$ExprID]; + $expression = $this->expressions[$ExprID]; - $cell = $this->_referenceHelper->updateFormulaReferences( $expression['formula'], - 'A1', - $cellAttributes->Col - $expression['column'], - $cellAttributes->Row - $expression['row'], - $worksheetName - ); + $cell = $this->referenceHelper->updateFormulaReferences($expression['formula'], 'A1', $cellAttributes->Col - $expression['column'], $cellAttributes->Row - $expression['row'], $worksheetName); // echo 'SHARED EXPRESSION ', $ExprID,'<br />'; // echo 'New Value is ', $cell,'<br />'; } $type = PHPExcel_Cell_DataType::TYPE_FORMULA; } else { switch ($ValueType) { - case '10' : // NULL + case '10': // NULL $type = PHPExcel_Cell_DataType::TYPE_NULL; break; - case '20' : // Boolean + case '20': // Boolean $type = PHPExcel_Cell_DataType::TYPE_BOOL; - $cell = ($cell == 'TRUE') ? True : False; + $cell = ($cell == 'TRUE') ? true: false; break; - case '30' : // Integer + case '30': // Integer $cell = intval($cell); - case '40' : // Float + case '40': // Float $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; break; - case '50' : // Error + case '50': // Error $type = PHPExcel_Cell_DataType::TYPE_ERROR; break; - case '60' : // String + case '60': // String $type = PHPExcel_Cell_DataType::TYPE_STRING; break; - case '70' : // Cell Range - case '80' : // Array + case '70': // Cell Range + case '80': // Array } } $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type); } if ((!$this->_readDataOnly) && (isset($sheet->Objects))) { - foreach ($sheet->Objects->children('gnm',TRUE) as $key => $comment) { + foreach ($sheet->Objects->children('gnm', true) as $key => $comment) { $commentAttributes = $comment->attributes(); // Only comment objects are handled at the moment if ($commentAttributes->Text) { - $objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound ) - ->setAuthor( (string)$commentAttributes->Author ) - ->setText($this->_parseRichText((string)$commentAttributes->Text) ); + $objPHPExcel->getActiveSheet()->getComment((string)$commentAttributes->ObjectBound)->setAuthor((string)$commentAttributes->Author)->setText($this->_parseRichText((string)$commentAttributes->Text)); } } } @@ -494,7 +473,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $styleAttributes = $styleRegion->attributes(); if (($styleAttributes['startRow'] <= $maxRow) && ($styleAttributes['startCol'] <= $maxCol)) { - $startColumn = PHPExcel_Cell::stringFromColumnIndex((int) $styleAttributes['startCol']); $startRow = $styleAttributes['startRow'] + 1; @@ -517,44 +495,44 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // If _readDataOnly is false, we set all formatting information if (!$this->_readDataOnly) { switch ($styleAttributes['HAlign']) { - case '1' : + case '1': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; break; - case '2' : + case '2': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT; break; - case '4' : + case '4': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT; break; - case '8' : + case '8': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER; break; - case '16' : - case '64' : + case '16': + case '64': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS; break; - case '32' : + case '32': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY; break; } switch ($styleAttributes['VAlign']) { - case '1' : + case '1': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP; break; - case '2' : + case '2': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; break; - case '4' : + case '4': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER; break; - case '8' : + case '8': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY; break; } - $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? True : False; - $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? True : False; + $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false; + $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false; $styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0; $RGB = self::_parseGnumericColour($styleAttributes["Fore"]); @@ -566,64 +544,64 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]); $styleArray['fill']['endcolor']['rgb'] = $RGB2; switch ($shade) { - case '1' : + case '1': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; break; - case '2' : + case '2': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR; break; - case '3' : + case '3': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH; break; - case '4' : + case '4': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; break; - case '5' : + case '5': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; break; - case '6' : + case '6': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; break; - case '7' : + case '7': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; break; - case '8' : + case '8': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; break; - case '9' : + case '9': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; break; - case '10' : + case '10': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; break; - case '11' : + case '11': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; break; - case '12' : + case '12': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; break; - case '13' : + case '13': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; break; - case '14' : + case '14': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; break; - case '15' : + case '15': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; break; - case '16' : + case '16': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; break; - case '17' : + case '17': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; break; - case '18' : + case '18': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; break; - case '19' : + case '19': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; break; - case '20' : + case '20': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; break; } @@ -634,32 +612,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // echo '<br />'; $styleArray['font']['name'] = (string) $styleRegion->Style->Font; $styleArray['font']['size'] = intval($fontAttributes['Unit']); - $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False; - $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False; - $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False; + $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false; + $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false; + $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false; switch ($fontAttributes['Underline']) { - case '1' : + case '1': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE; break; - case '2' : + case '2': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE; break; - case '3' : + case '3': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING; break; - case '4' : + case '4': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING; break; - default : + default: $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE; break; } switch ($fontAttributes['Script']) { - case '1' : - $styleArray['font']['superScript'] = True; + case '1': + $styleArray['font']['superScript'] = true; break; - case '-1' : - $styleArray['font']['subScript'] = True; + case '-1': + $styleArray['font']['subScript'] = true; break; } @@ -761,7 +739,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // Handle Merged Cells in this worksheet if (isset($sheet->MergedRegions)) { foreach ($sheet->MergedRegions->Merge as $mergeCells) { - if (strpos($mergeCells,':') !== FALSE) { + if (strpos($mergeCells, ':') !== false) { $objPHPExcel->getActiveSheet()->mergeCells($mergeCells); } } @@ -780,20 +758,18 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } $range = explode('!', $range); - $range[0] = trim($range[0],"'");; + $range[0] = trim($range[0], "'"); if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); - $objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) ); + $objPHPExcel->addNamedRange(new PHPExcel_NamedRange($name, $worksheet, $extractedRange)); } } } - // Return return $objPHPExcel; } - private static function _parseBorderAttributes($borderAttributes) { $styleArray = array(); @@ -804,54 +780,54 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } switch ($borderAttributes["Style"]) { - case '0' : + case '0': $styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE; break; - case '1' : + case '1': $styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN; break; - case '2' : + case '2': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; break; - case '4' : + case '4': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED; break; - case '5' : + case '5': $styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK; break; - case '6' : + case '6': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE; break; - case '7' : + case '7': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED; break; - case '9' : + case '9': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT; break; - case '10' : + case '10': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; break; - case '11' : + case '11': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT; break; - case '12' : + case '12': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; break; - case '13' : + case '13': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; break; - case '3' : + case '3': $styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT; break; - case '8' : + case '8': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED; break; } return $styleArray; } - - private function _parseRichText($is = '') { + private function _parseRichText($is = '') + { $value = new PHPExcel_RichText(); $value->createText($is); @@ -859,15 +835,14 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $value; } - - private static function _parseGnumericColour($gnmColour) { + private static function _parseGnumericColour($gnmColour) + { list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour); - $gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2); - $gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2); - $gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2); + $gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2); + $gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2); + $gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2); $RGB = $gnmR.$gnmG.$gnmB; // echo 'Excel Colour: ', $RGB,'<br />'; return $RGB; } - } diff --git a/Classes/PHPExcel/Reader/OOCalc.php b/Classes/PHPExcel/Reader/OOCalc.php index c212e9bc..66b7afe8 100644 --- a/Classes/PHPExcel/Reader/OOCalc.php +++ b/Classes/PHPExcel/Reader/OOCalc.php @@ -1,6 +1,16 @@ <?php + +/** PHPExcel root directory */ +if (!defined('PHPEXCEL_ROOT')) { + /** + * @ignore + */ + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); +} + /** - * PHPExcel + * PHPExcel_Reader_OOCalc * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,24 +34,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - - -/** PHPExcel root directory */ -if (!defined('PHPEXCEL_ROOT')) { - /** - * @ignore - */ - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); -} - -/** - * PHPExcel_Reader_OOCalc - * - * @category PHPExcel - * @package PHPExcel_Reader - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { /** @@ -49,17 +41,16 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce * * @var array */ - private $_styles = array(); - + private $styles = array(); /** * Create a new PHPExcel_Reader_OOCalc */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } - /** * Can the current PHPExcel_Reader_IReader read the file? * @@ -77,7 +68,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $zipClass = PHPExcel_Settings::getZipClass(); // Check if zip class exists -// if (!class_exists($zipClass, FALSE)) { +// if (!class_exists($zipClass, false)) { // throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled"); // } @@ -109,7 +100,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet'); } - return FALSE; + return false; } @@ -137,17 +128,18 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $xml = new XMLReader(); $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); - $xml->setParserProperty(2,true); + $xml->setParserProperty(2, true); // Step into the first level of content of the XML $xml->read(); while ($xml->read()) { // Quickly jump through to the office:body node while ($xml->name !== 'office:body') { - if ($xml->isEmptyElement) + if ($xml->isEmptyElement) { $xml->read(); - else + } else { $xml->next(); + } } // Now read each node until we find our first table:table node while ($xml->read()) { @@ -164,7 +156,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $worksheetNames; } - /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * @@ -189,17 +180,18 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $xml = new XMLReader(); $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); - $xml->setParserProperty(2,true); + $xml->setParserProperty(2, true); // Step into the first level of content of the XML $xml->read(); while ($xml->read()) { // Quickly jump through to the office:body node while ($xml->name !== 'office:body') { - if ($xml->isEmptyElement) + if ($xml->isEmptyElement) { $xml->read(); - else + } else { $xml->next(); + } } // Now read each node until we find our first table:table node while ($xml->read()) { @@ -289,7 +281,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $worksheetInfo; } - /** * Loads PHPExcel from file * @@ -306,8 +297,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $this->loadIntoExisting($pFilename, $objPHPExcel); } - - private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { + private static function identifyFixedStyleValue($styleList, &$styleAttributeValue) + { $styleAttributeValue = strtolower($styleAttributeValue); foreach ($styleList as $style) { if ($styleAttributeValue == strtolower($style)) { @@ -318,7 +309,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return false; } - /** * Loads PHPExcel from file into PHPExcel instance * @@ -361,24 +351,24 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce foreach ($officePropertyDC as $propertyName => $propertyValue) { $propertyValue = (string) $propertyValue; switch ($propertyName) { - case 'title' : - $docProps->setTitle($propertyValue); - break; - case 'subject' : - $docProps->setSubject($propertyValue); - break; - case 'creator' : - $docProps->setCreator($propertyValue); - $docProps->setLastModifiedBy($propertyValue); - break; - case 'date' : - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - break; - case 'description' : - $docProps->setDescription($propertyValue); - break; + case 'title': + $docProps->setTitle($propertyValue); + break; + case 'subject': + $docProps->setSubject($propertyValue); + break; + case 'creator': + $docProps->setCreator($propertyValue); + $docProps->setLastModifiedBy($propertyValue); + break; + case 'date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + break; + case 'description': + $docProps->setDescription($propertyValue); + break; } } $officePropertyMeta = array(); @@ -389,42 +379,42 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValue = (string) $propertyValue; switch ($propertyName) { - case 'initial-creator' : - $docProps->setCreator($propertyValue); - break; - case 'keyword' : - $docProps->setKeywords($propertyValue); - break; - case 'creation-date' : - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - break; - case 'user-defined' : - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; - foreach ($propertyValueAttributes as $key => $value) { - if ($key == 'name') { - $propertyValueName = (string) $value; - } elseif ($key == 'value-type') { - switch ($value) { - case 'date' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; - break; - case 'boolean' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; - break; - case 'float' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; - break; - default : - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; - } + case 'initial-creator': + $docProps->setCreator($propertyValue); + break; + case 'keyword': + $docProps->setKeywords($propertyValue); + break; + case 'creation-date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + break; + case 'user-defined': + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; + foreach ($propertyValueAttributes as $key => $value) { + if ($key == 'name') { + $propertyValueName = (string) $value; + } elseif ($key == 'value-type') { + switch ($value) { + case 'date': + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'date'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; + break; + case 'boolean': + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'bool'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; + break; + case 'float': + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'r4'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; + break; + default: + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; } } - $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); - break; + } + $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); + break; } } } @@ -462,7 +452,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // 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); + $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); } $rowID = 1; @@ -470,26 +460,23 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo '<b>'.$key.'</b><br />'; switch ($key) { case 'table-header-rows': - foreach ($rowData as $key=>$cellData) { + foreach ($rowData as $key => $cellData) { $rowData = $cellData; break; } - case 'table-row' : + case 'table-row': $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']); - $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? - $rowDataTableAttributes['number-rows-repeated'] : 1; + $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? $rowDataTableAttributes['number-rows-repeated'] : 1; $columnID = 'A'; foreach ($rowData as $key => $cellData) { - if ($this->getReadFilter() !== NULL) { + if ($this->getReadFilter() !== null) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { continue; } } // echo '<b>'.$columnID.$rowID.'</b><br />'; - $cellDataText = (isset($namespacesContent['text'])) ? - $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']); @@ -524,13 +511,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce } } $text = implode("\n", $textArray); -// echo $text,'<br />'; - $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) +// echo $text, '<br />'; + $objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setText($this->parseRichText($text)); // ->setAuthor( $author ) - ->setText($this->_parseRichText($text) ); } - if (isset($cellDataText->p)) { + 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. @@ -553,86 +539,87 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />'; switch ($cellDataOfficeAttributes['value-type']) { - case 'string' : - $type = PHPExcel_Cell_DataType::TYPE_STRING; - $dataValue = $allCellDataText; - if (isset($dataValue->a)) { - $dataValue = $dataValue->a; - $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']); - $hyperlink = $cellXLinkAttributes['href']; - } - break; - case 'boolean' : - $type = PHPExcel_Cell_DataType::TYPE_BOOL; - $dataValue = ($allCellDataText == 'TRUE') ? True : False; - break; - case 'percentage' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = (float) $cellDataOfficeAttributes['value']; - if (floor($dataValue) == $dataValue) { + case 'string': + $type = PHPExcel_Cell_DataType::TYPE_STRING; + $dataValue = $allCellDataText; + if (isset($dataValue->a)) { + $dataValue = $dataValue->a; + $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']); + $hyperlink = $cellXLinkAttributes['href']; + } + break; + case 'boolean': + $type = PHPExcel_Cell_DataType::TYPE_BOOL; + $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) { + if ($dataValue == (integer) $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) { - if ($dataValue == (integer) $dataValue) - $dataValue = (integer) $dataValue; - else - $dataValue = (float) $dataValue; - } - break; - case 'date' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); - $dateObj->setTimeZone($timezoneObj); - list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s')); - $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second); - if ($dataValue != floor($dataValue)) { - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; } else { - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; + $dataValue = (float) $dataValue; } - break; - case 'time' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS')))); - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; - break; + } + break; + case 'date': + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); + $dateObj->setTimeZone($timezoneObj); + list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s')); + $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second); + if ($dataValue != floor($dataValue)) { + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; + } else { + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; + } + break; + case 'time': + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':', sscanf($cellDataOfficeAttributes['time-value'], 'PT%dH%dM%dS')))); + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; + break; } // echo 'Data value is '.$dataValue.'<br />'; -// if ($hyperlink !== NULL) { +// if ($hyperlink !== null) { // echo 'Hyperlink is '.$hyperlink.'<br />'; // } } else { $type = PHPExcel_Cell_DataType::TYPE_NULL; - $dataValue = NULL; + $dataValue = null; } if ($hasCalculatedValue) { $type = PHPExcel_Cell_DataType::TYPE_FORMULA; // echo 'Formula: ', $cellDataFormula, PHP_EOL; - $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); + $cellDataFormula = substr($cellDataFormula, strpos($cellDataFormula, ':=')+1); $temp = explode('"', $cellDataFormula); $tKey = false; foreach ($temp as &$value) { // Only replace in alternate array entries (i.e. non-quoted blocks) if ($tKey = !$tKey) { - $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3', $value); // Cell range reference in another sheet - $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2', $value); // Cell reference in another sheet - $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2', $value); // Cell range reference - $value = preg_replace('/\[\.([^\.]+)\]/Ui','$1', $value); // Simple cell reference - $value = PHPExcel_Calculation::_translateSeparator(';',',', $value, $inBraces); + $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value); // Cell range reference in another sheet + $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); // Cell reference in another sheet + $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference + $value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference + $value = PHPExcel_Calculation::_translateSeparator(';', ',', $value, $inBraces); } } unset($value); @@ -641,9 +628,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL; } - $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? - $cellDataTableAttributes['number-columns-repeated'] : 1; - if ($type !== NULL) { + $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? $cellDataTableAttributes['number-columns-repeated'] : 1; + if ($type !== null) { for ($i = 0; $i < $colRepeats; ++$i) { if ($i > 0) { ++$columnID; @@ -656,12 +642,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo 'Forumla result is '.$dataValue.'<br />'; $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue); } - if ($formatting !== NULL) { + 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) { + if ($hyperlink !== null) { $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink); } } @@ -699,13 +685,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $objPHPExcel; } - - private function _parseRichText($is = '') { + private function parseRichText($is = '') + { $value = new PHPExcel_RichText(); $value->createText($is); return $value; } - } diff --git a/Classes/PHPExcel/Reader/SYLK.php b/Classes/PHPExcel/Reader/SYLK.php index 85569d9a..a7f3f172 100644 --- a/Classes/PHPExcel/Reader/SYLK.php +++ b/Classes/PHPExcel/Reader/SYLK.php @@ -49,33 +49,34 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ * * @var string */ - private $_inputEncoding = 'ANSI'; + private $inputEncoding = 'ANSI'; /** * Sheet index to read * * @var int */ - private $_sheetIndex = 0; + private $sheetIndex = 0; /** * Formats * * @var array */ - private $_formats = array(); + private $formats = array(); /** * Format Count * * @var int */ - private $_format = 0; + private $format = 0; /** * Create a new PHPExcel_Reader_SYLK */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } @@ -92,16 +93,16 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // Count delimiters in file $delimiterCount = substr_count($data, ';'); if ($delimiterCount < 1) { - return FALSE; + return false; } // Analyze first line looking for ID; signature $lines = explode("\n", $data); - if (substr($lines[0],0,4) != 'ID;P') { - return FALSE; + if (substr($lines[0], 0, 4) != 'ID;P') { + return false; } - return TRUE; + return true; } /** @@ -111,7 +112,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ */ public function setInputEncoding($pValue = 'ANSI') { - $this->_inputEncoding = $pValue; + $this->inputEncoding = $pValue; return $this; } @@ -122,7 +123,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ */ public function getInputEncoding() { - return $this->_inputEncoding; + return $this->inputEncoding; } /** @@ -136,7 +137,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; @@ -154,7 +155,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // loop through one row (line) at a time in the file $rowIndex = 0; - while (($rowData = fgets($fileHandle)) !== FALSE) { + while (($rowData = fgets($fileHandle)) !== false) { $columnIndex = 0; // convert SYLK encoded $rowData to UTF-8 @@ -162,20 +163,20 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // 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))))); + $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; + case 'C': + case 'X': + $columnIndex = substr($rowDatum, 1) - 1; break; - case 'R' : - case 'Y' : - $rowIndex = substr($rowDatum,1); + case 'R': + case 'Y': + $rowIndex = substr($rowDatum, 1); break; } @@ -223,17 +224,17 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; rewind($fileHandle); // Create new PHPExcel - while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { + while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) { $objPHPExcel->createSheet(); } - $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex ); + $objPHPExcel->setActiveSheetIndex($this->sheetIndex); $fromFormats = array('\-', '\ '); $toFormats = array('-', ' '); @@ -243,14 +244,13 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ $column = $row = ''; // loop through one row (line) at a time in the file - while (($rowData = fgets($fileHandle)) !== FALSE) { - + while (($rowData = fgets($fileHandle)) !== false) { // 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))))); + $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData))))); $dataType = array_shift($rowData); // Read shared styles @@ -258,93 +258,115 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ $formatArray = array(); foreach ($rowData as $rowDatum) { switch ($rowDatum{0}) { - case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats,substr($rowDatum,1)); - break; - case 'E' : - case 'F' : $formatArray['font']['name'] = substr($rowDatum,1); - break; - case 'L' : $formatArray['font']['size'] = substr($rowDatum,1); - break; - case 'S' : $styleSettings = substr($rowDatum,1); - for ($i=0;$i<strlen($styleSettings);++$i) { - switch ($styleSettings{$i}) { - case 'I' : $formatArray['font']['italic'] = true; - break; - case 'D' : $formatArray['font']['bold'] = true; - break; - case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - } - } - break; + case 'P': + $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); + break; + case 'E': + case 'F': + $formatArray['font']['name'] = substr($rowDatum, 1); + break; + case 'L': + $formatArray['font']['size'] = substr($rowDatum, 1); + break; + case 'S': + $styleSettings = substr($rowDatum, 1); + for ($i=0; $i<strlen($styleSettings); ++$i) { + switch ($styleSettings{$i}) { + case 'I': + $formatArray['font']['italic'] = true; + break; + case 'D': + $formatArray['font']['bold'] = true; + break; + case 'T': + $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + case 'B': + $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + case 'L': + $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + case 'R': + $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + } + } + break; } } - $this->_formats['P'.$this->_format++] = $formatArray; + $this->formats['P'.$this->format++] = $formatArray; // Read cell value data } elseif ($dataType == 'C') { $hasCalculatedValue = false; $cellData = $cellDataFormula = ''; foreach ($rowData as $rowDatum) { switch ($rowDatum{0}) { - case 'C' : - case 'X' : $column = substr($rowDatum,1); - break; - case 'R' : - case 'Y' : $row = substr($rowDatum,1); - break; - case 'K' : $cellData = substr($rowDatum,1); - break; - case 'E' : $cellDataFormula = '='.substr($rowDatum,1); - // Convert R1C1 style references to A1 style references (but only when not quoted) - $temp = explode('"', $cellDataFormula); - $key = false; - foreach ($temp as &$value) { - // Only count/replace in alternate array entries - if ($key = !$key) { - preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); - // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way - // through the formula from left to right. Reversing means that we work right to left.through - // the formula - $cellReferences = array_reverse($cellReferences); - // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, - // then modify the formula to use that new reference - foreach ($cellReferences as $cellReference) { - $rowReference = $cellReference[2][0]; - // Empty R reference is the current row - if ($rowReference == '') $rowReference = $row; - // Bracketed R references are relative to the current row - if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]'); - $columnReference = $cellReference[4][0]; - // Empty C reference is the current column - if ($columnReference == '') $columnReference = $column; - // Bracketed C references are relative to the current column - if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]'); - $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; - - $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0])); - } + case 'C': + case 'X': + $column = substr($rowDatum, 1); + break; + case 'R': + case 'Y': + $row = substr($rowDatum, 1); + break; + case 'K': + $cellData = substr($rowDatum, 1); + break; + case 'E': + $cellDataFormula = '='.substr($rowDatum, 1); + // Convert R1C1 style references to A1 style references (but only when not quoted) + $temp = explode('"', $cellDataFormula); + $key = false; + foreach ($temp as &$value) { + // Only count/replace in alternate array entries + if ($key = !$key) { + preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER+PREG_OFFSET_CAPTURE); + // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way + // through the formula from left to right. Reversing means that we work right to left.through + // the formula + $cellReferences = array_reverse($cellReferences); + // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, + // then modify the formula to use that new reference + foreach ($cellReferences as $cellReference) { + $rowReference = $cellReference[2][0]; + // Empty R reference is the current row + if ($rowReference == '') { + $rowReference = $row; } + // Bracketed R references are relative to the current row + if ($rowReference{0} == '[') { + $rowReference = $row + trim($rowReference, '[]'); + } + $columnReference = $cellReference[4][0]; + // Empty C reference is the current column + if ($columnReference == '') { + $columnReference = $column; + } + // Bracketed C references are relative to the current column + if ($columnReference{0} == '[') { + $columnReference = $column + trim($columnReference, '[]'); + } + $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; + + $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); } - unset($value); - // Then rebuild the formula string - $cellDataFormula = implode('"', $temp); - $hasCalculatedValue = true; - break; + } + } + unset($value); + // Then rebuild the formula string + $cellDataFormula = implode('"', $temp); + $hasCalculatedValue = true; + break; } } $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); - $cellData = PHPExcel_Calculation::_unwrapResult($cellData); + $cellData = PHPExcel_Calculation::unwrapResult($cellData); // Set cell value $objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData); if ($hasCalculatedValue) { - $cellData = PHPExcel_Calculation::_unwrapResult($cellData); + $cellData = PHPExcel_Calculation::unwrapResult($cellData); $objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData); } // Read cell formatting @@ -353,40 +375,51 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ $styleData = array(); foreach ($rowData as $rowDatum) { switch ($rowDatum{0}) { - case 'C' : - case 'X' : $column = substr($rowDatum,1); - break; - case 'R' : - case 'Y' : $row = substr($rowDatum,1); - break; - case 'P' : $formatStyle = $rowDatum; - break; - case 'W' : list($startCol, $endCol, $columnWidth) = explode(' ',substr($rowDatum,1)); - break; - case 'S' : $styleSettings = substr($rowDatum,1); - for ($i=0;$i<strlen($styleSettings);++$i) { - switch ($styleSettings{$i}) { - case 'I' : $styleData['font']['italic'] = true; - break; - case 'D' : $styleData['font']['bold'] = true; - break; - case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN; - break; - } - } - break; + case 'C': + case 'X': + $column = substr($rowDatum, 1); + break; + case 'R': + case 'Y': + $row = substr($rowDatum, 1); + break; + case 'P': + $formatStyle = $rowDatum; + break; + case 'W': + list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1)); + break; + case 'S': + $styleSettings = substr($rowDatum, 1); + for ($i=0; $i<strlen($styleSettings); ++$i) { + switch ($styleSettings{$i}) { + case 'I': + $styleData['font']['italic'] = true; + break; + case 'D': + $styleData['font']['bold'] = true; + break; + case 'T': + $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + case 'B': + $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + case 'L': + $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + case 'R': + $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN; + break; + } + } + break; } } if (($formatStyle > '') && ($column > '') && ($row > '')) { $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); - if (isset($this->_formats[$formatStyle])) { - $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]); + if (isset($this->formats[$formatStyle])) { + $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->formats[$formatStyle]); } } if ((!empty($styleData)) && ($column > '') && ($row > '')) { @@ -409,12 +442,14 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ } else { foreach ($rowData as $rowDatum) { switch ($rowDatum{0}) { - case 'C' : - case 'X' : $column = substr($rowDatum,1); - break; - case 'R' : - case 'Y' : $row = substr($rowDatum,1); - break; + case 'C': + case 'X': + $column = substr($rowDatum, 1); + break; + case 'R': + case 'Y': + $row = substr($rowDatum, 1); + break; } } } @@ -432,8 +467,9 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ * * @return int */ - public function getSheetIndex() { - return $this->_sheetIndex; + public function getSheetIndex() + { + return $this->sheetIndex; } /** @@ -442,9 +478,9 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ * @param int $pValue Sheet index * @return PHPExcel_Reader_SYLK */ - public function setSheetIndex($pValue = 0) { - $this->_sheetIndex = $pValue; + public function setSheetIndex($pValue = 0) + { + $this->sheetIndex = $pValue; return $this; } - } diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index 1442425e..7d7de93b 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -39,7 +39,7 @@ class PHPExcel_ReferenceHelper * * @var PHPExcel_ReferenceHelper */ - private static $_instance; + private static $instance; /** * Get an instance of this class @@ -48,11 +48,11 @@ class PHPExcel_ReferenceHelper */ public static function getInstance() { - if (!isset(self::$_instance) || (self::$_instance === null)) { - self::$_instance = new PHPExcel_ReferenceHelper(); + if (!isset(self::$instance) || (self::$instance === null)) { + self::$instance = new PHPExcel_ReferenceHelper(); } - return self::$_instance; + return self::$instance; } /** @@ -163,7 +163,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aBreaks = $pSheet->getBreaks(); ($pNumCols > 0 || $pNumRows > 0) ? @@ -197,7 +197,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aComments = $pSheet->getComments(); $aNewComments = array(); // the new array of all comments @@ -224,7 +224,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aHyperlinkCollection = $pSheet->getHyperlinkCollection(); ($pNumCols > 0 || $pNumRows > 0) ? uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort')); @@ -248,7 +248,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aDataValidationCollection = $pSheet->getDataValidationCollection(); ($pNumCols > 0 || $pNumRows > 0) ? uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort')); @@ -272,7 +272,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aMergeCells = $pSheet->getMergeCells(); $aNewMergeCells = array(); // the new array of all merge cells @@ -293,7 +293,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aProtectedCells = $pSheet->getProtectedCells(); ($pNumCols > 0 || $pNumRows > 0) ? @@ -318,7 +318,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true); if (!empty($aColumnDimensions)) { @@ -343,7 +343,7 @@ class PHPExcel_ReferenceHelper * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function _adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) { $aRowDimensions = array_reverse($pSheet->getRowDimensions(), true); if (!empty($aRowDimensions)) { @@ -513,28 +513,28 @@ class PHPExcel_ReferenceHelper } // Update worksheet: column dimensions - $this->_adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: row dimensions - $this->_adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: page breaks - $this->_adjustPageBreaks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustPageBreaks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: comments - $this->_adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: hyperlinks - $this->_adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: data validations - $this->_adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: merge cells - $this->_adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: protected cells - $this->_adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); + $this->adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows); // Update worksheet: autofilter $autoFilter = $pSheet->getAutoFilter(); @@ -662,7 +662,7 @@ class PHPExcel_ReferenceHelper $toString .= $modified3.':'.$modified4; // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more $column = 100000; - $row = 10000000 + trim($match[3],'$'); + $row = 10000000 + trim($match[3], '$'); $cellIndex = $column.$row; $newCellTokens[$cellIndex] = preg_quote($toString); @@ -785,10 +785,10 @@ class PHPExcel_ReferenceHelper // Is it a range or a single cell? } elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) { // Single cell - return $this->_updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows); + return $this->updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows); } elseif (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) { // Range - return $this->_updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows); + return $this->updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows); } else { // Return original return $pCellRange; @@ -833,7 +833,7 @@ class PHPExcel_ReferenceHelper * @return string Updated cell range * @throws PHPExcel_Exception */ - private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) + private function updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { if (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) { // Update range @@ -843,13 +843,13 @@ class PHPExcel_ReferenceHelper $jc = count($range[$i]); for ($j = 0; $j < $jc; ++$j) { if (ctype_alpha($range[$i][$j])) { - $r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows)); + $r = PHPExcel_Cell::coordinateFromString($this->updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows)); $range[$i][$j] = $r[0]; } elseif (ctype_digit($range[$i][$j])) { - $r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows)); + $r = PHPExcel_Cell::coordinateFromString($this->updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows)); $range[$i][$j] = $r[1]; } else { - $range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows); + $range[$i][$j] = $this->updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows); } } } @@ -871,7 +871,7 @@ class PHPExcel_ReferenceHelper * @return string Updated cell reference * @throws PHPExcel_Exception */ - private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) + private function updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) { // Get coordinates of $pBefore diff --git a/Classes/PHPExcel/Shared/Escher.php b/Classes/PHPExcel/Shared/Escher.php index 948d409b..1aedb9d2 100644 --- a/Classes/PHPExcel/Shared/Escher.php +++ b/Classes/PHPExcel/Shared/Escher.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher { /** @@ -39,14 +32,14 @@ class PHPExcel_Shared_Escher * * @var PHPExcel_Shared_Escher_DggContainer */ - private $_dggContainer; + private $dggContainer; /** * Drawing Container * * @var PHPExcel_Shared_Escher_DgContainer */ - private $_dgContainer; + private $dgContainer; /** * Get Drawing Group Container @@ -55,7 +48,7 @@ class PHPExcel_Shared_Escher */ public function getDggContainer() { - return $this->_dggContainer; + return $this->dggContainer; } /** @@ -65,7 +58,7 @@ class PHPExcel_Shared_Escher */ public function setDggContainer($dggContainer) { - return $this->_dggContainer = $dggContainer; + return $this->dggContainer = $dggContainer; } /** @@ -75,7 +68,7 @@ class PHPExcel_Shared_Escher */ public function getDgContainer() { - return $this->_dgContainer; + return $this->dgContainer; } /** @@ -85,6 +78,6 @@ class PHPExcel_Shared_Escher */ public function setDgContainer($dgContainer) { - return $this->_dgContainer = $dgContainer; + return $this->dgContainer = $dgContainer; } } diff --git a/Classes/PHPExcel/Shared/Escher/DgContainer.php b/Classes/PHPExcel/Shared/Escher/DgContainer.php index e4d17bc1..739cd902 100644 --- a/Classes/PHPExcel/Shared/Escher/DgContainer.php +++ b/Classes/PHPExcel/Shared/Escher/DgContainer.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher_DgContainer * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher_DgContainer - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher_DgContainer { /** @@ -39,44 +32,44 @@ class PHPExcel_Shared_Escher_DgContainer * * @var int */ - private $_dgId; + private $dgId; /** * Last shape index in this drawing * * @var int */ - private $_lastSpId; + private $lastSpId; - private $_spgrContainer = null; + private $spgrContainer = null; public function getDgId() { - return $this->_dgId; + return $this->dgId; } public function setDgId($value) { - $this->_dgId = $value; + $this->dgId = $value; } public function getLastSpId() { - return $this->_lastSpId; + return $this->lastSpId; } public function setLastSpId($value) { - $this->_lastSpId = $value; + $this->lastSpId = $value; } public function getSpgrContainer() { - return $this->_spgrContainer; + return $this->spgrContainer; } public function setSpgrContainer($spgrContainer) { - return $this->_spgrContainer = $spgrContainer; + return $this->spgrContainer = $spgrContainer; } } diff --git a/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php b/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php index efa1683f..49e7d685 100644 --- a/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php +++ b/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher_DgContainer_SpgrContainer * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher_DgContainer_SpgrContainer - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer { /** @@ -39,14 +32,14 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer * * @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer */ - private $_parent; + private $parent; /** * Shape Container collection * * @var array */ - private $_children = array(); + private $children = array(); /** * Set parent Shape Group Container @@ -55,7 +48,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer */ public function setParent($parent) { - $this->_parent = $parent; + $this->parent = $parent; } /** @@ -65,7 +58,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer */ public function getParent() { - return $this->_parent; + return $this->parent; } /** @@ -75,7 +68,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer */ public function addChild($child) { - $this->_children[] = $child; + $this->children[] = $child; $child->setParent($this); } @@ -84,7 +77,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer */ public function getChildren() { - return $this->_children; + return $this->children; } /** @@ -96,7 +89,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer { $allSpContainers = array(); - foreach ($this->_children as $child) { + foreach ($this->children as $child) { if ($child instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) { $allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers()); } else { diff --git a/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index 97136ee0..a1f1a460 100644 --- a/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/Classes/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer { /** @@ -39,84 +32,84 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer * * @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer */ - private $_parent; + private $parent; /** * Is this a group shape? * * @var boolean */ - private $_spgr = false; + private $spgr = false; /** * Shape type * * @var int */ - private $_spType; + private $spType; /** * Shape flag * * @var int */ - private $_spFlag; + private $spFlag; /** * Shape index (usually group shape has index 0, and the rest: 1,2,3...) * * @var boolean */ - private $_spId; + private $spId; /** * Array of options * * @var array */ - private $_OPT; + private $OPT; /** * Cell coordinates of upper-left corner of shape, e.g. 'A1' * * @var string */ - private $_startCoordinates; + private $startCoordinates; /** * Horizontal offset of upper-left corner of shape measured in 1/1024 of column width * * @var int */ - private $_startOffsetX; + private $startOffsetX; /** * Vertical offset of upper-left corner of shape measured in 1/256 of row height * * @var int */ - private $_startOffsetY; + private $startOffsetY; /** * Cell coordinates of bottom-right corner of shape, e.g. 'B2' * * @var string */ - private $_endCoordinates; + private $endCoordinates; /** * Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width * * @var int */ - private $_endOffsetX; + private $endOffsetX; /** * Vertical offset of bottom-right corner of shape measured in 1/256 of row height * * @var int */ - private $_endOffsetY; + private $endOffsetY; /** * Set parent Shape Group Container @@ -125,7 +118,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setParent($parent) { - $this->_parent = $parent; + $this->parent = $parent; } /** @@ -135,7 +128,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getParent() { - return $this->_parent; + return $this->parent; } /** @@ -145,7 +138,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setSpgr($value = false) { - $this->_spgr = $value; + $this->spgr = $value; } /** @@ -155,7 +148,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getSpgr() { - return $this->_spgr; + return $this->spgr; } /** @@ -165,7 +158,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setSpType($value) { - $this->_spType = $value; + $this->spType = $value; } /** @@ -175,7 +168,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getSpType() { - return $this->_spType; + return $this->spType; } /** @@ -185,7 +178,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setSpFlag($value) { - $this->_spFlag = $value; + $this->spFlag = $value; } /** @@ -195,7 +188,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getSpFlag() { - return $this->_spFlag; + return $this->spFlag; } /** @@ -205,7 +198,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setSpId($value) { - $this->_spId = $value; + $this->spId = $value; } /** @@ -215,7 +208,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getSpId() { - return $this->_spId; + return $this->spId; } /** @@ -226,7 +219,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setOPT($property, $value) { - $this->_OPT[$property] = $value; + $this->OPT[$property] = $value; } /** @@ -237,8 +230,8 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getOPT($property) { - if (isset($this->_OPT[$property])) { - return $this->_OPT[$property]; + if (isset($this->OPT[$property])) { + return $this->OPT[$property]; } return null; } @@ -250,7 +243,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getOPTCollection() { - return $this->_OPT; + return $this->OPT; } /** @@ -260,7 +253,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setStartCoordinates($value = 'A1') { - $this->_startCoordinates = $value; + $this->startCoordinates = $value; } /** @@ -270,7 +263,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getStartCoordinates() { - return $this->_startCoordinates; + return $this->startCoordinates; } /** @@ -280,7 +273,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setStartOffsetX($startOffsetX = 0) { - $this->_startOffsetX = $startOffsetX; + $this->startOffsetX = $startOffsetX; } /** @@ -290,7 +283,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getStartOffsetX() { - return $this->_startOffsetX; + return $this->startOffsetX; } /** @@ -300,7 +293,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setStartOffsetY($startOffsetY = 0) { - $this->_startOffsetY = $startOffsetY; + $this->startOffsetY = $startOffsetY; } /** @@ -310,7 +303,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getStartOffsetY() { - return $this->_startOffsetY; + return $this->startOffsetY; } /** @@ -320,7 +313,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setEndCoordinates($value = 'A1') { - $this->_endCoordinates = $value; + $this->endCoordinates = $value; } /** @@ -330,7 +323,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getEndCoordinates() { - return $this->_endCoordinates; + return $this->endCoordinates; } /** @@ -340,7 +333,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setEndOffsetX($endOffsetX = 0) { - $this->_endOffsetX = $endOffsetX; + $this->endOffsetX = $endOffsetX; } /** @@ -350,7 +343,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getEndOffsetX() { - return $this->_endOffsetX; + return $this->endOffsetX; } /** @@ -360,7 +353,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function setEndOffsetY($endOffsetY = 0) { - $this->_endOffsetY = $endOffsetY; + $this->endOffsetY = $endOffsetY; } /** @@ -370,7 +363,7 @@ class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */ public function getEndOffsetY() { - return $this->_endOffsetY; + return $this->endOffsetY; } /** diff --git a/Classes/PHPExcel/Shared/Escher/DggContainer.php b/Classes/PHPExcel/Shared/Escher/DggContainer.php index dae6a5a4..b116b1bd 100644 --- a/Classes/PHPExcel/Shared/Escher/DggContainer.php +++ b/Classes/PHPExcel/Shared/Escher/DggContainer.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher_DggContainer * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher_DggContainer - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher_DggContainer { /** @@ -39,42 +32,42 @@ class PHPExcel_Shared_Escher_DggContainer * * @var int */ - private $_spIdMax; + private $spIdMax; /** * Total number of drawings saved * * @var int */ - private $_cDgSaved; + private $cDgSaved; /** * Total number of shapes saved (including group shapes) * * @var int */ - private $_cSpSaved; + private $cSpSaved; /** * BLIP Store Container * * @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer */ - private $_bstoreContainer; + private $bstoreContainer; /** * Array of options for the drawing group * * @var array */ - private $_OPT = array(); + private $OPT = array(); /** * Array of identifier clusters containg information about the maximum shape identifiers * * @var array */ - private $_IDCLs = array(); + private $IDCLs = array(); /** * Get maximum shape index of all shapes in all drawings (plus one) @@ -83,7 +76,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function getSpIdMax() { - return $this->_spIdMax; + return $this->spIdMax; } /** @@ -93,7 +86,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function setSpIdMax($value) { - $this->_spIdMax = $value; + $this->spIdMax = $value; } /** @@ -103,7 +96,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function getCDgSaved() { - return $this->_cDgSaved; + return $this->cDgSaved; } /** @@ -113,7 +106,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function setCDgSaved($value) { - $this->_cDgSaved = $value; + $this->cDgSaved = $value; } /** @@ -123,7 +116,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function getCSpSaved() { - return $this->_cSpSaved; + return $this->cSpSaved; } /** @@ -133,7 +126,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function setCSpSaved($value) { - $this->_cSpSaved = $value; + $this->cSpSaved = $value; } /** @@ -143,7 +136,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function getBstoreContainer() { - return $this->_bstoreContainer; + return $this->bstoreContainer; } /** @@ -153,7 +146,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function setBstoreContainer($bstoreContainer) { - $this->_bstoreContainer = $bstoreContainer; + $this->bstoreContainer = $bstoreContainer; } /** @@ -164,7 +157,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function setOPT($property, $value) { - $this->_OPT[$property] = $value; + $this->OPT[$property] = $value; } /** @@ -175,8 +168,8 @@ class PHPExcel_Shared_Escher_DggContainer */ public function getOPT($property) { - if (isset($this->_OPT[$property])) { - return $this->_OPT[$property]; + if (isset($this->OPT[$property])) { + return $this->OPT[$property]; } return null; } @@ -188,7 +181,7 @@ class PHPExcel_Shared_Escher_DggContainer */ public function getIDCLs() { - return $this->_IDCLs; + return $this->IDCLs; } /** @@ -198,6 +191,6 @@ class PHPExcel_Shared_Escher_DggContainer */ public function setIDCLs($pValue) { - $this->_IDCLs = $pValue; + $this->IDCLs = $pValue; } } diff --git a/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php b/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php index 3f8f81da..1af2432b 100644 --- a/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php +++ b/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher_DggContainer_BstoreContainer * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher_DggContainer_BstoreContainer - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer { /** @@ -39,7 +32,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer * * @var array */ - private $_BSECollection = array(); + private $BSECollection = array(); /** * Add a BLIP Store Entry @@ -48,7 +41,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer */ public function addBSE($BSE) { - $this->_BSECollection[] = $BSE; + $this->BSECollection[] = $BSE; $BSE->setParent($this); } @@ -59,6 +52,6 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer */ public function getBSECollection() { - return $this->_BSECollection; + return $this->BSECollection; } } diff --git a/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php index 1b0fbe2c..9f8afa5d 100644 --- a/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php +++ b/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,26 +25,18 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE { const BLIPTYPE_ERROR = 0x00; - const BLIPTYPE_UNKNOWN = 0x01; - const BLIPTYPE_EMF = 0x02; - const BLIPTYPE_WMF = 0x03; - const BLIPTYPE_PICT = 0x04; - const BLIPTYPE_JPEG = 0x05; - const BLIPTYPE_PNG = 0x06; - const BLIPTYPE_DIB = 0x07; - const BLIPTYPE_TIFF = 0x11; - const BLIPTYPE_CMYKJPEG = 0x12; + const BLIPTYPE_UNKNOWN = 0x01; + const BLIPTYPE_EMF = 0x02; + const BLIPTYPE_WMF = 0x03; + const BLIPTYPE_PICT = 0x04; + const BLIPTYPE_JPEG = 0x05; + const BLIPTYPE_PNG = 0x06; + const BLIPTYPE_DIB = 0x07; + const BLIPTYPE_TIFF = 0x11; + const BLIPTYPE_CMYKJPEG = 0x12; /** * The parent BLIP Store Entry Container @@ -57,14 +50,14 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE * * @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */ - private $_blip; + private $blip; /** * The BLIP type * * @var int */ - private $_blipType; + private $blipType; /** * Set parent BLIP Store Entry Container @@ -83,7 +76,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */ public function getBlip() { - return $this->_blip; + return $this->blip; } /** @@ -93,7 +86,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */ public function setBlip($blip) { - $this->_blip = $blip; + $this->blip = $blip; $blip->setParent($this); } @@ -104,7 +97,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */ public function getBlipType() { - return $this->_blipType; + return $this->blipType; } /** @@ -114,6 +107,6 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */ public function setBlipType($blipType) { - $this->_blipType = $blipType; + $this->blipType = $blipType; } } diff --git a/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php index 172c03e2..3bcbbbe2 100644 --- a/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php +++ b/Classes/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip - * - * @category PHPExcel - * @package PHPExcel_Shared_Escher - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip { /** @@ -39,14 +32,14 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip * * @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */ - private $_parent; + private $parent; /** * Raw image data * * @var string */ - private $_data; + private $data; /** * Get the raw image data @@ -55,7 +48,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */ public function getData() { - return $this->_data; + return $this->data; } /** @@ -65,7 +58,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */ public function setData($data) { - $this->_data = $data; + $this->data = $data; } /** @@ -75,7 +68,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */ public function setParent($parent) { - $this->_parent = $parent; + $this->parent = $parent; } /** @@ -85,6 +78,6 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */ public function getParent() { - return $this->_parent; + return $this->parent; } } diff --git a/Classes/PHPExcel/Shared/Excel5.php b/Classes/PHPExcel/Shared/Excel5.php index 819092dd..c3ff209f 100644 --- a/Classes/PHPExcel/Shared/Excel5.php +++ b/Classes/PHPExcel/Shared/Excel5.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Shared_Excel5 * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,14 +25,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - -/** - * PHPExcel_Shared_Excel5 - * - * @category PHPExcel - * @package PHPExcel_Shared - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Shared_Excel5 { /** @@ -56,7 +49,7 @@ class PHPExcel_Shared_Excel5 $columnDimension = $columnDimensions[$col]; $width = $columnDimension->getWidth(); $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font); - } else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) { + } elseif ($sheet->getDefaultColumnDimension()->getWidth() != -1) { // then we have default column dimension with explicit width $defaultColumnDimension = $sheet->getDefaultColumnDimension(); $width = $defaultColumnDimension->getWidth(); @@ -98,7 +91,7 @@ class PHPExcel_Shared_Excel5 $rowDimension = $rowDimensions[$row]; $rowHeight = $rowDimension->getRowHeight(); $pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10 - } else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) { + } elseif ($sheet->getDefaultRowDimension()->getRowHeight() != -1) { // then we have a default row dimension with explicit height $defaultRowDimension = $sheet->getDefaultRowDimension(); $rowHeight = $defaultRowDimension->getRowHeight(); diff --git a/Classes/PHPExcel/Shared/Font.php b/Classes/PHPExcel/Shared/Font.php index 23d087e7..7efb3c96 100644 --- a/Classes/PHPExcel/Shared/Font.php +++ b/Classes/PHPExcel/Shared/Font.php @@ -39,7 +39,7 @@ class PHPExcel_Shared_Font const AUTOSIZE_METHOD_APPROX = 'approx'; const AUTOSIZE_METHOD_EXACT = 'exact'; - private static $_autoSizeMethods = array( + private static $autoSizeMethods = array( self::AUTOSIZE_METHOD_APPROX, self::AUTOSIZE_METHOD_EXACT, ); @@ -196,7 +196,7 @@ class PHPExcel_Shared_Font */ public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX) { - if (!in_array($pValue, self::$_autoSizeMethods)) { + if (!in_array($pValue, self::$autoSizeMethods)) { return false; } self::$autoSizeMethod = $pValue; diff --git a/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php b/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php index 31a0b648..4b73e077 100644 --- a/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php @@ -15,8 +15,8 @@ * @author Michael Bommarito * @version 1.2 */ -class CholeskyDecomposition { - +class CholeskyDecomposition +{ /** * Decomposition storage * @var array @@ -38,21 +38,21 @@ class CholeskyDecomposition { */ private $isspd = true; - /** * CholeskyDecomposition * * Class constructor - decomposes symmetric positive definite matrix * @param mixed Matrix square symmetric positive definite matrix */ - public function __construct($A = null) { + public function __construct($A = null) + { if ($A instanceof Matrix) { $this->L = $A->getArray(); $this->m = $A->getRowDimension(); - for($i = 0; $i < $this->m; ++$i) { - for($j = $i; $j < $this->m; ++$j) { - for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = $i; $j < $this->m; ++$j) { + for ($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { $sum -= $this->L[$i][$k] * $this->L[$j][$k]; } if ($i == $j) { @@ -77,35 +77,35 @@ class CholeskyDecomposition { } } // function __construct() - /** * Is the matrix symmetric and positive definite? * * @return boolean */ - public function isSPD() { + public function isSPD() + { return $this->isspd; } // function isSPD() - /** * getL * * Return triangular factor. * @return Matrix Lower triangular matrix */ - public function getL() { + public function getL() + { return new Matrix($this->L); } // function getL() - /** * Solve A*X = B * * @param $B Row-equal matrix * @return Matrix L * L' * X = B */ - public function solve($B = null) { + public function solve($B = null) + { if ($B instanceof Matrix) { if ($B->getRowDimension() == $this->m) { if ($this->isspd) { @@ -145,5 +145,4 @@ class CholeskyDecomposition { throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); } } // function solve() - -} // class CholeskyDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php b/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php index 2f9a9ab6..d4ae3979 100644 --- a/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php @@ -21,8 +21,8 @@ * @license PHP v3.0 * @version 1.1 */ -class EigenvalueDecomposition { - +class EigenvalueDecomposition +{ /** * Row and column dimension (square matrix). * @var int @@ -67,13 +67,13 @@ class EigenvalueDecomposition { private $cdivr; private $cdivi; - /** * Symmetric Householder reduction to tridiagonal form. * * @access private */ - private function tred2 () { + private function tred2() + { // This is derived from the Algol procedures tred2 by // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding @@ -171,7 +171,6 @@ class EigenvalueDecomposition { $this->e[0] = 0.0; } - /** * Symmetric tridiagonal QL algorithm. * @@ -182,22 +181,24 @@ class EigenvalueDecomposition { * * @access private */ - private function tql2() { + private function tql2() + { for ($i = 1; $i < $this->n; ++$i) { $this->e[$i-1] = $this->e[$i]; } $this->e[$this->n-1] = 0.0; $f = 0.0; $tst1 = 0.0; - $eps = pow(2.0,-52.0); + $eps = pow(2.0, -52.0); for ($l = 0; $l < $this->n; ++$l) { // Find small subdiagonal element $tst1 = max($tst1, abs($this->d[$l]) + abs($this->e[$l])); $m = $l; while ($m < $this->n) { - if (abs($this->e[$m]) <= $eps * $tst1) + if (abs($this->e[$m]) <= $eps * $tst1) { break; + } ++$m; } // If m == l, $this->d[l] is an eigenvalue, @@ -211,14 +212,16 @@ class EigenvalueDecomposition { $g = $this->d[$l]; $p = ($this->d[$l+1] - $g) / (2.0 * $this->e[$l]); $r = hypo($p, 1.0); - if ($p < 0) + if ($p < 0) { $r *= -1; + } $this->d[$l] = $this->e[$l] / ($p + $r); $this->d[$l+1] = $this->e[$l] * ($p + $r); $dl1 = $this->d[$l+1]; $h = $g - $this->d[$l]; - for ($i = $l + 2; $i < $this->n; ++$i) + for ($i = $l + 2; $i < $this->n; ++$i) { $this->d[$i] -= $h; + } $f += $h; // Implicit QL transformation. $p = $this->d[$m]; @@ -277,7 +280,6 @@ class EigenvalueDecomposition { } } - /** * Nonsymmetric reduction to Hessenberg form. * @@ -288,7 +290,8 @@ class EigenvalueDecomposition { * * @access private */ - private function orthes () { + private function orthes() + { $low = 0; $high = $this->n-1; @@ -364,13 +367,13 @@ class EigenvalueDecomposition { } } - /** * Performs complex division. * * @access private */ - private function cdiv($xr, $xi, $yr, $yi) { + private function cdiv($xr, $xi, $yr, $yi) + { if (abs($yr) > abs($yi)) { $r = $yi / $yr; $d = $yr + $r * $yi; @@ -384,7 +387,6 @@ class EigenvalueDecomposition { } } - /** * Nonsymmetric reduction from Hessenberg to real Schur form. * @@ -395,7 +397,8 @@ class EigenvalueDecomposition { * * @access private */ - private function hqr2 () { + private function hqr2() + { // Initialize $nn = $this->n; $n = $nn - 1; @@ -408,7 +411,7 @@ class EigenvalueDecomposition { $norm = 0.0; for ($i = 0; $i < $nn; ++$i) { - if (($i < $low) OR ($i > $high)) { + if (($i < $low) or ($i > $high)) { $this->d[$i] = $this->H[$i][$i]; $this->e[$i] = 0.0; } @@ -441,7 +444,7 @@ class EigenvalueDecomposition { --$n; $iter = 0; // Two roots found - } else if ($l == $n-1) { + } elseif ($l == $n-1) { $w = $this->H[$n][$n-1] * $this->H[$n-1][$n]; $p = ($this->H[$n-1][$n-1] - $this->H[$n][$n]) / 2.0; $q = $p * $p + $w; @@ -477,7 +480,7 @@ class EigenvalueDecomposition { $this->H[$n][$j] = $q * $this->H[$n][$j] - $p * $z; } // Column modification - for ($i = 0; $i <= n; ++$i) { + for ($i = 0; $i <= $n; ++$i) { $z = $this->H[$i][$n-1]; $this->H[$i][$n-1] = $q * $z + $p * $this->H[$i][$n]; $this->H[$i][$n] = $q * $this->H[$i][$n] - $p * $z; @@ -684,7 +687,7 @@ class EigenvalueDecomposition { } } // Complex vector - } else if ($q < 0) { + } elseif ($q < 0) { $l = $n-1; // Last vector component imaginary so matrix is triangular if (abs($this->H[$n][$n-1]) > abs($this->H[$n-1][$n])) { @@ -738,7 +741,7 @@ class EigenvalueDecomposition { } } // Overflow control - $t = max(abs($this->H[$i][$n-1]),abs($this->H[$i][$n])); + $t = max(abs($this->H[$i][$n-1]), abs($this->H[$i][$n])); if (($eps * $t) * $t > 1) { for ($j = $i; $j <= $n; ++$j) { $this->H[$j][$n-1] = $this->H[$j][$n-1] / $t; @@ -771,7 +774,6 @@ class EigenvalueDecomposition { } } // end hqr2 - /** * Constructor: Check for symmetry, then construct the eigenvalue decomposition * @@ -779,7 +781,8 @@ class EigenvalueDecomposition { * @param A Square matrix * @return Structure to access D and V. */ - public function __construct($Arg) { + public function __construct($Arg) + { $this->A = $Arg->getArray(); $this->n = $Arg->getColumnDimension(); @@ -806,47 +809,47 @@ class EigenvalueDecomposition { } } - /** * Return the eigenvector matrix * * @access public * @return V */ - public function getV() { + public function getV() + { return new Matrix($this->V, $this->n, $this->n); } - /** * Return the real parts of the eigenvalues * * @access public * @return real(diag(D)) */ - public function getRealEigenvalues() { + public function getRealEigenvalues() + { return $this->d; } - /** * Return the imaginary parts of the eigenvalues * * @access public * @return imag(diag(D)) */ - public function getImagEigenvalues() { + public function getImagEigenvalues() + { return $this->e; } - /** * Return the block diagonal eigenvalue matrix * * @access public * @return D */ - public function getD() { + public function getD() + { for ($i = 0; $i < $this->n; ++$i) { $D[$i] = array_fill(0, $this->n, 0.0); $D[$i][$i] = $this->d[$i]; @@ -858,5 +861,4 @@ class EigenvalueDecomposition { } return new Matrix($D); } - -} // class EigenvalueDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php b/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php index bffda2aa..64290fe7 100644 --- a/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php @@ -18,8 +18,8 @@ * @version 1.1 * @license PHP v3.0 */ -class PHPExcel_Shared_JAMA_LUDecomposition { - +class PHPExcel_Shared_JAMA_LUDecomposition +{ const MatrixSingularException = "Can only perform operation on singular matrix."; const MatrixSquareException = "Mismatched Row dimension"; @@ -53,14 +53,14 @@ class PHPExcel_Shared_JAMA_LUDecomposition { */ private $piv = array(); - /** * LU Decomposition constructor. * * @param $A Rectangular matrix * @return Structure to access L, U and piv. */ - public function __construct($A) { + public function __construct($A) + { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) { // Use a "left-looking", dot-product, Crout/Doolittle algorithm. $this->LU = $A->getArray(); @@ -119,13 +119,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition { } } // function __construct() - /** * Get lower triangular factor. * * @return array Lower triangular factor */ - public function getL() { + public function getL() + { for ($i = 0; $i < $this->m; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i > $j) { @@ -140,13 +140,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition { return new PHPExcel_Shared_JAMA_Matrix($L); } // function getL() - /** * Get upper triangular factor. * * @return array Upper triangular factor */ - public function getU() { + public function getU() + { for ($i = 0; $i < $this->n; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i <= $j) { @@ -159,33 +159,33 @@ class PHPExcel_Shared_JAMA_LUDecomposition { return new PHPExcel_Shared_JAMA_Matrix($U); } // function getU() - /** * Return pivot permutation vector. * * @return array Pivot vector */ - public function getPivot() { + public function getPivot() + { return $this->piv; } // function getPivot() - /** * Alias for getPivot * * @see getPivot */ - public function getDoublePivot() { + public function getDoublePivot() + { return $this->getPivot(); } // function getDoublePivot() - /** * Is the matrix nonsingular? * * @return true if U, and hence A, is nonsingular. */ - public function isNonsingular() { + public function isNonsingular() + { for ($j = 0; $j < $this->n; ++$j) { if ($this->LU[$j][$j] == 0) { return false; @@ -194,13 +194,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition { return true; } // function isNonsingular() - /** * Count determinants * * @return array d matrix deterninat */ - public function det() { + public function det() + { if ($this->m == $this->n) { $d = $this->pivsign; for ($j = 0; $j < $this->n; ++$j) { @@ -212,7 +212,6 @@ class PHPExcel_Shared_JAMA_LUDecomposition { } } // function det() - /** * Solve A*X = B * @@ -221,7 +220,8 @@ class PHPExcel_Shared_JAMA_LUDecomposition { * @PHPExcel_Calculation_Exception IllegalArgumentException Matrix row dimensions must agree. * @PHPExcel_Calculation_Exception RuntimeException Matrix is singular. */ - public function solve($B) { + public function solve($B) + { if ($B->getRowDimension() == $this->m) { if ($this->isNonsingular()) { // Copy right hand side with pivoting @@ -254,5 +254,4 @@ class PHPExcel_Shared_JAMA_LUDecomposition { throw new PHPExcel_Calculation_Exception(self::MatrixSquareException); } } // function solve() - -} // class PHPExcel_Shared_JAMA_LUDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/Matrix.php b/Classes/PHPExcel/Shared/JAMA/Matrix.php index 2ab40f22..b39d414c 100644 --- a/Classes/PHPExcel/Shared/JAMA/Matrix.php +++ b/Classes/PHPExcel/Shared/JAMA/Matrix.php @@ -24,9 +24,8 @@ if (!defined('PHPEXCEL_ROOT')) { * @license PHP v3.0 * @see http://math.nist.gov/javanumerics/jama/ */ -class PHPExcel_Shared_JAMA_Matrix { - - +class PHPExcel_Shared_JAMA_Matrix +{ const PolymorphicArgumentException = "Invalid argument pattern for polymorphic function."; const ArgumentTypeException = "Invalid argument type."; const ArgumentBoundsException = "Invalid argument range."; @@ -57,13 +56,13 @@ class PHPExcel_Shared_JAMA_Matrix { */ private $n; - /** * Polymorphic constructor * * As PHP has no support for polymorphic constructors, we hack our own sort of polymorphism using func_num_args, func_get_arg, and gettype. In essence, we're just implementing a simple RTTI filter and calling the appropriate constructor. */ - public function __construct() { + public function __construct() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); @@ -71,80 +70,79 @@ class PHPExcel_Shared_JAMA_Matrix { switch ($match) { //Rectangular matrix - m x n initialized from 2D array case 'array': - $this->m = count($args[0]); - $this->n = count($args[0][0]); - $this->A = $args[0]; - break; + $this->m = count($args[0]); + $this->n = count($args[0][0]); + $this->A = $args[0]; + break; //Square matrix - n x n case 'integer': - $this->m = $args[0]; - $this->n = $args[0]; - $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); - break; + $this->m = $args[0]; + $this->n = $args[0]; + $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); + break; //Rectangular matrix - m x n case 'integer,integer': - $this->m = $args[0]; - $this->n = $args[1]; - $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); - break; + $this->m = $args[0]; + $this->n = $args[1]; + $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); + break; //Rectangular matrix - m x n initialized from packed array case 'array,integer': - $this->m = $args[1]; - if ($this->m != 0) { - $this->n = count($args[0]) / $this->m; - } else { - $this->n = 0; - } - if (($this->m * $this->n) == count($args[0])) { - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $this->A[$i][$j] = $args[0][$i + $j * $this->m]; - } + $this->m = $args[1]; + if ($this->m != 0) { + $this->n = count($args[0]) / $this->m; + } else { + $this->n = 0; + } + if (($this->m * $this->n) == count($args[0])) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { + $this->A[$i][$j] = $args[0][$i + $j * $this->m]; } - } else { - throw new PHPExcel_Calculation_Exception(self::ArrayLengthException); } - break; + } else { + throw new PHPExcel_Calculation_Exception(self::ArrayLengthException); + } + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } } else { throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function __construct() - /** * getArray * * @return array Matrix array */ - public function getArray() { + public function getArray() + { return $this->A; } // function getArray() - /** * getRowDimension * * @return int Row dimension */ - public function getRowDimension() { + public function getRowDimension() + { return $this->m; } // function getRowDimension() - /** * getColumnDimension * * @return int Column dimension */ - public function getColumnDimension() { + public function getColumnDimension() + { return $this->n; } // function getColumnDimension() - /** * get * @@ -153,11 +151,11 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $j Column position * @return mixed Element (int/float/double) */ - public function get($i = null, $j = null) { + public function get($i = null, $j = null) + { return $this->A[$i][$j]; } // function get() - /** * getMatrix * @@ -168,7 +166,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $jF Final column index * @return Matrix Submatrix */ - public function getMatrix() { + public function getMatrix() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); @@ -176,92 +175,139 @@ class PHPExcel_Shared_JAMA_Matrix { switch ($match) { //A($i0...; $j0...) case 'integer,integer': - list($i0, $j0) = $args; - if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = $i0; $i < $this->m; ++$i) { - for($j = $j0; $j < $this->n; ++$j) { - $R->set($i, $j, $this->A[$i][$j]); - } + list($i0, $j0) = $args; + if ($i0 >= 0) { + $m = $this->m - $i0; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + if ($j0 >= 0) { + $n = $this->n - $j0; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for ($i = $i0; $i < $this->m; ++$i) { + for ($j = $j0; $j < $this->n; ++$j) { + $R->set($i, $j, $this->A[$i][$j]); } - return $R; - break; + } + return $R; + break; //A($i0...$iF; $j0...$jF) case 'integer,integer,integer,integer': - list($i0, $iF, $j0, $jF) = $args; - if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1); - for($i = $i0; $i <= $iF; ++$i) { - for($j = $j0; $j <= $jF; ++$j) { - $R->set($i - $i0, $j - $j0, $this->A[$i][$j]); - } + list($i0, $iF, $j0, $jF) = $args; + if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { + $m = $iF - $i0; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { + $n = $jF - $j0; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + $R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1); + for ($i = $i0; $i <= $iF; ++$i) { + for ($j = $j0; $j <= $jF; ++$j) { + $R->set($i - $i0, $j - $j0, $this->A[$i][$j]); } - return $R; - break; + } + return $R; + break; //$R = array of row indices; $C = array of column indices case 'array,array': - list($RL, $CL) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = 0; $i < $m; ++$i) { - for($j = 0; $j < $n; ++$j) { - $R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]); - } + list($RL, $CL) = $args; + if (count($RL) > 0) { + $m = count($RL); + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + if (count($CL) > 0) { + $n = count($CL); + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for ($i = 0; $i < $m; ++$i) { + for ($j = 0; $j < $n; ++$j) { + $R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]); } - return $R; - break; + } + return $R; + break; //$RL = array of row indices; $CL = array of column indices case 'array,array': - list($RL, $CL) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = 0; $i < $m; ++$i) { - for($j = 0; $j < $n; ++$j) { - $R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]); - } + list($RL, $CL) = $args; + if (count($RL) > 0) { + $m = count($RL); + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + if (count($CL) > 0) { + $n = count($CL); + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for ($i = 0; $i < $m; ++$i) { + for ($j = 0; $j < $n; ++$j) { + $R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]); } - return $R; - break; + } + return $R; + break; //A($i0...$iF); $CL = array of column indices case 'integer,integer,array': - list($i0, $iF, $CL) = $args; - if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = $i0; $i < $iF; ++$i) { - for($j = 0; $j < $n; ++$j) { - $R->set($i - $i0, $j, $this->A[$RL[$i]][$j]); - } + list($i0, $iF, $CL) = $args; + if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { + $m = $iF - $i0; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + if (count($CL) > 0) { + $n = count($CL); + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for ($i = $i0; $i < $iF; ++$i) { + for ($j = 0; $j < $n; ++$j) { + $R->set($i - $i0, $j, $this->A[$RL[$i]][$j]); } - return $R; - break; + } + return $R; + break; //$RL = array of row indices case 'array,integer,integer': - list($RL, $j0, $jF) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n+1); - for($i = 0; $i < $m; ++$i) { - for($j = $j0; $j <= $jF; ++$j) { - $R->set($i, $j - $j0, $this->A[$RL[$i]][$j]); - } + list($RL, $j0, $jF) = $args; + if (count($RL) > 0) { + $m = count($RL); + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { + $n = $jF - $j0; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); + } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n+1); + for ($i = 0; $i < $m; ++$i) { + for ($j = $j0; $j <= $jF; ++$j) { + $R->set($i, $j - $j0, $this->A[$RL[$i]][$j]); } - return $R; - break; + } + return $R; + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } } else { throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function getMatrix() - /** * checkMatrixDimensions * @@ -269,7 +315,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param Matrix $B Matrix B * @return boolean */ - public function checkMatrixDimensions($B = null) { + public function checkMatrixDimensions($B = null) + { if ($B instanceof PHPExcel_Shared_JAMA_Matrix) { if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) { return true; @@ -281,8 +328,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function checkMatrixDimensions() - - /** * set * @@ -292,12 +337,12 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $c Int/float/double value * @return mixed Element (int/float/double) */ - public function set($i = null, $j = null, $c = null) { + public function set($i = null, $j = null, $c = null) + { // Optimized set version just has this $this->A[$i][$j] = $c; } // function set() - /** * identity * @@ -306,11 +351,11 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $n Column dimension * @return Matrix Identity matrix */ - public function identity($m = null, $n = null) { + public function identity($m = null, $n = null) + { return $this->diagonal($m, $n, 1); } // function identity() - /** * diagonal * @@ -320,15 +365,15 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $c Diagonal value * @return Matrix Diagonal matrix */ - public function diagonal($m = null, $n = null, $c = 1) { + public function diagonal($m = null, $n = null, $c = 1) + { $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = 0; $i < $m; ++$i) { + for ($i = 0; $i < $m; ++$i) { $R->set($i, $i, $c); } return $R; } // function diagonal() - /** * getMatrixByRow * @@ -337,7 +382,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $iF Final row index * @return Matrix Submatrix */ - public function getMatrixByRow($i0 = null, $iF = null) { + public function getMatrixByRow($i0 = null, $iF = null) + { if (is_int($i0)) { if (is_int($iF)) { return $this->getMatrix($i0, 0, $iF + 1, $this->n); @@ -349,7 +395,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function getMatrixByRow() - /** * getMatrixByCol * @@ -358,7 +403,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $iF Final column index * @return Matrix Submatrix */ - public function getMatrixByCol($j0 = null, $jF = null) { + public function getMatrixByCol($j0 = null, $jF = null) + { if (is_int($j0)) { if (is_int($jF)) { return $this->getMatrix(0, $j0, $this->m, $jF + 1); @@ -370,50 +416,49 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function getMatrixByCol() - /** * transpose * * Tranpose matrix * @return Matrix Transposed matrix */ - public function transpose() { + public function transpose() + { $R = new PHPExcel_Shared_JAMA_Matrix($this->n, $this->m); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { $R->set($j, $i, $this->A[$i][$j]); } } return $R; } // function transpose() - /** * trace * * Sum of diagonal elements * @return float Sum of diagonal elements */ - public function trace() { + public function trace() + { $s = 0; $n = min($this->m, $this->n); - for($i = 0; $i < $n; ++$i) { + for ($i = 0; $i < $n; ++$i) { $s += $this->A[$i][$i]; } return $s; } // function trace() - /** * uminus * * Unary minus matrix -A * @return Matrix Unary minus matrix */ - public function uminus() { + public function uminus() + { } // function uminus() - /** * plus * @@ -421,25 +466,30 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function plus() { + public function plus() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { $M->set($i, $j, $M->get($i, $j) + $this->A[$i][$j]); } } @@ -449,7 +499,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function plus() - /** * plusEquals * @@ -457,33 +506,38 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function plusEquals() { + public function plusEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { + $validValues = true; $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { - $this->A[$i][$j] = trim($this->A[$i][$j],'"'); + $this->A[$i][$j] = trim($this->A[$i][$j], '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { - $value = trim($value,'"'); + $value = trim($value, '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value); } if ($validValues) { @@ -499,7 +553,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function plusEquals() - /** * minus * @@ -507,25 +560,30 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function minus() { + public function minus() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { $M->set($i, $j, $M->get($i, $j) - $this->A[$i][$j]); } } @@ -535,7 +593,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function minus() - /** * minusEquals * @@ -543,33 +600,38 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function minusEquals() { + public function minusEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { + $validValues = true; $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { - $this->A[$i][$j] = trim($this->A[$i][$j],'"'); + $this->A[$i][$j] = trim($this->A[$i][$j], '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { - $value = trim($value,'"'); + $value = trim($value, '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value); } if ($validValues) { @@ -585,7 +647,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function minusEquals() - /** * arrayTimes * @@ -594,25 +655,30 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Cij */ - public function arrayTimes() { + public function arrayTimes() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { $M->set($i, $j, $M->get($i, $j) * $this->A[$i][$j]); } } @@ -622,7 +688,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function arrayTimes() - /** * arrayTimesEquals * @@ -631,33 +696,38 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Aij */ - public function arrayTimesEquals() { + public function arrayTimesEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { + $validValues = true; $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { - $this->A[$i][$j] = trim($this->A[$i][$j],'"'); + $this->A[$i][$j] = trim($this->A[$i][$j], '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { - $value = trim($value,'"'); + $value = trim($value, '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value); } if ($validValues) { @@ -673,7 +743,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function arrayTimesEquals() - /** * arrayRightDivide * @@ -682,33 +751,38 @@ class PHPExcel_Shared_JAMA_Matrix { * @param Matrix $B Matrix B * @return Matrix Division result */ - public function arrayRightDivide() { + public function arrayRightDivide() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { + $validValues = true; $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { - $this->A[$i][$j] = trim($this->A[$i][$j],'"'); + $this->A[$i][$j] = trim($this->A[$i][$j], '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { - $value = trim($value,'"'); + $value = trim($value, '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value); } if ($validValues) { @@ -738,25 +812,30 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Aij */ - public function arrayRightDivideEquals() { + public function arrayRightDivideEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { $this->A[$i][$j] = $this->A[$i][$j] / $M->get($i, $j); } } @@ -775,25 +854,30 @@ class PHPExcel_Shared_JAMA_Matrix { * @param Matrix $B Matrix B * @return Matrix Division result */ - public function arrayLeftDivide() { + public function arrayLeftDivide() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { $M->set($i, $j, $M->get($i, $j) / $this->A[$i][$j]); } } @@ -812,25 +896,30 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Aij */ - public function arrayLeftDivideEquals() { + public function arrayLeftDivideEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { $this->A[$i][$j] = $M->get($i, $j) / $this->A[$i][$j]; } } @@ -848,90 +937,94 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $n Matrix/Array/Scalar * @return Matrix Product */ - public function times() { + public function times() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - if ($this->n == $B->m) { - $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); - for($j = 0; $j < $B->n; ++$j) { + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $B = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + if ($this->n == $B->m) { + $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); + for ($j = 0; $j < $B->n; ++$j) { + for ($k = 0; $k < $this->n; ++$k) { + $Bcolj[$k] = $B->A[$k][$j]; + } + for ($i = 0; $i < $this->m; ++$i) { + $Arowi = $this->A[$i]; + $s = 0; for ($k = 0; $k < $this->n; ++$k) { - $Bcolj[$k] = $B->A[$k][$j]; - } - for($i = 0; $i < $this->m; ++$i) { - $Arowi = $this->A[$i]; - $s = 0; - for($k = 0; $k < $this->n; ++$k) { - $s += $Arowi[$k] * $Bcolj[$k]; - } - $C->A[$i][$j] = $s; + $s += $Arowi[$k] * $Bcolj[$k]; } + $C->A[$i][$j] = $s; } - return $C; - } else { - throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); } - break; + return $C; + } else { + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); + } + break; case 'array': - $B = new PHPExcel_Shared_JAMA_Matrix($args[0]); - if ($this->n == $B->m) { - $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $s = "0"; - for($k = 0; $k < $C->n; ++$k) { - $s += $this->A[$i][$k] * $B->A[$k][$j]; - } - $C->A[$i][$j] = $s; + $B = new PHPExcel_Shared_JAMA_Matrix($args[0]); + if ($this->n == $B->m) { + $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); + for ($i = 0; $i < $C->m; ++$i) { + for ($j = 0; $j < $C->n; ++$j) { + $s = "0"; + for ($k = 0; $k < $C->n; ++$k) { + $s += $this->A[$i][$k] * $B->A[$k][$j]; } + $C->A[$i][$j] = $s; } - return $C; - } else { - throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); } - return $M; - break; + return $C; + } else { + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); + } + return $M; + break; case 'integer': - $C = new PHPExcel_Shared_JAMA_Matrix($this->A); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $C->A[$i][$j] *= $args[0]; - } + $C = new PHPExcel_Shared_JAMA_Matrix($this->A); + for ($i = 0; $i < $C->m; ++$i) { + for ($j = 0; $j < $C->n; ++$j) { + $C->A[$i][$j] *= $args[0]; } - return $C; - break; + } + return $C; + break; case 'double': - $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $this->n); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $C->A[$i][$j] = $args[0] * $this->A[$i][$j]; - } + $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $this->n); + for ($i = 0; $i < $C->m; ++$i) { + for ($j = 0; $j < $C->n; ++$j) { + $C->A[$i][$j] = $args[0] * $this->A[$i][$j]; } - return $C; - break; + } + return $C; + break; case 'float': - $C = new PHPExcel_Shared_JAMA_Matrix($this->A); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $C->A[$i][$j] *= $args[0]; - } + $C = new PHPExcel_Shared_JAMA_Matrix($this->A); + for ($i = 0; $i < $C->m; ++$i) { + for ($j = 0; $j < $C->n; ++$j) { + $C->A[$i][$j] *= $args[0]; } - return $C; - break; + } + return $C; + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } } else { throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function times() - /** * power * @@ -939,33 +1032,38 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function power() { + public function power() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { + $validValues = true; $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { - $this->A[$i][$j] = trim($this->A[$i][$j],'"'); + $this->A[$i][$j] = trim($this->A[$i][$j], '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { - $value = trim($value,'"'); + $value = trim($value, '"'); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value); } if ($validValues) { @@ -981,7 +1079,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function power() - /** * concat * @@ -989,25 +1086,30 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function concat() { + public function concat() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $this->A[$i][$j] = trim($this->A[$i][$j],'"').trim($M->get($i, $j),'"'); + for ($i = 0; $i < $this->m; ++$i) { + for ($j = 0; $j < $this->n; ++$j) { + $this->A[$i][$j] = trim($this->A[$i][$j], '"').trim($M->get($i, $j), '"'); } } return $this; @@ -1016,14 +1118,14 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function concat() - /** * Solve A*X = B. * * @param Matrix $B Right hand side * @return Matrix ... Solution if A is square, least squares solution otherwise */ - public function solve($B) { + public function solve($B) + { if ($this->m == $this->n) { $LU = new PHPExcel_Shared_JAMA_LUDecomposition($this); return $LU->solve($B); @@ -1033,24 +1135,24 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function solve() - /** * Matrix inverse or pseudoinverse. * * @return Matrix ... Inverse(A) if A is square, pseudoinverse otherwise. */ - public function inverse() { + public function inverse() + { return $this->solve($this->identity($this->m, $this->m)); } // function inverse() - /** * det * * Calculate determinant * @return float Determinant */ - public function det() { + public function det() + { $L = new PHPExcel_Shared_JAMA_LUDecomposition($this); return $L->det(); } // function det() diff --git a/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php b/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php index fa832caf..b20e5a07 100644 --- a/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php @@ -16,8 +16,8 @@ * @license PHP v3.0 * @version 1.1 */ -class PHPExcel_Shared_JAMA_QRDecomposition { - +class PHPExcel_Shared_JAMA_QRDecomposition +{ const MatrixRankException = "Can only perform operation on full-rank matrix."; /** @@ -51,7 +51,8 @@ class PHPExcel_Shared_JAMA_QRDecomposition { * @param matrix $A Rectangular matrix * @return Structure to access R and the Householder vectors and compute Q. */ - public function __construct($A) { + public function __construct($A) + { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) { // Initialize. $this->QR = $A->getArrayCopy(); @@ -98,7 +99,8 @@ class PHPExcel_Shared_JAMA_QRDecomposition { * * @return boolean true if R, and hence A, has full rank, else false. */ - public function isFullRank() { + public function isFullRank() + { for ($j = 0; $j < $this->n; ++$j) { if ($this->Rdiag[$j] == 0) { return false; @@ -107,13 +109,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return true; } // function isFullRank() - /** * Return the Householder vectors * * @return Matrix Lower trapezoidal matrix whose columns define the reflections */ - public function getH() { + public function getH() + { for ($i = 0; $i < $this->m; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i >= $j) { @@ -126,13 +128,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return new PHPExcel_Shared_JAMA_Matrix($H); } // function getH() - /** * Return the upper triangular factor * * @return Matrix upper triangular factor */ - public function getR() { + public function getR() + { for ($i = 0; $i < $this->n; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i < $j) { @@ -147,13 +149,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return new PHPExcel_Shared_JAMA_Matrix($R); } // function getR() - /** * Generate and return the (economy-sized) orthogonal factor * * @return Matrix orthogonal factor */ - public function getQ() { + public function getQ() + { for ($k = $this->n-1; $k >= 0; --$k) { for ($i = 0; $i < $this->m; ++$i) { $Q[$i][$k] = 0.0; @@ -184,14 +186,14 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return new PHPExcel_Shared_JAMA_Matrix($Q); } // function getQ() - /** * Least squares solution of A*X = B * * @param Matrix $B A Matrix with as many rows as A and any number of columns. * @return Matrix Matrix that minimizes the two norm of Q*R*X-B. */ - public function solve($B) { + public function solve($B) + { if ($B->getRowDimension() == $this->m) { if ($this->isFullRank()) { // Copy right hand side @@ -230,5 +232,4 @@ class PHPExcel_Shared_JAMA_QRDecomposition { throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException); } } // function solve() - -} // PHPExcel_Shared_JAMA_class QRDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php b/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php index f20668ac..f57d122c 100644 --- a/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php @@ -17,8 +17,8 @@ * @license PHP v3.0 * @version 1.1 */ -class SingularValueDecomposition { - +class SingularValueDecomposition +{ /** * Internal storage of U. * @var array @@ -49,7 +49,6 @@ class SingularValueDecomposition { */ private $n; - /** * Construct the singular value decomposition * @@ -58,8 +57,8 @@ class SingularValueDecomposition { * @param $A Rectangular matrix * @return Structure to access U, S and V. */ - public function __construct($Arg) { - + public function __construct($Arg) + { // Initialize. $A = $Arg->getArrayCopy(); $this->m = $Arg->getRowDimension(); @@ -75,7 +74,6 @@ class SingularValueDecomposition { // Reduce A to bidiagonal form, storing the diagonal elements // in s and the super-diagonal elements in e. for ($k = 0; $k < max($nct, $nrt); ++$k) { - if ($k < $nct) { // Compute the transformation for the k-th column and // place the k-th diagonal in s[$k]. @@ -113,7 +111,7 @@ class SingularValueDecomposition { } } - if ($wantu AND ($k < $nct)) { + if ($wantu and ($k < $nct)) { // Place the transformation in U for subsequent back // multiplication. for ($i = $k; $i < $this->m; ++$i) { @@ -139,7 +137,7 @@ class SingularValueDecomposition { $e[$k+1] += 1.0; } $e[$k] = -$e[$k]; - if (($k+1 < $this->m) AND ($e[$k] != 0.0)) { + if (($k+1 < $this->m) and ($e[$k] != 0.0)) { // Apply the transformation. for ($i = $k+1; $i < $this->m; ++$i) { $work[$i] = 0.0; @@ -198,7 +196,7 @@ class SingularValueDecomposition { $this->U[$i][$j] += $t * $this->U[$i][$k]; } } - for ($i = $k; $i < $this->m; ++$i ) { + for ($i = $k; $i < $this->m; ++$i) { $this->U[$i][$k] = -$this->U[$i][$k]; } $this->U[$k][$k] = 1.0 + $this->U[$k][$k]; @@ -217,7 +215,7 @@ class SingularValueDecomposition { // If required, generate V. if ($wantv) { for ($k = $this->n - 1; $k >= 0; --$k) { - if (($k < $nrt) AND ($e[$k] != 0.0)) { + if (($k < $nrt) and ($e[$k] != 0.0)) { for ($j = $k + 1; $j < $nu; ++$j) { $t = 0; for ($i = $k + 1; $i < $this->n; ++$i) { @@ -268,14 +266,14 @@ class SingularValueDecomposition { break; } $t = ($ks != $p ? abs($e[$ks]) : 0.) + ($ks != $k + 1 ? abs($e[$ks-1]) : 0.); - if (abs($this->s[$ks]) <= $eps * $t) { + if (abs($this->s[$ks]) <= $eps * $t) { $this->s[$ks] = 0.0; break; } } if ($ks == $k) { $kase = 3; - } else if ($ks == $p-1) { + } elseif ($ks == $p-1) { $kase = 1; } else { $kase = 2; @@ -288,145 +286,143 @@ class SingularValueDecomposition { switch ($kase) { // Deflate negligible s(p). case 1: - $f = $e[$p-2]; - $e[$p-2] = 0.0; - for ($j = $p - 2; $j >= $k; --$j) { - $t = hypo($this->s[$j], $f); - $cs = $this->s[$j] / $t; - $sn = $f / $t; - $this->s[$j] = $t; - if ($j != $k) { - $f = -$sn * $e[$j-1]; - $e[$j-1] = $cs * $e[$j-1]; - } - if ($wantv) { - for ($i = 0; $i < $this->n; ++$i) { - $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$p-1]; - $this->V[$i][$p-1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$p-1]; - $this->V[$i][$j] = $t; - } + $f = $e[$p-2]; + $e[$p-2] = 0.0; + for ($j = $p - 2; $j >= $k; --$j) { + $t = hypo($this->s[$j], $f); + $cs = $this->s[$j] / $t; + $sn = $f / $t; + $this->s[$j] = $t; + if ($j != $k) { + $f = -$sn * $e[$j-1]; + $e[$j-1] = $cs * $e[$j-1]; + } + if ($wantv) { + for ($i = 0; $i < $this->n; ++$i) { + $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$p-1]; + $this->V[$i][$p-1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$p-1]; + $this->V[$i][$j] = $t; } } - break; + } + break; // Split at negligible s(k). case 2: - $f = $e[$k-1]; - $e[$k-1] = 0.0; - for ($j = $k; $j < $p; ++$j) { - $t = hypo($this->s[$j], $f); - $cs = $this->s[$j] / $t; - $sn = $f / $t; - $this->s[$j] = $t; - $f = -$sn * $e[$j]; - $e[$j] = $cs * $e[$j]; - if ($wantu) { - for ($i = 0; $i < $this->m; ++$i) { - $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$k-1]; - $this->U[$i][$k-1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$k-1]; - $this->U[$i][$j] = $t; - } + $f = $e[$k-1]; + $e[$k-1] = 0.0; + for ($j = $k; $j < $p; ++$j) { + $t = hypo($this->s[$j], $f); + $cs = $this->s[$j] / $t; + $sn = $f / $t; + $this->s[$j] = $t; + $f = -$sn * $e[$j]; + $e[$j] = $cs * $e[$j]; + if ($wantu) { + for ($i = 0; $i < $this->m; ++$i) { + $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$k-1]; + $this->U[$i][$k-1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$k-1]; + $this->U[$i][$j] = $t; } } - break; + } + break; // Perform one qr step. case 3: - // Calculate the shift. - $scale = max(max(max(max( - abs($this->s[$p-1]),abs($this->s[$p-2])),abs($e[$p-2])), - abs($this->s[$k])), abs($e[$k])); - $sp = $this->s[$p-1] / $scale; - $spm1 = $this->s[$p-2] / $scale; - $epm1 = $e[$p-2] / $scale; - $sk = $this->s[$k] / $scale; - $ek = $e[$k] / $scale; - $b = (($spm1 + $sp) * ($spm1 - $sp) + $epm1 * $epm1) / 2.0; - $c = ($sp * $epm1) * ($sp * $epm1); - $shift = 0.0; - if (($b != 0.0) || ($c != 0.0)) { - $shift = sqrt($b * $b + $c); - if ($b < 0.0) { - $shift = -$shift; - } - $shift = $c / ($b + $shift); + // Calculate the shift. + $scale = max(max(max(max(abs($this->s[$p-1]), abs($this->s[$p-2])), abs($e[$p-2])), abs($this->s[$k])), abs($e[$k])); + $sp = $this->s[$p-1] / $scale; + $spm1 = $this->s[$p-2] / $scale; + $epm1 = $e[$p-2] / $scale; + $sk = $this->s[$k] / $scale; + $ek = $e[$k] / $scale; + $b = (($spm1 + $sp) * ($spm1 - $sp) + $epm1 * $epm1) / 2.0; + $c = ($sp * $epm1) * ($sp * $epm1); + $shift = 0.0; + if (($b != 0.0) || ($c != 0.0)) { + $shift = sqrt($b * $b + $c); + if ($b < 0.0) { + $shift = -$shift; } - $f = ($sk + $sp) * ($sk - $sp) + $shift; - $g = $sk * $ek; - // Chase zeros. - for ($j = $k; $j < $p-1; ++$j) { - $t = hypo($f, $g); - $cs = $f/$t; - $sn = $g/$t; - if ($j != $k) { - $e[$j-1] = $t; - } - $f = $cs * $this->s[$j] + $sn * $e[$j]; - $e[$j] = $cs * $e[$j] - $sn * $this->s[$j]; - $g = $sn * $this->s[$j+1]; - $this->s[$j+1] = $cs * $this->s[$j+1]; - if ($wantv) { - for ($i = 0; $i < $this->n; ++$i) { - $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$j+1]; - $this->V[$i][$j+1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$j+1]; - $this->V[$i][$j] = $t; - } - } - $t = hypo($f, $g); - $cs = $f/$t; - $sn = $g/$t; - $this->s[$j] = $t; - $f = $cs * $e[$j] + $sn * $this->s[$j+1]; - $this->s[$j+1] = -$sn * $e[$j] + $cs * $this->s[$j+1]; - $g = $sn * $e[$j+1]; - $e[$j+1] = $cs * $e[$j+1]; - if ($wantu && ($j < $this->m - 1)) { - for ($i = 0; $i < $this->m; ++$i) { - $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$j+1]; - $this->U[$i][$j+1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$j+1]; - $this->U[$i][$j] = $t; - } + $shift = $c / ($b + $shift); + } + $f = ($sk + $sp) * ($sk - $sp) + $shift; + $g = $sk * $ek; + // Chase zeros. + for ($j = $k; $j < $p-1; ++$j) { + $t = hypo($f, $g); + $cs = $f/$t; + $sn = $g/$t; + if ($j != $k) { + $e[$j-1] = $t; + } + $f = $cs * $this->s[$j] + $sn * $e[$j]; + $e[$j] = $cs * $e[$j] - $sn * $this->s[$j]; + $g = $sn * $this->s[$j+1]; + $this->s[$j+1] = $cs * $this->s[$j+1]; + if ($wantv) { + for ($i = 0; $i < $this->n; ++$i) { + $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$j+1]; + $this->V[$i][$j+1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$j+1]; + $this->V[$i][$j] = $t; } } - $e[$p-2] = $f; - $iter = $iter + 1; - break; + $t = hypo($f, $g); + $cs = $f/$t; + $sn = $g/$t; + $this->s[$j] = $t; + $f = $cs * $e[$j] + $sn * $this->s[$j+1]; + $this->s[$j+1] = -$sn * $e[$j] + $cs * $this->s[$j+1]; + $g = $sn * $e[$j+1]; + $e[$j+1] = $cs * $e[$j+1]; + if ($wantu && ($j < $this->m - 1)) { + for ($i = 0; $i < $this->m; ++$i) { + $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$j+1]; + $this->U[$i][$j+1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$j+1]; + $this->U[$i][$j] = $t; + } + } + } + $e[$p-2] = $f; + $iter = $iter + 1; + break; // Convergence. case 4: - // Make the singular values positive. - if ($this->s[$k] <= 0.0) { - $this->s[$k] = ($this->s[$k] < 0.0 ? -$this->s[$k] : 0.0); - if ($wantv) { - for ($i = 0; $i <= $pp; ++$i) { - $this->V[$i][$k] = -$this->V[$i][$k]; - } + // Make the singular values positive. + if ($this->s[$k] <= 0.0) { + $this->s[$k] = ($this->s[$k] < 0.0 ? -$this->s[$k] : 0.0); + if ($wantv) { + for ($i = 0; $i <= $pp; ++$i) { + $this->V[$i][$k] = -$this->V[$i][$k]; } } - // Order the singular values. - while ($k < $pp) { - if ($this->s[$k] >= $this->s[$k+1]) { - break; - } - $t = $this->s[$k]; - $this->s[$k] = $this->s[$k+1]; - $this->s[$k+1] = $t; - if ($wantv AND ($k < $this->n - 1)) { - for ($i = 0; $i < $this->n; ++$i) { - $t = $this->V[$i][$k+1]; - $this->V[$i][$k+1] = $this->V[$i][$k]; - $this->V[$i][$k] = $t; - } - } - if ($wantu AND ($k < $this->m-1)) { - for ($i = 0; $i < $this->m; ++$i) { - $t = $this->U[$i][$k+1]; - $this->U[$i][$k+1] = $this->U[$i][$k]; - $this->U[$i][$k] = $t; - } - } - ++$k; + } + // Order the singular values. + while ($k < $pp) { + if ($this->s[$k] >= $this->s[$k+1]) { + break; } - $iter = 0; - --$p; - break; + $t = $this->s[$k]; + $this->s[$k] = $this->s[$k+1]; + $this->s[$k+1] = $t; + if ($wantv and ($k < $this->n - 1)) { + for ($i = 0; $i < $this->n; ++$i) { + $t = $this->V[$i][$k+1]; + $this->V[$i][$k+1] = $this->V[$i][$k]; + $this->V[$i][$k] = $t; + } + } + if ($wantu and ($k < $this->m-1)) { + for ($i = 0; $i < $this->m; ++$i) { + $t = $this->U[$i][$k+1]; + $this->U[$i][$k+1] = $this->U[$i][$k]; + $this->U[$i][$k] = $t; + } + } + ++$k; + } + $iter = 0; + --$p; + break; } // end switch } // end while @@ -439,7 +435,8 @@ class SingularValueDecomposition { * @access public * @return U */ - public function getU() { + public function getU() + { return new Matrix($this->U, $this->m, min($this->m + 1, $this->n)); } @@ -450,7 +447,8 @@ class SingularValueDecomposition { * @access public * @return V */ - public function getV() { + public function getV() + { return new Matrix($this->V); } @@ -461,7 +459,8 @@ class SingularValueDecomposition { * @access public * @return diagonal of S. */ - public function getSingularValues() { + public function getSingularValues() + { return $this->s; } @@ -472,7 +471,8 @@ class SingularValueDecomposition { * @access public * @return S */ - public function getS() { + public function getS() + { for ($i = 0; $i < $this->n; ++$i) { for ($j = 0; $j < $this->n; ++$j) { $S[$i][$j] = 0.0; @@ -489,7 +489,8 @@ class SingularValueDecomposition { * @access public * @return max(S) */ - public function norm2() { + public function norm2() + { return $this->s[0]; } @@ -500,7 +501,8 @@ class SingularValueDecomposition { * @access public * @return max(S)/min(S) */ - public function cond() { + public function cond() + { return $this->s[0] / $this->s[min($this->m, $this->n) - 1]; } @@ -511,7 +513,8 @@ class SingularValueDecomposition { * @access public * @return Number of nonnegligible singular values. */ - public function rank() { + public function rank() + { $eps = pow(2.0, -52.0); $tol = max($this->m, $this->n) * $this->s[0] * $eps; $r = 0; @@ -522,5 +525,4 @@ class SingularValueDecomposition { } return $r; } - -} // class SingularValueDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/utils/Error.php b/Classes/PHPExcel/Shared/JAMA/utils/Error.php index ff51ccc5..155bcba0 100644 --- a/Classes/PHPExcel/Shared/JAMA/utils/Error.php +++ b/Classes/PHPExcel/Shared/JAMA/utils/Error.php @@ -67,7 +67,8 @@ $error['EN'][RowLengthException] = "All rows must have the same length."; * Custom error handler * @param int $num Error number */ -function JAMAError($errorNumber = null) { +function JAMAError($errorNumber = null) +{ global $error; if (isset($errorNumber)) { diff --git a/Classes/PHPExcel/Shared/JAMA/utils/Maths.php b/Classes/PHPExcel/Shared/JAMA/utils/Maths.php index 922784c5..6d4db65a 100644 --- a/Classes/PHPExcel/Shared/JAMA/utils/Maths.php +++ b/Classes/PHPExcel/Shared/JAMA/utils/Maths.php @@ -11,7 +11,8 @@ * * r = sqrt(a^2 + b^2) without under/overflow. */ -function hypo($a, $b) { +function hypo($a, $b) +{ if (abs($a) > abs($b)) { $r = $b / $a; $r = abs($a) * sqrt(1 + $r * $r); diff --git a/Classes/PHPExcel/Shared/OLE/PPS/Root.php b/Classes/PHPExcel/Shared/OLE/PPS/Root.php index b2278c4e..c62399ba 100644 --- a/Classes/PHPExcel/Shared/OLE/PPS/Root.php +++ b/Classes/PHPExcel/Shared/OLE/PPS/Root.php @@ -72,11 +72,12 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS if (is_resource($filename)) { $this->_FILEH_ = $filename; - } else if ($filename == '-' || $filename == '') { - if ($this->_tmp_dir === null) + } elseif ($filename == '-' || $filename == '') { + if ($this->_tmp_dir === null) { $this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir(); + } $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); - $this->_FILEH_ = fopen($this->_tmp_filename,"w+b"); + $this->_FILEH_ = fopen($this->_tmp_filename, "w+b"); if ($this->_FILEH_ == false) { throw new PHPExcel_Writer_Exception("Can't create temporary file."); } @@ -105,8 +106,8 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS $this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); if (!is_resource($filename)) { - fclose($this->_FILEH_); - } + fclose($this->_FILEH_); + } return true; } @@ -199,33 +200,35 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS } // Save Header - fwrite($FILE, - "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . pack("v", 0x3b) - . pack("v", 0x03) - . pack("v", -2) - . pack("v", 9) - . pack("v", 6) - . pack("v", 0) - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . pack("V", $iBdCnt) - . pack("V", $iBBcnt+$iSBDcnt) //ROOT START - . pack("V", 0) - . pack("V", 0x1000) - . pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot - . pack("V", $iSBDcnt) - ); + fwrite( + $FILE, + "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . pack("v", 0x3b) + . pack("v", 0x03) + . pack("v", -2) + . pack("v", 9) + . pack("v", 6) + . pack("v", 0) + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . pack("V", $iBdCnt) + . pack("V", $iBBcnt+$iSBDcnt) //ROOT START + . pack("V", 0) + . pack("V", 0x1000) + . pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot + . pack("V", $iSBDcnt) + ); // Extra BDList Start, Count if ($iBdCnt < $i1stBdL) { - fwrite($FILE, - pack("V", -2) // Extra BDList Start - . pack("V", 0) // Extra BDList Count - ); + fwrite( + $FILE, + pack("V", -2) // Extra BDList Start + . pack("V", 0)// Extra BDList Count + ); } else { fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL)); } @@ -258,9 +261,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS for ($i = 0; $i < $iCount; ++$i) { if ($raList[$i]->Type != PHPExcel_Shared_OLE::OLE_PPS_TYPE_DIR) { $raList[$i]->Size = $raList[$i]->_DataLen(); - if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) || - (($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data))) - { + if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) || (($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data))) { // Write Data //if (isset($raList[$i]->_PPS_FILE)) { // $iLen = 0; @@ -366,7 +367,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS $iCnt = count($raList); $iBCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE; if ($iCnt % $iBCnt) { - fwrite($this->_FILEH_, str_repeat("\x00",($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE)); + fwrite($this->_FILEH_, str_repeat("\x00", ($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE)); } } diff --git a/Classes/PHPExcel/Shared/OLERead.php b/Classes/PHPExcel/Shared/OLERead.php index f43567d7..48b24eed 100644 --- a/Classes/PHPExcel/Shared/OLERead.php +++ b/Classes/PHPExcel/Shared/OLERead.php @@ -28,7 +28,8 @@ defined('IDENTIFIER_OLE') || define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)); -class PHPExcel_Shared_OLERead { +class PHPExcel_Shared_OLERead +{ private $data = ''; // OLE identifier @@ -272,7 +273,7 @@ class PHPExcel_Shared_OLERead { // Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook) if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) { $this->wrkbook = count($this->props) - 1; - } else if ($upName === 'ROOT ENTRY' || $upName === 'R') { + } elseif ($upName === 'ROOT ENTRY' || $upName === 'R') { // Root entry $this->rootentry = count($this->props) - 1; } diff --git a/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php b/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php index d0c772a5..8fa3db83 100644 --- a/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php +++ b/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php @@ -319,7 +319,7 @@ class PclZip // ----- Look for the optional second argument if ($v_size == 2) { $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; - } else if ($v_size > 2) { + } elseif ($v_size > 2) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); return 0; } @@ -345,7 +345,7 @@ class PclZip // ----- The list is a list of string names $v_string_list = $p_filelist; } - } else if (is_string($p_filelist)) { + } elseif (is_string($p_filelist)) { // ----- Look if the $p_filelist is a string // ----- Create a list from the string $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); @@ -487,7 +487,7 @@ class PclZip // ----- Look for the optional second argument if ($v_size == 2) { $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; - } else if ($v_size > 2) { + } elseif ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); @@ -516,7 +516,7 @@ class PclZip // ----- The list is a list of string names $v_string_list = $p_filelist; } - } else if (is_string($p_filelist)) { + } elseif (is_string($p_filelist)) { // ----- Look if the $p_filelist is a string // ----- Create a list from the string $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); @@ -748,7 +748,7 @@ class PclZip // ----- Look for the optional second argument if ($v_size == 2) { $v_remove_path = $v_arg_list[1]; - } else if ($v_size > 2) { + } elseif ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); @@ -903,7 +903,7 @@ class PclZip // ----- Look for the optional second argument if ($v_size == 2) { $v_remove_path = $v_arg_list[1]; - } else if ($v_size > 2) { + } elseif ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); @@ -1122,7 +1122,7 @@ class PclZip if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) { // ----- Duplicate the archive $v_result = $this->privDuplicate($p_archive->zipname); - } else if (is_string($p_archive)) { + } elseif (is_string($p_archive)) { // ----- Look if the $p_archive is a string (so a filename) // ----- Check that $p_archive is a valid zip file // TBC : Should also check the archive format @@ -1176,7 +1176,7 @@ class PclZip if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) { // ----- Merge the archive $v_result = $this->privMerge($p_archive_to_add); - } else if (is_string($p_archive_to_add)) { + } elseif (is_string($p_archive_to_add)) { // ----- Look if the $p_archive_to_add is a string (so a filename) // ----- Create a temporary archive $v_object_archive = new PclZip($p_archive_to_add); @@ -1466,7 +1466,7 @@ class PclZip // ----- Get the value if (is_string($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; - } else if (is_array($p_options_list[$i+1])) { + } elseif (is_array($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; } else { // ----- Error log @@ -1548,9 +1548,9 @@ class PclZip // ----- Parse items $v_work_list = explode(",", $p_options_list[$i+1]); - } else if (is_integer($p_options_list[$i+1])) { + } elseif (is_integer($p_options_list[$i+1])) { $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; - } else if (is_array($p_options_list[$i+1])) { + } elseif (is_array($p_options_list[$i+1])) { $v_work_list = $p_options_list[$i+1]; } else { // ----- Error log @@ -1895,16 +1895,16 @@ class PclZip if (file_exists($v_descr['filename'])) { if (@is_file($v_descr['filename'])) { $v_descr['type'] = 'file'; - } else if (@is_dir($v_descr['filename'])) { + } elseif (@is_dir($v_descr['filename'])) { $v_descr['type'] = 'folder'; - } else if (@is_link($v_descr['filename'])) { + } elseif (@is_link($v_descr['filename'])) { // skip continue; } else { // skip continue; } - } else if (isset($v_descr['content'])) { + } elseif (isset($v_descr['content'])) { // ----- Look for string added as file $v_descr['type'] = 'virtual_file'; } else { @@ -2412,12 +2412,12 @@ class PclZip if ($p_filedescr['type']=='file') { $p_header['external'] = 0x00000000; $p_header['size'] = filesize($p_filename); - } else if ($p_filedescr['type']=='folder') { + } elseif ($p_filedescr['type']=='folder') { // ----- Look for regular folder $p_header['external'] = 0x00000010; $p_header['mtime'] = filemtime($p_filename); $p_header['size'] = filesize($p_filename); - } else if ($p_filedescr['type'] == 'virtual_file') { + } elseif ($p_filedescr['type'] == 'virtual_file') { // ----- Look for virtual file $p_header['external'] = 0x00000000; $p_header['size'] = strlen($p_filedescr['content']); @@ -2426,7 +2426,7 @@ class PclZip // ----- Look for filetime if (isset($p_filedescr['mtime'])) { $p_header['mtime'] = $p_filedescr['mtime']; - } else if ($p_filedescr['type'] == 'virtual_file') { + } elseif ($p_filedescr['type'] == 'virtual_file') { $p_header['mtime'] = time(); } else { $p_header['mtime'] = filemtime($p_filename); @@ -2526,7 +2526,7 @@ class PclZip // ----- Write the compressed (or not) content @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); } - } else if ($p_filedescr['type'] == 'virtual_file') { + } elseif ($p_filedescr['type'] == 'virtual_file') { // ----- Look for a virtual file (a file from string) $v_content = $p_filedescr['content']; @@ -2556,7 +2556,7 @@ class PclZip // ----- Write the compressed (or not) content @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); - } else if ($p_filedescr['type'] == 'folder') { + } elseif ($p_filedescr['type'] == 'folder') { // ----- Look for a directory // ----- Look for directory last '/' if (@substr($p_header['stored_filename'], -1) != '/') { @@ -2761,7 +2761,7 @@ class PclZip // ----- Look for all path to remove if ($p_remove_all_dir) { $v_stored_filename = basename($p_filename); - } else if ($p_remove_dir != "") { + } elseif ($p_remove_dir != "") { // ----- Look for partial path remove if (substr($p_remove_dir, -1) != '/') { $p_remove_dir .= "/"; @@ -3136,12 +3136,12 @@ class PclZip $v_extract = true; } } - }else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + } elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { // ----- Look for extract by preg rule if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { $v_extract = true; } - } else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + } elseif ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { // ----- Look for extract by index rule // ----- Look if the index is in the list for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { @@ -3167,7 +3167,6 @@ class PclZip // ----- Look for PCLZIP_OPT_STOP_ON_ERROR if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { - $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is compressed by an unsupported compression method (".$v_header['compression'].") "); @@ -3249,9 +3248,8 @@ class PclZip if ($v_result1 == 2) { break; } - } - // ----- Look for extraction in standard output - elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + } elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + // ----- Look for extraction in standard output // ----- Extracting the file in standard output $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); if ($v_result1 < 1) { @@ -3343,7 +3341,7 @@ class PclZip // ----- Get the basename of the path $p_entry['filename'] = basename($p_entry['filename']); - } else if ($p_remove_path != "") { + } elseif ($p_remove_path != "") { // ----- Look for path to remove if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) { // ----- Change the file status @@ -3369,7 +3367,7 @@ class PclZip if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']); if ($v_inclusion == 0) { - PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,"Filename '".$p_entry['filename']."' is outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, "Filename '".$p_entry['filename']."' is outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); return PclZip::errorCode(); } @@ -3410,7 +3408,6 @@ class PclZip if (file_exists($p_entry['filename'])) { // ----- Look if file is a directory if (is_dir($p_entry['filename'])) { - // ----- Change the file status $p_entry['status'] = "already_a_directory"; @@ -3421,7 +3418,7 @@ class PclZip PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, "Filename '".$p_entry['filename']."' is already used by an existing directory"); return PclZip::errorCode(); } - } else if (!is_writeable($p_entry['filename'])) { + } elseif (!is_writeable($p_entry['filename'])) { // ----- Look if file is write protected // ----- Change the file status $p_entry['status'] = "write_protected"; @@ -3433,7 +3430,7 @@ class PclZip PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Filename '".$p_entry['filename']."' exists and is write protected"); return PclZip::errorCode(); } - } else if (filemtime($p_entry['filename']) > $p_entry['mtime']) { + } elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) { // ----- Look if the extracted file is older // ----- Change the file status if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) { @@ -3444,26 +3441,23 @@ class PclZip // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Newer version of '".$p_entry['filename']."' exists and option PCLZIP_OPT_REPLACE_NEWER is not selected"); - return PclZip::errorCode(); - } + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Newer version of '".$p_entry['filename']."' exists and option PCLZIP_OPT_REPLACE_NEWER is not selected"); + return PclZip::errorCode(); + } } } else { } } else { - // ----- Check the directory availability and create it if necessary + // ----- Check the directory availability and create it if necessary if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) { $v_dir_to_check = $p_entry['filename']; - } - else if (!strstr($p_entry['filename'], "/")) { + } elseif (!strstr($p_entry['filename'], "/")) { $v_dir_to_check = ""; - } - else { + } else { $v_dir_to_check = dirname($p_entry['filename']); } if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { - // ----- Change the file status $p_entry['status'] = "path_creation_fail"; @@ -3530,7 +3524,6 @@ class PclZip $v_file_content = @gzinflate($v_buffer); unset($v_buffer); if ($v_file_content === false) { - // ----- Change the file status // TBC $p_entry['status'] = "error"; @@ -3540,7 +3533,6 @@ class PclZip // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { - // ----- Change the file status $p_entry['status'] = "write_error"; @@ -3723,7 +3715,6 @@ class PclZip if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file if ($p_entry['compressed_size'] == $p_entry['size']) { - // ----- Read the file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); @@ -3731,7 +3722,6 @@ class PclZip echo $v_buffer; unset($v_buffer); } else { - // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); @@ -3791,7 +3781,7 @@ class PclZip // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { - // TBC + // TBC } // ----- Look for pre-extract callback @@ -3830,17 +3820,15 @@ class PclZip // ----- Look for not compressed file // if ($p_entry['compressed_size'] == $p_entry['size']) if ($p_entry['compression'] == 0) { - // ----- Reading the file $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); } else { - // ----- Reading the file $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Decompress the file if (($p_string = @gzinflate($v_data)) === false) { - // TBC + // TBC } } // ----- Trace @@ -4037,8 +4025,7 @@ class PclZip // ----- Get comment if ($p_header['comment_len'] != 0) { $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); - } - else { + } else { $p_header['comment'] = ''; } @@ -4112,9 +4099,9 @@ class PclZip // ----- Look for flag bit 3 if (($p_local_header['flag'] & 8) == 8) { - $p_local_header['size'] = $p_central_header['size']; - $p_local_header['compressed_size'] = $p_central_header['compressed_size']; - $p_local_header['crc'] = $p_central_header['crc']; + $p_local_header['size'] = $p_central_header['size']; + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; + $p_local_header['crc'] = $p_central_header['crc']; } // ----- Return @@ -4171,8 +4158,9 @@ class PclZip // ----- Go back to the maximum possible size of the Central Dir End Record if (!$v_found) { $v_maximum_size = 65557; // 0xFFFF + 22; - if ($v_maximum_size > $v_size) + if ($v_maximum_size > $v_size) { $v_maximum_size = $v_size; + } @fseek($this->zip_fd, $v_size-$v_maximum_size); if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) { // ----- Error log @@ -4196,8 +4184,7 @@ class PclZip $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); // ----- Compare the bytes - if ($v_bytes == 0x504b0506) - { + if ($v_bytes == 0x504b0506) { $v_pos++; break; } @@ -4342,43 +4329,28 @@ class PclZip } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { $v_found = true; } - } - // ----- Look for a filename - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + } elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + // ----- Look for a filename $v_found = true; } } - } - // ----- Look for extract by ereg rule - // ereg() is deprecated with PHP 5.3 - /* - else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) - && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { - - if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { - $v_found = true; - } - } - */ - else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) - // ----- Look for extract by preg rule - && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + } elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + // ----- Look for extract by preg rule if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { $v_found = true; } - } else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + } elseif ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { // ----- Look for extract by index rule // ----- Look if the index is in the list for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { - $v_found = true; + $v_found = true; } if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { - $j_start = $j+1; + $j_start = $j+1; } - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { - break; + break; } } } else { @@ -4523,7 +4495,7 @@ class PclZip // ----- Destroy the temporary archive unset($v_temp_zip); - } else if ($v_central_dir['entries'] != 0) { + } elseif ($v_central_dir['entries'] != 0) { // ----- Remove every files : reset the file $this->privCloseFd(); @@ -4608,7 +4580,6 @@ class PclZip // ----- Look if the archive_to_add exists if (!is_file($p_archive_to_add->zipname)) { - // ----- Nothing to merge, so merge is a success $v_result = 1; @@ -4618,7 +4589,6 @@ class PclZip // ----- Look if the archive exists if (!is_file($this->zipname)) { - // ----- Do a duplicate $v_result = $this->privDuplicate($p_archive_to_add->zipname); @@ -4781,7 +4751,6 @@ class PclZip // ----- Look if the $p_archive_filename exists if (!is_file($p_archive_filename)) { - // ----- Nothing to duplicate, so duplicate is a success. $v_result = 1; @@ -4946,9 +4915,9 @@ function PclZipUtilPathReduction($p_dir) if ($v_list[$i] == ".") { // ----- Ignore this directory // Should be the first $i=0, but no check is done - } else if ($v_list[$i] == "..") { + } elseif ($v_list[$i] == "..") { $v_skip++; - } else if ($v_list[$i] == "") { + } elseif ($v_list[$i] == "") { // ----- First '/' i.e. root slash if ($i == 0) { $v_result = "/".$v_result; @@ -4958,7 +4927,7 @@ function PclZipUtilPathReduction($p_dir) $v_result = $p_dir; $v_skip = 0; } - } else if ($i == (sizeof($v_list)-1)) { + } elseif ($i == (sizeof($v_list)-1)) { // ----- Last '/' i.e. indicates a directory $v_result = $v_list[$i]; } else { @@ -4970,8 +4939,7 @@ function PclZipUtilPathReduction($p_dir) // ----- Look for item to skip if ($v_skip > 0) { $v_skip--; - } - else { + } else { $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); } } @@ -5051,13 +5019,17 @@ function PclZipUtilPathInclusion($p_dir, $p_path) // ----- Look if everything seems to be the same if ($v_result) { // ----- Skip all the empty items - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { + $j++; + } + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) { + $i++; + } if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { // ----- There are exactly the same $v_result = 2; - } else if ($i < $v_list_dir_size) { + } elseif ($i < $v_list_dir_size) { // ----- The path is shorter than the dir $v_result = 0; } @@ -5090,21 +5062,21 @@ function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0) @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } - } else if ($p_mode==1) { + } elseif ($p_mode==1) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @gzread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } - } else if ($p_mode==2) { + } elseif ($p_mode==2) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } - } else if ($p_mode==3) { + } elseif ($p_mode==3) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @gzread($p_src, $v_read_size); @@ -5139,7 +5111,7 @@ function PclZipUtilRename($p_src, $p_dest) // ----- Try to copy & unlink the src if (!@copy($p_src, $p_dest)) { $v_result = 0; - } else if (!@unlink($p_src)) { + } elseif (!@unlink($p_src)) { $v_result = 0; } } @@ -5160,7 +5132,6 @@ function PclZipUtilRename($p_src, $p_dest) // -------------------------------------------------------------------------------- function PclZipUtilOptionText($p_option) { - $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); @@ -5191,13 +5162,12 @@ function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true) if (stristr(php_uname(), 'windows')) { // ----- Look for potential disk letter if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { - $p_path = substr($p_path, $v_position+1); + $p_path = substr($p_path, $v_position+1); } // ----- Change potential windows directory separator - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { - $p_path = strtr($p_path, '\\', '/'); + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { + $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } -// -------------------------------------------------------------------------------- \ No newline at end of file diff --git a/Classes/PHPExcel/Shared/String.php b/Classes/PHPExcel/Shared/String.php index c32a3bb8..df8cdf2f 100644 --- a/Classes/PHPExcel/Shared/String.php +++ b/Classes/PHPExcel/Shared/String.php @@ -504,7 +504,7 @@ class PHPExcel_Shared_String if ($from == 'UTF-16LE') { return self::utf16_decode($value, false); - } else if ($from == 'UTF-16BE') { + } elseif ($from == 'UTF-16BE') { return self::utf16_decode($value); } // else, no conversion diff --git a/Classes/PHPExcel/Shared/ZipStreamWrapper.php b/Classes/PHPExcel/Shared/ZipStreamWrapper.php index c96cffe1..d1c87ac6 100644 --- a/Classes/PHPExcel/Shared/ZipStreamWrapper.php +++ b/Classes/PHPExcel/Shared/ZipStreamWrapper.php @@ -131,7 +131,7 @@ class PHPExcel_Shared_ZipStreamWrapper * @param int $count maximum number of bytes to read * @return string */ - function stream_read($count) + public function stream_read($count) { $ret = substr($this->_data, $this->_position, $count); $this->_position += strlen($ret); diff --git a/Classes/PHPExcel/Shared/trend/exponentialBestFitClass.php b/Classes/PHPExcel/Shared/trend/exponentialBestFitClass.php index 647bd2dc..caa1759c 100644 --- a/Classes/PHPExcel/Shared/trend/exponentialBestFitClass.php +++ b/Classes/PHPExcel/Shared/trend/exponentialBestFitClass.php @@ -138,7 +138,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit * @param float[] $xValues The set of X-values for this regression * @param boolean $const */ - function __construct($yValues, $xValues = array(), $const = true) + public function __construct($yValues, $xValues = array(), $const = true) { if (parent::__construct($yValues, $xValues) !== false) { $this->_exponential_regression($yValues, $xValues, $const); diff --git a/Classes/PHPExcel/Shared/trend/linearBestFitClass.php b/Classes/PHPExcel/Shared/trend/linearBestFitClass.php index 1689dd60..c5ed3cf3 100644 --- a/Classes/PHPExcel/Shared/trend/linearBestFitClass.php +++ b/Classes/PHPExcel/Shared/trend/linearBestFitClass.php @@ -100,7 +100,7 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit * @param float[] $xValues The set of X-values for this regression * @param boolean $const */ - function __construct($yValues, $xValues = array(), $const = true) + public function __construct($yValues, $xValues = array(), $const = true) { if (parent::__construct($yValues, $xValues) !== false) { $this->_linear_regression($yValues, $xValues, $const); diff --git a/Classes/PHPExcel/Shared/trend/logarithmicBestFitClass.php b/Classes/PHPExcel/Shared/trend/logarithmicBestFitClass.php index fa1a3d26..7d561cda 100644 --- a/Classes/PHPExcel/Shared/trend/logarithmicBestFitClass.php +++ b/Classes/PHPExcel/Shared/trend/logarithmicBestFitClass.php @@ -108,7 +108,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit * @param float[] $xValues The set of X-values for this regression * @param boolean $const */ - function __construct($yValues, $xValues = array(), $const = true) + public function __construct($yValues, $xValues = array(), $const = true) { if (parent::__construct($yValues, $xValues) !== false) { $this->_logarithmic_regression($yValues, $xValues, $const); diff --git a/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php b/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php index b571f206..b1b69b0a 100644 --- a/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php +++ b/Classes/PHPExcel/Shared/trend/polynomialBestFitClass.php @@ -213,7 +213,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit * @param float[] $xValues The set of X-values for this regression * @param boolean $const */ - function __construct($order, $yValues, $xValues = array(), $const = true) + public function __construct($order, $yValues, $xValues = array(), $const = true) { if (parent::__construct($yValues, $xValues) !== false) { if ($order < $this->_valueCount) { diff --git a/Classes/PHPExcel/Shared/trend/powerBestFitClass.php b/Classes/PHPExcel/Shared/trend/powerBestFitClass.php index b58d8f5d..38870af8 100644 --- a/Classes/PHPExcel/Shared/trend/powerBestFitClass.php +++ b/Classes/PHPExcel/Shared/trend/powerBestFitClass.php @@ -138,7 +138,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit * @param float[] $xValues The set of X-values for this regression * @param boolean $const */ - function __construct($yValues, $xValues = array(), $const = true) + public function __construct($yValues, $xValues = array(), $const = true) { if (parent::__construct($yValues, $xValues) !== false) { $this->_power_regression($yValues, $xValues, $const); diff --git a/Classes/PHPExcel/Shared/trend/trendClass.php b/Classes/PHPExcel/Shared/trend/trendClass.php index bb1cd1c5..a7b34ed9 100644 --- a/Classes/PHPExcel/Shared/trend/trendClass.php +++ b/Classes/PHPExcel/Shared/trend/trendClass.php @@ -153,4 +153,4 @@ class trendClass return false; } } // function calculate() -} // class trendClass +} diff --git a/Classes/PHPExcel/Style.php b/Classes/PHPExcel/Style.php index 20f7236e..6b952ef9 100644 --- a/Classes/PHPExcel/Style.php +++ b/Classes/PHPExcel/Style.php @@ -358,7 +358,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp // Selection type, inspect if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { $selectionType = 'COLUMN'; - } else if (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { + } elseif (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { $selectionType = 'ROW'; } else { $selectionType = 'CELL'; diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 5c6d3ed6..8004412d 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -391,7 +391,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable * Code to execute when this worksheet is unset() * */ - function __destruct() + public function __destruct() { PHPExcel_Calculation::getInstance($this->_parent)->clearCalculationCacheForWorksheet($this->_title); @@ -2265,9 +2265,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable if (strpos($pCellCoordinate, ':') !== false || strpos($pCellCoordinate, ',') !== false) { throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.'); - } else if (strpos($pCellCoordinate, '$') !== false) { + } elseif (strpos($pCellCoordinate, '$') !== false) { throw new PHPExcel_Exception('Cell coordinate string must not be absolute.'); - } else if ($pCellCoordinate == '') { + } elseif ($pCellCoordinate == '') { throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.'); } else { // Check if we already have a comment for this cell. diff --git a/Classes/PHPExcel/Worksheet/ColumnDimension.php b/Classes/PHPExcel/Worksheet/ColumnDimension.php index fe007c81..405b8258 100644 --- a/Classes/PHPExcel/Worksheet/ColumnDimension.php +++ b/Classes/PHPExcel/Worksheet/ColumnDimension.php @@ -25,14 +25,14 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ -class PHPExcel_Worksheet_ColumnDimension +class PHPExcel_Worksheet_ColumnDimension extends PHPExcel_Worksheet_Dimension { /** * Column index * * @var int */ - private $_columnIndex; + private $columnIndex; /** * Column width @@ -41,42 +41,14 @@ class PHPExcel_Worksheet_ColumnDimension * * @var double */ - private $_width = -1; + private $width = -1; /** * Auto size? * * @var bool */ - private $_autoSize = false; - - /** - * Visible? - * - * @var bool - */ - private $_visible = true; - - /** - * Outline level - * - * @var int - */ - private $_outlineLevel = 0; - - /** - * Collapsed - * - * @var bool - */ - private $_collapsed = false; - - /** - * Index to cellXf - * - * @var int - */ - private $_xfIndex; + private $autoSize = false; /** * Create a new PHPExcel_Worksheet_ColumnDimension @@ -86,10 +58,10 @@ class PHPExcel_Worksheet_ColumnDimension public function __construct($pIndex = 'A') { // Initialise values - $this->_columnIndex = $pIndex; + $this->columnIndex = $pIndex; - // set default index to cellXf - $this->_xfIndex = 0; + // set dimension as unformatted by default + parent::__construct(0); } /** @@ -99,7 +71,7 @@ class PHPExcel_Worksheet_ColumnDimension */ public function getColumnIndex() { - return $this->_columnIndex; + return $this->columnIndex; } /** @@ -110,7 +82,7 @@ class PHPExcel_Worksheet_ColumnDimension */ public function setColumnIndex($pValue) { - $this->_columnIndex = $pValue; + $this->columnIndex = $pValue; return $this; } @@ -121,7 +93,7 @@ class PHPExcel_Worksheet_ColumnDimension */ public function getWidth() { - return $this->_width; + return $this->width; } /** @@ -132,7 +104,7 @@ class PHPExcel_Worksheet_ColumnDimension */ public function setWidth($pValue = -1) { - $this->_width = $pValue; + $this->width = $pValue; return $this; } @@ -143,7 +115,7 @@ class PHPExcel_Worksheet_ColumnDimension */ public function getAutoSize() { - return $this->_autoSize; + return $this->autoSize; } /** @@ -154,117 +126,7 @@ class PHPExcel_Worksheet_ColumnDimension */ public function setAutoSize($pValue = false) { - $this->_autoSize = $pValue; + $this->autoSize = $pValue; return $this; } - - /** - * Get Visible - * - * @return bool - */ - public function getVisible() - { - return $this->_visible; - } - - /** - * Set Visible - * - * @param bool $pValue - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function setVisible($pValue = true) - { - $this->_visible = $pValue; - return $this; - } - - /** - * Get Outline Level - * - * @return int - */ - public function getOutlineLevel() - { - return $this->_outlineLevel; - } - - /** - * Set Outline Level - * - * Value must be between 0 and 7 - * - * @param int $pValue - * @throws PHPExcel_Exception - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function setOutlineLevel($pValue) - { - if ($pValue < 0 || $pValue > 7) { - throw new PHPExcel_Exception("Outline level must range between 0 and 7."); - } - - $this->_outlineLevel = $pValue; - return $this; - } - - /** - * Get Collapsed - * - * @return bool - */ - public function getCollapsed() - { - return $this->_collapsed; - } - - /** - * Set Collapsed - * - * @param bool $pValue - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function setCollapsed($pValue = true) - { - $this->_collapsed = $pValue; - return $this; - } - - /** - * Get index to cellXf - * - * @return int - */ - public function getXfIndex() - { - return $this->_xfIndex; - } - - /** - * Set index to cellXf - * - * @param int $pValue - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function setXfIndex($pValue = 0) - { - $this->_xfIndex = $pValue; - return $this; - } - - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() - { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Worksheet/Dimension.php b/Classes/PHPExcel/Worksheet/Dimension.php new file mode 100644 index 00000000..84f692cb --- /dev/null +++ b/Classes/PHPExcel/Worksheet/Dimension.php @@ -0,0 +1,178 @@ +<?php + +/** + * PHPExcel_Worksheet_Dimension + * + * Copyright (c) 2006 - 2015 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_Worksheet + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## + */ +abstract class PHPExcel_Worksheet_Dimension +{ + /** + * Visible? + * + * @var bool + */ + private $visible = true; + + /** + * Outline level + * + * @var int + */ + private $outlineLevel = 0; + + /** + * Collapsed + * + * @var bool + */ + private $collapsed = false; + + /** + * Index to cellXf. Null value means row has no explicit cellXf format. + * + * @var int|null + */ + private $xfIndex; + + /** + * Create a new PHPExcel_Worksheet_Dimension + * + * @param int $pIndex Numeric row index + */ + public function __construct($initialValue = null) + { + // set dimension as unformatted by default + $this->xfIndex = $initialValue; + } + + /** + * Get Visible + * + * @return bool + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set Visible + * + * @param bool $pValue + * @return PHPExcel_Worksheet_Dimension + */ + public function setVisible($pValue = true) + { + $this->visible = $pValue; + return $this; + } + + /** + * Get Outline Level + * + * @return int + */ + public function getOutlineLevel() + { + return $this->outlineLevel; + } + + /** + * Set Outline Level + * + * Value must be between 0 and 7 + * + * @param int $pValue + * @throws PHPExcel_Exception + * @return PHPExcel_Worksheet_Dimension + */ + public function setOutlineLevel($pValue) + { + if ($pValue < 0 || $pValue > 7) { + throw new PHPExcel_Exception("Outline level must range between 0 and 7."); + } + + $this->outlineLevel = $pValue; + return $this; + } + + /** + * Get Collapsed + * + * @return bool + */ + public function getCollapsed() + { + return $this->collapsed; + } + + /** + * Set Collapsed + * + * @param bool $pValue + * @return PHPExcel_Worksheet_Dimension + */ + public function setCollapsed($pValue = true) + { + $this->collapsed = $pValue; + return $this; + } + + /** + * Get index to cellXf + * + * @return int + */ + public function getXfIndex() + { + return $this->xfIndex; + } + + /** + * Set index to cellXf + * + * @param int $pValue + * @return PHPExcel_Worksheet_Dimension + */ + public function setXfIndex($pValue = 0) + { + $this->xfIndex = $pValue; + return $this; + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() + { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } +} diff --git a/Classes/PHPExcel/Worksheet/Protection.php b/Classes/PHPExcel/Worksheet/Protection.php index d6ab223a..d84e6e9c 100644 --- a/Classes/PHPExcel/Worksheet/Protection.php +++ b/Classes/PHPExcel/Worksheet/Protection.php @@ -166,7 +166,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function isProtectionEnabled() + public function isProtectionEnabled() { return $this->_sheet || $this->_objects || @@ -191,7 +191,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSheet() + public function getSheet() { return $this->_sheet; } @@ -202,7 +202,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSheet($pValue = false) + public function setSheet($pValue = false) { $this->_sheet = $pValue; return $this; @@ -213,7 +213,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getObjects() + public function getObjects() { return $this->_objects; } @@ -224,7 +224,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setObjects($pValue = false) + public function setObjects($pValue = false) { $this->_objects = $pValue; return $this; @@ -235,7 +235,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getScenarios() + public function getScenarios() { return $this->_scenarios; } @@ -246,7 +246,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setScenarios($pValue = false) + public function setScenarios($pValue = false) { $this->_scenarios = $pValue; return $this; @@ -257,7 +257,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getFormatCells() + public function getFormatCells() { return $this->_formatCells; } @@ -268,7 +268,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setFormatCells($pValue = false) + public function setFormatCells($pValue = false) { $this->_formatCells = $pValue; return $this; @@ -279,7 +279,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getFormatColumns() + public function getFormatColumns() { return $this->_formatColumns; } @@ -290,7 +290,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setFormatColumns($pValue = false) + public function setFormatColumns($pValue = false) { $this->_formatColumns = $pValue; return $this; @@ -301,7 +301,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getFormatRows() + public function getFormatRows() { return $this->_formatRows; } @@ -312,7 +312,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setFormatRows($pValue = false) + public function setFormatRows($pValue = false) { $this->_formatRows = $pValue; return $this; @@ -323,7 +323,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getInsertColumns() + public function getInsertColumns() { return $this->_insertColumns; } @@ -334,7 +334,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setInsertColumns($pValue = false) + public function setInsertColumns($pValue = false) { $this->_insertColumns = $pValue; return $this; @@ -345,7 +345,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getInsertRows() + public function getInsertRows() { return $this->_insertRows; } @@ -356,7 +356,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setInsertRows($pValue = false) + public function setInsertRows($pValue = false) { $this->_insertRows = $pValue; return $this; @@ -367,7 +367,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getInsertHyperlinks() + public function getInsertHyperlinks() { return $this->_insertHyperlinks; } @@ -378,7 +378,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setInsertHyperlinks($pValue = false) + public function setInsertHyperlinks($pValue = false) { $this->_insertHyperlinks = $pValue; return $this; @@ -389,7 +389,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getDeleteColumns() + public function getDeleteColumns() { return $this->_deleteColumns; } @@ -400,7 +400,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setDeleteColumns($pValue = false) + public function setDeleteColumns($pValue = false) { $this->_deleteColumns = $pValue; return $this; @@ -411,7 +411,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getDeleteRows() + public function getDeleteRows() { return $this->_deleteRows; } @@ -422,7 +422,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setDeleteRows($pValue = false) + public function setDeleteRows($pValue = false) { $this->_deleteRows = $pValue; return $this; @@ -433,7 +433,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSelectLockedCells() + public function getSelectLockedCells() { return $this->_selectLockedCells; } @@ -444,7 +444,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSelectLockedCells($pValue = false) + public function setSelectLockedCells($pValue = false) { $this->_selectLockedCells = $pValue; return $this; @@ -455,7 +455,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSort() + public function getSort() { return $this->_sort; } @@ -466,7 +466,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSort($pValue = false) + public function setSort($pValue = false) { $this->_sort = $pValue; return $this; @@ -477,7 +477,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getAutoFilter() + public function getAutoFilter() { return $this->_autoFilter; } @@ -488,7 +488,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setAutoFilter($pValue = false) + public function setAutoFilter($pValue = false) { $this->_autoFilter = $pValue; return $this; @@ -499,7 +499,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getPivotTables() + public function getPivotTables() { return $this->_pivotTables; } @@ -510,7 +510,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setPivotTables($pValue = false) + public function setPivotTables($pValue = false) { $this->_pivotTables = $pValue; return $this; @@ -521,7 +521,7 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSelectUnlockedCells() + public function getSelectUnlockedCells() { return $this->_selectUnlockedCells; } @@ -532,7 +532,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSelectUnlockedCells($pValue = false) + public function setSelectUnlockedCells($pValue = false) { $this->_selectUnlockedCells = $pValue; return $this; @@ -543,7 +543,7 @@ class PHPExcel_Worksheet_Protection * * @return string */ - function getPassword() + public function getPassword() { return $this->_password; } @@ -555,7 +555,7 @@ class PHPExcel_Worksheet_Protection * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true * @return PHPExcel_Worksheet_Protection */ - function setPassword($pValue = '', $pAlreadyHashed = false) + public function setPassword($pValue = '', $pAlreadyHashed = false) { if (!$pAlreadyHashed) { $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue); diff --git a/Classes/PHPExcel/Worksheet/RowDimension.php b/Classes/PHPExcel/Worksheet/RowDimension.php index 5314f9c1..c1474862 100644 --- a/Classes/PHPExcel/Worksheet/RowDimension.php +++ b/Classes/PHPExcel/Worksheet/RowDimension.php @@ -25,14 +25,14 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ -class PHPExcel_Worksheet_RowDimension +class PHPExcel_Worksheet_RowDimension extends PHPExcel_Worksheet_Dimension { /** * Row index * * @var int */ - private $_rowIndex; + private $rowIndex; /** * Row height (in pt) @@ -41,42 +41,14 @@ class PHPExcel_Worksheet_RowDimension * * @var double */ - private $_rowHeight = -1; + private $height = -1; /** * ZeroHeight for Row? * * @var bool */ - private $_zeroHeight = false; - - /** - * Visible? - * - * @var bool - */ - private $_visible = true; - - /** - * Outline level - * - * @var int - */ - private $_outlineLevel = 0; - - /** - * Collapsed - * - * @var bool - */ - private $_collapsed = false; - - /** - * Index to cellXf. Null value means row has no explicit cellXf format. - * - * @var int|null - */ - private $_xfIndex; + private $zeroHeight = false; /** * Create a new PHPExcel_Worksheet_RowDimension @@ -86,10 +58,10 @@ class PHPExcel_Worksheet_RowDimension public function __construct($pIndex = 0) { // Initialise values - $this->_rowIndex = $pIndex; + $this->rowIndex = $pIndex; - // set row dimension as unformatted by default - $this->_xfIndex = null; + // set dimension as unformatted by default + parent::__construct(null); } /** @@ -99,7 +71,7 @@ class PHPExcel_Worksheet_RowDimension */ public function getRowIndex() { - return $this->_rowIndex; + return $this->rowIndex; } /** @@ -110,7 +82,7 @@ class PHPExcel_Worksheet_RowDimension */ public function setRowIndex($pValue) { - $this->_rowIndex = $pValue; + $this->rowIndex = $pValue; return $this; } @@ -121,7 +93,7 @@ class PHPExcel_Worksheet_RowDimension */ public function getRowHeight() { - return $this->_rowHeight; + return $this->height; } /** @@ -132,7 +104,7 @@ class PHPExcel_Worksheet_RowDimension */ public function setRowHeight($pValue = -1) { - $this->_rowHeight = $pValue; + $this->height = $pValue; return $this; } @@ -143,7 +115,7 @@ class PHPExcel_Worksheet_RowDimension */ public function getZeroHeight() { - return $this->_zeroHeight; + return $this->zeroHeight; } /** @@ -154,117 +126,7 @@ class PHPExcel_Worksheet_RowDimension */ public function setZeroHeight($pValue = false) { - $this->_zeroHeight = $pValue; + $this->zeroHeight = $pValue; return $this; } - - /** - * Get Visible - * - * @return bool - */ - public function getVisible() - { - return $this->_visible; - } - - /** - * Set Visible - * - * @param bool $pValue - * @return PHPExcel_Worksheet_RowDimension - */ - public function setVisible($pValue = true) - { - $this->_visible = $pValue; - return $this; - } - - /** - * Get Outline Level - * - * @return int - */ - public function getOutlineLevel() - { - return $this->_outlineLevel; - } - - /** - * Set Outline Level - * - * Value must be between 0 and 7 - * - * @param int $pValue - * @throws PHPExcel_Exception - * @return PHPExcel_Worksheet_RowDimension - */ - public function setOutlineLevel($pValue) - { - if ($pValue < 0 || $pValue > 7) { - throw new PHPExcel_Exception("Outline level must range between 0 and 7."); - } - - $this->_outlineLevel = $pValue; - return $this; - } - - /** - * Get Collapsed - * - * @return bool - */ - public function getCollapsed() - { - return $this->_collapsed; - } - - /** - * Set Collapsed - * - * @param bool $pValue - * @return PHPExcel_Worksheet_RowDimension - */ - public function setCollapsed($pValue = true) - { - $this->_collapsed = $pValue; - return $this; - } - - /** - * Get index to cellXf - * - * @return int - */ - public function getXfIndex() - { - return $this->_xfIndex; - } - - /** - * Set index to cellXf - * - * @param int $pValue - * @return PHPExcel_Worksheet_RowDimension - */ - public function setXfIndex($pValue = 0) - { - $this->_xfIndex = $pValue; - return $this; - } - - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() - { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Worksheet/SheetView.php b/Classes/PHPExcel/Worksheet/SheetView.php index e0ea6148..c7a7d5bf 100644 --- a/Classes/PHPExcel/Worksheet/SheetView.php +++ b/Classes/PHPExcel/Worksheet/SheetView.php @@ -1,6 +1,7 @@ <?php + /** - * PHPExcel + * PHPExcel_Worksheet_SheetView * * Copyright (c) 2006 - 2015 PHPExcel * @@ -24,22 +25,13 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ - - -/** - * PHPExcel_Worksheet_SheetView - * - * @category PHPExcel - * @package PHPExcel_Worksheet - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - */ class PHPExcel_Worksheet_SheetView { /* Sheet View types */ - const SHEETVIEW_NORMAL = 'normal'; - const SHEETVIEW_PAGE_LAYOUT = 'pageLayout'; - const SHEETVIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview'; + const SHEETVIEW_NORMAL = 'normal'; + const SHEETVIEW_PAGE_LAYOUT = 'pageLayout'; + const SHEETVIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview'; private static $_sheetViewTypes = array( self::SHEETVIEW_NORMAL, @@ -54,7 +46,7 @@ class PHPExcel_Worksheet_SheetView * * @var int */ - private $_zoomScale = 100; + private $zoomScale = 100; /** * ZoomScaleNormal @@ -63,7 +55,7 @@ class PHPExcel_Worksheet_SheetView * * @var int */ - private $_zoomScaleNormal = 100; + private $zoomScaleNormal = 100; /** * View @@ -72,7 +64,7 @@ class PHPExcel_Worksheet_SheetView * * @var string */ - private $_sheetviewType = self::SHEETVIEW_NORMAL; + private $sheetviewType = self::SHEETVIEW_NORMAL; /** * Create a new PHPExcel_Worksheet_SheetView @@ -88,7 +80,7 @@ class PHPExcel_Worksheet_SheetView */ public function getZoomScale() { - return $this->_zoomScale; + return $this->zoomScale; } /** @@ -105,7 +97,7 @@ class PHPExcel_Worksheet_SheetView // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, // but it is apparently still able to handle any scale >= 1 if (($pValue >= 1) || is_null($pValue)) { - $this->_zoomScale = $pValue; + $this->zoomScale = $pValue; } else { throw new PHPExcel_Exception("Scale must be greater than or equal to 1."); } @@ -119,7 +111,7 @@ class PHPExcel_Worksheet_SheetView */ public function getZoomScaleNormal() { - return $this->_zoomScaleNormal; + return $this->zoomScaleNormal; } /** @@ -134,7 +126,7 @@ class PHPExcel_Worksheet_SheetView public function setZoomScaleNormal($pValue = 100) { if (($pValue >= 1) || is_null($pValue)) { - $this->_zoomScaleNormal = $pValue; + $this->zoomScaleNormal = $pValue; } else { throw new PHPExcel_Exception("Scale must be greater than or equal to 1."); } @@ -148,7 +140,7 @@ class PHPExcel_Worksheet_SheetView */ public function getView() { - return $this->_sheetviewType; + return $this->sheetviewType; } /** @@ -157,7 +149,7 @@ class PHPExcel_Worksheet_SheetView * Valid values are * 'normal' self::SHEETVIEW_NORMAL * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT - * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW + * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW * * @param string $pValue * @throws PHPExcel_Exception @@ -170,7 +162,7 @@ class PHPExcel_Worksheet_SheetView $pValue = self::SHEETVIEW_NORMAL; } if (in_array($pValue, self::$_sheetViewTypes)) { - $this->_sheetviewType = $pValue; + $this->sheetviewType = $pValue; } else { throw new PHPExcel_Exception("Invalid sheetview layout type."); } diff --git a/Classes/PHPExcel/Writer/CSV.php b/Classes/PHPExcel/Writer/CSV.php index 1540a22b..90c5cc08 100644 --- a/Classes/PHPExcel/Writer/CSV.php +++ b/Classes/PHPExcel/Writer/CSV.php @@ -32,49 +32,49 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W * * @var PHPExcel */ - private $_phpExcel; + private $phpExcel; /** * Delimiter * * @var string */ - private $_delimiter = ','; + private $delimiter = ','; /** * Enclosure * * @var string */ - private $_enclosure = '"'; + private $enclosure = '"'; /** * Line ending * * @var string */ - private $_lineEnding = PHP_EOL; + private $lineEnding = PHP_EOL; /** * Sheet index to write * * @var int */ - private $_sheetIndex = 0; + private $sheetIndex = 0; /** * Whether to write a BOM (for UTF8). * * @var boolean */ - private $_useBOM = false; + private $useBOM = false; /** * Whether to write a fully Excel compatible CSV file. * * @var boolean */ - private $_excelCompatibility = false; + private $excelCompatibility = false; /** * Create a new PHPExcel_Writer_CSV @@ -83,7 +83,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function __construct(PHPExcel $phpExcel) { - $this->_phpExcel = $phpExcel; + $this->phpExcel = $phpExcel; } /** @@ -95,10 +95,10 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W public function save($pFilename = null) { // Fetch sheet - $sheet = $this->_phpExcel->getSheet($this->_sheetIndex); + $sheet = $this->phpExcel->getSheet($this->sheetIndex); - $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); - PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(false); + $saveDebugLog = PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->getWriteDebugLog(); + PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog(false); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); @@ -108,13 +108,13 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing."); } - if ($this->_excelCompatibility) { + if ($this->excelCompatibility) { fwrite($fileHandle, "\xEF\xBB\xBF"); // Enforce UTF-8 BOM Header $this->setEnclosure('"'); // Set enclosure to " $this->setDelimiter(";"); // Set delimiter to a semi-colon $this->setLineEnding("\r\n"); - fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->_lineEnding); - } elseif ($this->_useBOM) { + fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->lineEnding); + } elseif ($this->useBOM) { // Write the UTF-8 BOM code if required fwrite($fileHandle, "\xEF\xBB\xBF"); } @@ -135,7 +135,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); - PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); + PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** @@ -145,7 +145,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function getDelimiter() { - return $this->_delimiter; + return $this->delimiter; } /** @@ -156,7 +156,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function setDelimiter($pValue = ',') { - $this->_delimiter = $pValue; + $this->delimiter = $pValue; return $this; } @@ -167,7 +167,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function getEnclosure() { - return $this->_enclosure; + return $this->enclosure; } /** @@ -181,7 +181,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W if ($pValue == '') { $pValue = null; } - $this->_enclosure = $pValue; + $this->enclosure = $pValue; return $this; } @@ -192,7 +192,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function getLineEnding() { - return $this->_lineEnding; + return $this->lineEnding; } /** @@ -203,7 +203,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function setLineEnding($pValue = PHP_EOL) { - $this->_lineEnding = $pValue; + $this->lineEnding = $pValue; return $this; } @@ -214,7 +214,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function getUseBOM() { - return $this->_useBOM; + return $this->useBOM; } /** @@ -225,7 +225,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function setUseBOM($pValue = false) { - $this->_useBOM = $pValue; + $this->useBOM = $pValue; return $this; } @@ -236,7 +236,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function getExcelCompatibility() { - return $this->_excelCompatibility; + return $this->excelCompatibility; } /** @@ -248,7 +248,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function setExcelCompatibility($pValue = false) { - $this->_excelCompatibility = $pValue; + $this->excelCompatibility = $pValue; return $this; } @@ -259,7 +259,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function getSheetIndex() { - return $this->_sheetIndex; + return $this->sheetIndex; } /** @@ -270,7 +270,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W */ public function setSheetIndex($pValue = 0) { - $this->_sheetIndex = $pValue; + $this->sheetIndex = $pValue; return $this; } @@ -292,21 +292,21 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W foreach ($pValues as $element) { // Escape enclosures - $element = str_replace($this->_enclosure, $this->_enclosure . $this->_enclosure, $element); + $element = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $element); // Add delimiter if ($writeDelimiter) { - $line .= $this->_delimiter; + $line .= $this->delimiter; } else { $writeDelimiter = true; } // Add enclosed string - $line .= $this->_enclosure . $element . $this->_enclosure; + $line .= $this->enclosure . $element . $this->enclosure; } // Add line ending - $line .= $this->_lineEnding; + $line .= $this->lineEnding; // Write to file fwrite($pFileHandle, $line); diff --git a/Classes/PHPExcel/Writer/Excel2007.php b/Classes/PHPExcel/Writer/Excel2007.php index e7f26ff5..1b241018 100644 --- a/Classes/PHPExcel/Writer/Excel2007.php +++ b/Classes/PHPExcel/Writer/Excel2007.php @@ -368,7 +368,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE } $objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); - } else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) { + } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) { ob_start(); call_user_func( $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(), diff --git a/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php b/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php index 4f0b1eba..c441ef11 100644 --- a/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php +++ b/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php @@ -145,7 +145,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) { $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); $mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath()); - } else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) { + } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) { $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); $extension = explode('/', $extension); $extension = $extension[1]; diff --git a/Classes/PHPExcel/Writer/Excel2007/StringTable.php b/Classes/PHPExcel/Writer/Excel2007/StringTable.php index 4a28f13e..7976f7bb 100644 --- a/Classes/PHPExcel/Writer/Excel2007/StringTable.php +++ b/Classes/PHPExcel/Writer/Excel2007/StringTable.php @@ -123,7 +123,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr } $objWriter->writeRawData($textToWrite); $objWriter->endElement(); - } else if ($textElement instanceof PHPExcel_RichText) { + } elseif ($textElement instanceof PHPExcel_RichText) { $this->writeRichText($objWriter, $textElement); } @@ -184,7 +184,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr $objWriter->startElement($prefix.'vertAlign'); if ($element->getFont()->getSuperScript()) { $objWriter->writeAttribute('val', 'superscript'); - } else if ($element->getFont()->getSubScript()) { + } elseif ($element->getFont()->getSubScript()) { $objWriter->writeAttribute('val', 'subscript'); } $objWriter->endElement(); @@ -280,7 +280,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr // $objWriter->startElement($prefix.'vertAlign'); // if ($element->getFont()->getSuperScript()) { // $objWriter->writeAttribute('val', 'superscript'); -// } else if ($element->getFont()->getSubScript()) { +// } elseif ($element->getFont()->getSubScript()) { // $objWriter->writeAttribute('val', 'subscript'); // } // $objWriter->endElement(); @@ -313,7 +313,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr foreach ($stringTable as $key => $value) { if (! $value instanceof PHPExcel_RichText) { $returnValue[$value] = $key; - } else if ($value instanceof PHPExcel_RichText) { + } elseif ($value instanceof PHPExcel_RichText) { $returnValue[$value->getHashCode()] = $key; } } diff --git a/Classes/PHPExcel/Writer/Excel2007/Style.php b/Classes/PHPExcel/Writer/Excel2007/Style.php index d6cf8538..5ff56f33 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Style.php +++ b/Classes/PHPExcel/Writer/Excel2007/Style.php @@ -317,7 +317,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->startElement('vertAlign'); if ($pFont->getSuperScript() === true) { $objWriter->writeAttribute('val', 'superscript'); - } else if ($pFont->getSubScript() === true) { + } elseif ($pFont->getSubScript() === true) { $objWriter->writeAttribute('val', 'subscript'); } $objWriter->endElement(); @@ -428,7 +428,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa $textRotation = 0; if ($pStyle->getAlignment()->getTextRotation() >= 0) { $textRotation = $pStyle->getAlignment()->getTextRotation(); - } else if ($pStyle->getAlignment()->getTextRotation() < 0) { + } elseif ($pStyle->getAlignment()->getTextRotation() < 0) { $textRotation = 90 - $pStyle->getAlignment()->getTextRotation(); } $objWriter->writeAttribute('textRotation', $textRotation); @@ -493,7 +493,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa $textRotation = 0; if ($pStyle->getAlignment()->getTextRotation() >= 0) { $textRotation = $pStyle->getAlignment()->getTextRotation(); - } else if ($pStyle->getAlignment()->getTextRotation() < 0) { + } elseif ($pStyle->getAlignment()->getTextRotation() < 0) { $textRotation = 90 - $pStyle->getAlignment()->getTextRotation(); } $objWriter->writeAttribute('textRotation', $textRotation); diff --git a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index cb153f8a..492e0453 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -506,19 +506,19 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))'); - } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT + } elseif ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BEGINSWITH && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); - } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT + } elseif ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_ENDSWITH && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); - } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT + } elseif ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_NOTCONTAINS && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))'); - } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS + } elseif ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS || $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) { foreach ($conditional->getConditions() as $formula) { @@ -910,7 +910,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ foreach ($pSheet->getBreaks() as $cell => $breakType) { if ($breakType == PHPExcel_Worksheet::BREAK_ROW) { $aRowBreaks[] = $cell; - } else if ($breakType == PHPExcel_Worksheet::BREAK_COLUMN) { + } elseif ($breakType == PHPExcel_Worksheet::BREAK_COLUMN) { $aColumnBreaks[] = $cell; } } @@ -1095,7 +1095,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ case 'inlinestr': // Inline string if (! $cellValue instanceof PHPExcel_RichText) { $objWriter->writeElement('t', PHPExcel_Shared_String::ControlCharacterPHP2OOXML(htmlspecialchars($cellValue))); - } else if ($cellValue instanceof PHPExcel_RichText) { + } elseif ($cellValue instanceof PHPExcel_RichText) { $objWriter->startElement('is'); $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue); $objWriter->endElement(); @@ -1107,7 +1107,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ if (isset($pFlippedStringTable[$cellValue])) { $objWriter->writeElement('v', $pFlippedStringTable[$cellValue]); } - } else if ($cellValue instanceof PHPExcel_RichText) { + } elseif ($cellValue instanceof PHPExcel_RichText) { $objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]); } diff --git a/Classes/PHPExcel/Writer/Excel5.php b/Classes/PHPExcel/Writer/Excel5.php index 024e7708..b1f49e09 100644 --- a/Classes/PHPExcel/Writer/Excel5.php +++ b/Classes/PHPExcel/Writer/Excel5.php @@ -32,63 +32,63 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce * * @var PHPExcel */ - private $_phpExcel; + private $phpExcel; /** * Total number of shared strings in workbook * * @var int */ - private $_str_total = 0; + private $strTotal = 0; /** * Number of unique shared strings in workbook * * @var int */ - private $_str_unique = 0; + private $strUnique = 0; /** * Array of unique shared strings in workbook * * @var array */ - private $_str_table = array(); + private $strTable = array(); /** * Color cache. Mapping between RGB value and color index. * * @var array */ - private $_colors; + private $colors; /** * Formula parser * * @var PHPExcel_Writer_Excel5_Parser */ - private $_parser; + private $parser; /** * Identifier clusters for drawings. Used in MSODRAWINGGROUP record. * * @var array */ - private $_IDCLs; + private $IDCLs; /** * Basic OLE object summary information * * @var array */ - private $_summaryInformation; + private $summaryInformation; /** * Extended OLE object document summary information * * @var array */ - private $_documentSummaryInformation; + private $documentSummaryInformation; /** * Create a new PHPExcel_Writer_Excel5 @@ -97,9 +97,9 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce */ public function __construct(PHPExcel $phpExcel) { - $this->_phpExcel = $phpExcel; + $this->phpExcel = $phpExcel; - $this->_parser = new PHPExcel_Writer_Excel5_Parser(); + $this->parser = new PHPExcel_Writer_Excel5_Parser(); } /** @@ -112,38 +112,38 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce { // garbage collect - $this->_phpExcel->garbageCollect(); + $this->phpExcel->garbageCollect(); - $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); - PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(false); + $saveDebugLog = PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->getWriteDebugLog(); + PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog(false); $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // initialize colors array - $this->_colors = array(); + $this->colors = array(); // Initialise workbook writer - $this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser); + $this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->phpExcel, $this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser); // Initialise worksheet writers - $countSheets = $this->_phpExcel->getSheetCount(); + $countSheets = $this->phpExcel->getSheetCount(); for ($i = 0; $i < $countSheets; ++$i) { - $this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_preCalculateFormulas, $this->_phpExcel->getSheet($i)); + $this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->_preCalculateFormulas, $this->phpExcel->getSheet($i)); } // build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook. - $this->_buildWorksheetEschers(); - $this->_buildWorkbookEscher(); + $this->buildWorksheetEschers(); + $this->buildWorkbookEscher(); // add 15 identical cell style Xfs // for now, we use the first cellXf instead of cellStyleXf - $cellXfCollection = $this->_phpExcel->getCellXfCollection(); + $cellXfCollection = $this->phpExcel->getCellXfCollection(); for ($i = 0; $i < 15; ++$i) { $this->_writerWorkbook->addXfWriter($cellXfCollection[0], true); } // add all the cell Xfs - foreach ($this->_phpExcel->getCellXfCollection() as $style) { + foreach ($this->phpExcel->getCellXfCollection() as $style) { $this->_writerWorkbook->addXfWriter($style, false); } @@ -184,18 +184,18 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $OLE->append($this->_writerWorksheets[$i]->getData()); } - $this->_documentSummaryInformation = $this->_writeDocumentSummaryInformation(); + $this->documentSummaryInformation = $this->writeDocumentSummaryInformation(); // initialize OLE Document Summary Information - if (isset($this->_documentSummaryInformation) && !empty($this->_documentSummaryInformation)) { + if (isset($this->documentSummaryInformation) && !empty($this->documentSummaryInformation)) { $OLE_DocumentSummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation')); - $OLE_DocumentSummaryInformation->append($this->_documentSummaryInformation); + $OLE_DocumentSummaryInformation->append($this->documentSummaryInformation); } - $this->_summaryInformation = $this->_writeSummaryInformation(); + $this->summaryInformation = $this->writeSummaryInformation(); // initialize OLE Summary Information - if (isset($this->_summaryInformation) && !empty($this->_summaryInformation)) { + if (isset($this->summaryInformation) && !empty($this->summaryInformation)) { $OLE_SummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'SummaryInformation')); - $OLE_SummaryInformation->append($this->_summaryInformation); + $OLE_SummaryInformation->append($this->summaryInformation); } // define OLE Parts @@ -214,7 +214,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $res = $root->save($pFilename); PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType); - PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); + PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** @@ -234,14 +234,14 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce * Build the Worksheet Escher objects * */ - private function _buildWorksheetEschers() + private function buildWorksheetEschers() { // 1-based index to BstoreContainer $blipIndex = 0; $lastReducedSpId = 0; $lastSpId = 0; - foreach ($this->_phpExcel->getAllsheets() as $sheet) { + foreach ($this->phpExcel->getAllsheets() as $sheet) { // sheet index $sheetIndex = $sheet->getParent()->getIndex($sheet); @@ -385,7 +385,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce } // identifier clusters, used for workbook Escher object - $this->_IDCLs[$dgId] = $lastReducedSpId; + $this->IDCLs[$dgId] = $lastReducedSpId; // set last shape index $dgContainer->setLastSpId($lastSpId); @@ -398,13 +398,13 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce /** * Build the Escher object corresponding to the MSODRAWINGGROUP record */ - private function _buildWorkbookEscher() + private function buildWorkbookEscher() { $escher = null; // any drawings in this workbook? $found = false; - foreach ($this->_phpExcel->getAllSheets() as $sheet) { + foreach ($this->phpExcel->getAllSheets() as $sheet) { if (count($sheet->getDrawingCollection()) > 0) { $found = true; break; @@ -424,14 +424,14 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $escher->setDggContainer($dggContainer); // set IDCLs (identifier clusters) - $dggContainer->setIDCLs($this->_IDCLs); + $dggContainer->setIDCLs($this->IDCLs); // this loop is for determining maximum shape identifier of all drawing $spIdMax = 0; $totalCountShapes = 0; $countDrawings = 0; - foreach ($this->_phpExcel->getAllsheets() as $sheet) { + foreach ($this->phpExcel->getAllsheets() as $sheet) { $sheetCountShapes = 0; // count number of shapes (minus group shape), in sheet if (count($sheet->getDrawingCollection()) > 0) { @@ -441,7 +441,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce ++$sheetCountShapes; ++$totalCountShapes; - $spId = $sheetCountShapes | ($this->_phpExcel->getIndex($sheet) + 1) << 10; + $spId = $sheetCountShapes | ($this->phpExcel->getIndex($sheet) + 1) << 10; $spIdMax = max($spId, $spIdMax); } } @@ -456,7 +456,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dggContainer->setBstoreContainer($bstoreContainer); // the BSE's (all the images) - foreach ($this->_phpExcel->getAllsheets() as $sheet) { + foreach ($this->phpExcel->getAllsheets() as $sheet) { foreach ($sheet->getDrawingCollection() as $drawing) { if ($drawing instanceof PHPExcel_Worksheet_Drawing) { $filename = $drawing->getPath(); @@ -498,7 +498,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $BSE->setBlip($blip); $bstoreContainer->addBSE($BSE); - } else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) { + } elseif ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) { switch ($drawing->getRenderingFunction()) { case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG: $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG; @@ -537,7 +537,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce * Build the OLE Part for DocumentSummary Information * @return string */ - private function _writeDocumentSummaryInformation() + private function writeDocumentSummaryInformation() { // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) $data = pack('v', 0xFFFE); @@ -571,8 +571,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; // GKPIDDSI_CATEGORY : Category - if ($this->_phpExcel->getProperties()->getCategory()) { - $dataProp = $this->_phpExcel->getProperties()->getCategory(); + if ($this->phpExcel->getProperties()->getCategory()) { + $dataProp = $this->phpExcel->getProperties()->getCategory(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), @@ -733,7 +733,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce * Build the OLE Part for Summary Information * @return string */ - private function _writeSummaryInformation() + private function writeSummaryInformation() { // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) $data = pack('v', 0xFFFE); @@ -767,8 +767,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; // Title - if ($this->_phpExcel->getProperties()->getTitle()) { - $dataProp = $this->_phpExcel->getProperties()->getTitle(); + if ($this->phpExcel->getProperties()->getTitle()) { + $dataProp = $this->phpExcel->getProperties()->getTitle(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length @@ -776,8 +776,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; } // Subject - if ($this->_phpExcel->getProperties()->getSubject()) { - $dataProp = $this->_phpExcel->getProperties()->getSubject(); + if ($this->phpExcel->getProperties()->getSubject()) { + $dataProp = $this->phpExcel->getProperties()->getSubject(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x03), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length @@ -785,8 +785,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; } // Author (Creator) - if ($this->_phpExcel->getProperties()->getCreator()) { - $dataProp = $this->_phpExcel->getProperties()->getCreator(); + if ($this->phpExcel->getProperties()->getCreator()) { + $dataProp = $this->phpExcel->getProperties()->getCreator(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x04), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length @@ -794,8 +794,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; } // Keywords - if ($this->_phpExcel->getProperties()->getKeywords()) { - $dataProp = $this->_phpExcel->getProperties()->getKeywords(); + if ($this->phpExcel->getProperties()->getKeywords()) { + $dataProp = $this->phpExcel->getProperties()->getKeywords(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x05), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length @@ -803,8 +803,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; } // Comments (Description) - if ($this->_phpExcel->getProperties()->getDescription()) { - $dataProp = $this->_phpExcel->getProperties()->getDescription(); + if ($this->phpExcel->getProperties()->getDescription()) { + $dataProp = $this->phpExcel->getProperties()->getDescription(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x06), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length @@ -812,8 +812,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; } // Last Saved By (LastModifiedBy) - if ($this->_phpExcel->getProperties()->getLastModifiedBy()) { - $dataProp = $this->_phpExcel->getProperties()->getLastModifiedBy(); + if ($this->phpExcel->getProperties()->getLastModifiedBy()) { + $dataProp = $this->phpExcel->getProperties()->getLastModifiedBy(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x08), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length @@ -821,8 +821,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; } // Created Date/Time - if ($this->_phpExcel->getProperties()->getCreated()) { - $dataProp = $this->_phpExcel->getProperties()->getCreated(); + if ($this->phpExcel->getProperties()->getCreated()) { + $dataProp = $this->phpExcel->getProperties()->getCreated(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) @@ -830,8 +830,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection_NumProps++; } // Modified Date/Time - if ($this->_phpExcel->getProperties()->getModified()) { - $dataProp = $this->_phpExcel->getProperties()->getModified(); + if ($this->phpExcel->getProperties()->getModified()) { + $dataProp = $this->phpExcel->getProperties()->getModified(); $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) diff --git a/Classes/PHPExcel/Writer/Excel5/Escher.php b/Classes/PHPExcel/Writer/Excel5/Escher.php index fc0f10a7..e7e79a84 100644 --- a/Classes/PHPExcel/Writer/Excel5/Escher.php +++ b/Classes/PHPExcel/Writer/Excel5/Escher.php @@ -82,7 +82,7 @@ class PHPExcel_Writer_Excel5_Escher if ($dggContainer = $this->_object->getDggContainer()) { $writer = new PHPExcel_Writer_Excel5_Escher($dggContainer); $this->_data = $writer->close(); - } else if ($dgContainer = $this->_object->getDgContainer()) { + } elseif ($dgContainer = $this->_object->getDgContainer()) { $writer = new PHPExcel_Writer_Excel5_Escher($dgContainer); $this->_data = $writer->close(); $this->_spOffsets = $writer->getSpOffsets(); diff --git a/Classes/PHPExcel/Writer/Excel5/Font.php b/Classes/PHPExcel/Writer/Excel5/Font.php index a95e6455..e67562b8 100644 --- a/Classes/PHPExcel/Writer/Excel5/Font.php +++ b/Classes/PHPExcel/Writer/Excel5/Font.php @@ -83,7 +83,7 @@ class PHPExcel_Writer_Excel5_Font $icv = $this->_colorIndex; // Index to color palette if ($this->_font->getSuperScript()) { $sss = 1; - } else if ($this->_font->getSubScript()) { + } elseif ($this->_font->getSubScript()) { $sss = 2; } else { $sss = 0; diff --git a/Classes/PHPExcel/Writer/Excel5/Workbook.php b/Classes/PHPExcel/Writer/Excel5/Workbook.php index cd6bbd73..c5f827d5 100644 --- a/Classes/PHPExcel/Writer/Excel5/Workbook.php +++ b/Classes/PHPExcel/Writer/Excel5/Workbook.php @@ -610,7 +610,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter ); // (exclusive) either repeatColumns or repeatRows - } else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { + } elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { // Columns to repeat if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); @@ -717,7 +717,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true)); // (exclusive) either repeatColumns or repeatRows - } else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { + } elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { // Columns to repeat if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); diff --git a/Classes/PHPExcel/Writer/Excel5/Worksheet.php b/Classes/PHPExcel/Writer/Excel5/Worksheet.php index 11e0e862..6949c172 100644 --- a/Classes/PHPExcel/Writer/Excel5/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel5/Worksheet.php @@ -504,7 +504,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // internal to current workbook $url = str_replace('sheet://', 'internal:', $url); - } else if (preg_match('/^(http:|https:|ftp:|mailto:)/', $url)) { + } elseif (preg_match('/^(http:|https:|ftp:|mailto:)/', $url)) { // URL // $url = $url; @@ -3048,7 +3048,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) { $type = 0x02; $operatorType = 0x00; - } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS) { + } elseif ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS) { $type = 0x01; switch ($conditional->getOperatorType()) { @@ -3089,7 +3089,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $szValue2 = 0x0000; $operand1 = pack('Cv', 0x1E, $arrConditions[0]); $operand2 = null; - } else if ($numConditions == 2 && ($conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BETWEEN)) { + } elseif ($numConditions == 2 && ($conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BETWEEN)) { $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000); $szValue2 = ($arrConditions[1] <= 65535 ? 3 : 0x0000); $operand1 = pack('Cv', 0x1E, $arrConditions[0]); @@ -3226,7 +3226,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter if ($conditional->getStyle()->getFont()->getSubScript() == true) { $dataBlockFont .= pack('v', 0x02); $fontEscapement = 0; - } else if ($conditional->getStyle()->getFont()->getSuperScript() == true) { + } elseif ($conditional->getStyle()->getFont()->getSuperScript() == true) { $dataBlockFont .= pack('v', 0x01); $fontEscapement = 0; } else { diff --git a/Classes/PHPExcel/Writer/Excel5/Xf.php b/Classes/PHPExcel/Writer/Excel5/Xf.php index dc185f00..61a42eb2 100644 --- a/Classes/PHPExcel/Writer/Excel5/Xf.php +++ b/Classes/PHPExcel/Writer/Excel5/Xf.php @@ -75,61 +75,61 @@ class PHPExcel_Writer_Excel5_Xf * * @var boolean */ - private $_isStyleXf; + private $isStyleXf; /** * Index to the FONT record. Index 4 does not exist * @var integer */ - private $_fontIndex; + private $fontIndex; /** * An index (2 bytes) to a FORMAT record (number format). * @var integer */ - public $_numberFormatIndex; + private $numberFormatIndex; /** * 1 bit, apparently not used. * @var integer */ - public $_text_justlast; + private $textJustLast; /** * The cell's foreground color. * @var integer */ - public $_fg_color; + private $foregroundColor; /** * The cell's background color. * @var integer */ - public $_bg_color; + private $backgroundColor; /** * Color of the bottom border of the cell. * @var integer */ - public $_bottom_color; + private $bottomBorderColor; /** * Color of the top border of the cell. * @var integer */ - public $_top_color; + private $topBorderColor; /** * Color of the left border of the cell. * @var integer */ - public $_left_color; + private $leftBorderColor; /** * Color of the right border of the cell. * @var integer */ - public $_right_color; + private $rightBorderColor; /** * Constructor @@ -139,22 +139,22 @@ class PHPExcel_Writer_Excel5_Xf */ public function __construct(PHPExcel_Style $style = null) { - $this->_isStyleXf = false; - $this->_fontIndex = 0; + $this->isStyleXf = false; + $this->fontIndex = 0; - $this->_numberFormatIndex = 0; + $this->numberFormatIndex = 0; - $this->_text_justlast = 0; + $this->textJustLast = 0; - $this->_fg_color = 0x40; - $this->_bg_color = 0x41; + $this->foregroundColor = 0x40; + $this->backgroundColor = 0x41; $this->_diag = 0; - $this->_bottom_color = 0x40; - $this->_top_color = 0x40; - $this->_left_color = 0x40; - $this->_right_color = 0x40; + $this->bottomBorderColor = 0x40; + $this->topBorderColor = 0x40; + $this->leftBorderColor = 0x40; + $this->rightBorderColor = 0x40; $this->_diag_color = 0x40; $this->_style = $style; @@ -169,94 +169,94 @@ class PHPExcel_Writer_Excel5_Xf public function writeXf() { // Set the type of the XF record and some of the attributes. - if ($this->_isStyleXf) { + if ($this->isStyleXf) { $style = 0xFFF5; } else { - $style = self::_mapLocked($this->_style->getProtection()->getLocked()); - $style |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1; + $style = self::mapLocked($this->_style->getProtection()->getLocked()); + $style |= self::mapHidden($this->_style->getProtection()->getHidden()) << 1; } // Flags to indicate if attributes have been set. - $atr_num = ($this->_numberFormatIndex != 0)?1:0; - $atr_fnt = ($this->_fontIndex != 0)?1:0; + $atr_num = ($this->numberFormatIndex != 0)?1:0; + $atr_fnt = ($this->fontIndex != 0)?1:0; $atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0; - $atr_bdr = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) || - self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) || - self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) || - self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0; - $atr_pat = (($this->_fg_color != 0x40) || - ($this->_bg_color != 0x41) || - self::_mapFillType($this->_style->getFill()->getFillType()))?1:0; - $atr_prot = self::_mapLocked($this->_style->getProtection()->getLocked()) - | self::_mapHidden($this->_style->getProtection()->getHidden()); + $atr_bdr = (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) || + self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) || + self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) || + self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0; + $atr_pat = (($this->foregroundColor != 0x40) || + ($this->backgroundColor != 0x41) || + self::mapFillType($this->_style->getFill()->getFillType()))?1:0; + $atr_prot = self::mapLocked($this->_style->getProtection()->getLocked()) + | self::mapHidden($this->_style->getProtection()->getHidden()); // Zero the default border colour if the border has not been set. - if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) { - $this->_bottom_color = 0; + if (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) { + $this->bottomBorderColor = 0; } - if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) { - $this->_top_color = 0; + if (self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) { + $this->topBorderColor = 0; } - if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) { - $this->_right_color = 0; + if (self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) { + $this->rightBorderColor = 0; } - if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) { - $this->_left_color = 0; + if (self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) { + $this->leftBorderColor = 0; } - if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) { + if (self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) { $this->_diag_color = 0; } - $record = 0x00E0; // Record identifier - $length = 0x0014; // Number of bytes to follow + $record = 0x00E0; // Record identifier + $length = 0x0014; // Number of bytes to follow - $ifnt = $this->_fontIndex; // Index to FONT record - $ifmt = $this->_numberFormatIndex; // Index to FORMAT record + $ifnt = $this->fontIndex; // Index to FONT record + $ifmt = $this->numberFormatIndex; // Index to FORMAT record - $align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment - $align |= (int) $this->_style->getAlignment()->getWrapText() << 3; - $align |= self::_mapVAlign($this->_style->getAlignment()->getVertical()) << 4; - $align |= $this->_text_justlast << 7; + $align = $this->mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment + $align |= (int) $this->_style->getAlignment()->getWrapText() << 3; + $align |= self::mapVAlign($this->_style->getAlignment()->getVertical()) << 4; + $align |= $this->textJustLast << 7; - $used_attrib = $atr_num << 2; - $used_attrib |= $atr_fnt << 3; - $used_attrib |= $atr_alc << 4; - $used_attrib |= $atr_bdr << 5; - $used_attrib |= $atr_pat << 6; - $used_attrib |= $atr_prot << 7; + $used_attrib = $atr_num << 2; + $used_attrib |= $atr_fnt << 3; + $used_attrib |= $atr_alc << 4; + $used_attrib |= $atr_bdr << 5; + $used_attrib |= $atr_pat << 6; + $used_attrib |= $atr_prot << 7; - $icv = $this->_fg_color; // fg and bg pattern colors - $icv |= $this->_bg_color << 7; + $icv = $this->foregroundColor; // fg and bg pattern colors + $icv |= $this->backgroundColor << 7; - $border1 = self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color - $border1 |= self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4; - $border1 |= self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8; - $border1 |= self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12; - $border1 |= $this->_left_color << 16; - $border1 |= $this->_right_color << 23; + $border1 = self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color + $border1 |= self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4; + $border1 |= self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8; + $border1 |= self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12; + $border1 |= $this->leftBorderColor << 16; + $border1 |= $this->rightBorderColor << 23; $diagonalDirection = $this->_style->getBorders()->getDiagonalDirection(); $diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH || $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN; $diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH || $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP; - $border1 |= $diag_tl_to_rb << 30; - $border1 |= $diag_tr_to_lb << 31; + $border1 |= $diag_tl_to_rb << 30; + $border1 |= $diag_tr_to_lb << 31; - $border2 = $this->_top_color; // Border color - $border2 |= $this->_bottom_color << 7; - $border2 |= $this->_diag_color << 14; - $border2 |= self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21; - $border2 |= self::_mapFillType($this->_style->getFill()->getFillType()) << 26; + $border2 = $this->topBorderColor; // Border color + $border2 |= $this->bottomBorderColor << 7; + $border2 |= $this->_diag_color << 14; + $border2 |= self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21; + $border2 |= self::mapFillType($this->_style->getFill()->getFillType()) << 26; - $header = pack("vv", $record, $length); + $header = pack("vv", $record, $length); //BIFF8 options: identation, shrinkToFit and text direction $biff8_options = $this->_style->getAlignment()->getIndent(); $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4; $data = pack("vvvC", $ifnt, $ifmt, $style, $align); - $data .= pack("CCC", self::_mapTextRotation($this->_style->getAlignment()->getTextRotation()), $biff8_options, $used_attrib); + $data .= pack("CCC", self::mapTextRotation($this->_style->getAlignment()->getTextRotation()), $biff8_options, $used_attrib); $data .= pack("VVv", $border1, $border2, $icv); return($header . $data); @@ -269,7 +269,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setIsStyleXf($value) { - $this->_isStyleXf = $value; + $this->isStyleXf = $value; } /** @@ -280,7 +280,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setBottomColor($colorIndex) { - $this->_bottom_color = $colorIndex; + $this->bottomBorderColor = $colorIndex; } /** @@ -291,7 +291,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setTopColor($colorIndex) { - $this->_top_color = $colorIndex; + $this->topBorderColor = $colorIndex; } /** @@ -302,7 +302,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setLeftColor($colorIndex) { - $this->_left_color = $colorIndex; + $this->leftBorderColor = $colorIndex; } /** @@ -313,7 +313,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setRightColor($colorIndex) { - $this->_right_color = $colorIndex; + $this->rightBorderColor = $colorIndex; } /** @@ -336,7 +336,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setFgColor($colorIndex) { - $this->_fg_color = $colorIndex; + $this->foregroundColor = $colorIndex; } /** @@ -347,7 +347,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setBgColor($colorIndex) { - $this->_bg_color = $colorIndex; + $this->backgroundColor = $colorIndex; } /** @@ -359,7 +359,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setNumberFormatIndex($numberFormatIndex) { - $this->_numberFormatIndex = $numberFormatIndex; + $this->numberFormatIndex = $numberFormatIndex; } /** @@ -369,7 +369,7 @@ class PHPExcel_Writer_Excel5_Xf */ public function setFontIndex($value) { - $this->_fontIndex = $value; + $this->fontIndex = $value; } /** @@ -377,21 +377,22 @@ class PHPExcel_Writer_Excel5_Xf * @static array of int * */ - private static $_mapBorderStyle = array ( PHPExcel_Style_Border::BORDER_NONE => 0x00, - PHPExcel_Style_Border::BORDER_THIN => 0x01, - PHPExcel_Style_Border::BORDER_MEDIUM => 0x02, - PHPExcel_Style_Border::BORDER_DASHED => 0x03, - PHPExcel_Style_Border::BORDER_DOTTED => 0x04, - PHPExcel_Style_Border::BORDER_THICK => 0x05, - PHPExcel_Style_Border::BORDER_DOUBLE => 0x06, - PHPExcel_Style_Border::BORDER_HAIR => 0x07, - PHPExcel_Style_Border::BORDER_MEDIUMDASHED => 0x08, - PHPExcel_Style_Border::BORDER_DASHDOT => 0x09, - PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT => 0x0A, - PHPExcel_Style_Border::BORDER_DASHDOTDOT => 0x0B, - PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT => 0x0C, - PHPExcel_Style_Border::BORDER_SLANTDASHDOT => 0x0D, - ); + private static $mapBorderStyles = array( + PHPExcel_Style_Border::BORDER_NONE => 0x00, + PHPExcel_Style_Border::BORDER_THIN => 0x01, + PHPExcel_Style_Border::BORDER_MEDIUM => 0x02, + PHPExcel_Style_Border::BORDER_DASHED => 0x03, + PHPExcel_Style_Border::BORDER_DOTTED => 0x04, + PHPExcel_Style_Border::BORDER_THICK => 0x05, + PHPExcel_Style_Border::BORDER_DOUBLE => 0x06, + PHPExcel_Style_Border::BORDER_HAIR => 0x07, + PHPExcel_Style_Border::BORDER_MEDIUMDASHED => 0x08, + PHPExcel_Style_Border::BORDER_DASHDOT => 0x09, + PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT => 0x0A, + PHPExcel_Style_Border::BORDER_DASHDOTDOT => 0x0B, + PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT => 0x0C, + PHPExcel_Style_Border::BORDER_SLANTDASHDOT => 0x0D, + ); /** * Map border style @@ -399,10 +400,10 @@ class PHPExcel_Writer_Excel5_Xf * @param string $borderStyle * @return int */ - private static function _mapBorderStyle($borderStyle) + private static function mapBorderStyle($borderStyle) { - if (isset(self::$_mapBorderStyle[$borderStyle])) { - return self::$_mapBorderStyle[$borderStyle]; + if (isset(self::$mapBorderStyles[$borderStyle])) { + return self::$mapBorderStyles[$borderStyle]; } return 0x00; } @@ -412,38 +413,40 @@ class PHPExcel_Writer_Excel5_Xf * @static array of int * */ - private static $_mapFillType = array( PHPExcel_Style_Fill::FILL_NONE => 0x00, - PHPExcel_Style_Fill::FILL_SOLID => 0x01, - PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY => 0x02, - PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY => 0x03, - PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY => 0x04, - PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05, - PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL => 0x06, - PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN => 0x07, - PHPExcel_Style_Fill::FILL_PATTERN_DARKUP => 0x08, - PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID => 0x09, - PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS => 0x0A, - PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B, - PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C, - PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN => 0x0D, - PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP => 0x0E, - PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID => 0x0F, - PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10, - PHPExcel_Style_Fill::FILL_PATTERN_GRAY125 => 0x11, - PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625 => 0x12, - PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8 - PHPExcel_Style_Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8 - ); + private static $mapFillTypes = array( + PHPExcel_Style_Fill::FILL_NONE => 0x00, + PHPExcel_Style_Fill::FILL_SOLID => 0x01, + PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY => 0x02, + PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY => 0x03, + PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY => 0x04, + PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05, + PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL => 0x06, + PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN => 0x07, + PHPExcel_Style_Fill::FILL_PATTERN_DARKUP => 0x08, + PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID => 0x09, + PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS => 0x0A, + PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B, + PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C, + PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN => 0x0D, + PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP => 0x0E, + PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID => 0x0F, + PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10, + PHPExcel_Style_Fill::FILL_PATTERN_GRAY125 => 0x11, + PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625 => 0x12, + PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8 + PHPExcel_Style_Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8 + ); + /** * Map fill type * * @param string $fillType * @return int */ - private static function _mapFillType($fillType) + private static function mapFillType($fillType) { - if (isset(self::$_mapFillType[$fillType])) { - return self::$_mapFillType[$fillType]; + if (isset(self::$mapFillTypes[$fillType])) { + return self::$mapFillTypes[$fillType]; } return 0x00; } @@ -453,24 +456,26 @@ class PHPExcel_Writer_Excel5_Xf * @static array of int * */ - private static $_mapHAlign = array( PHPExcel_Style_Alignment::HORIZONTAL_GENERAL => 0, - PHPExcel_Style_Alignment::HORIZONTAL_LEFT => 1, - PHPExcel_Style_Alignment::HORIZONTAL_CENTER => 2, - PHPExcel_Style_Alignment::HORIZONTAL_RIGHT => 3, - PHPExcel_Style_Alignment::HORIZONTAL_FILL => 4, - PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY => 5, - PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6, - ); + private static $mapHAlignments = array( + PHPExcel_Style_Alignment::HORIZONTAL_GENERAL => 0, + PHPExcel_Style_Alignment::HORIZONTAL_LEFT => 1, + PHPExcel_Style_Alignment::HORIZONTAL_CENTER => 2, + PHPExcel_Style_Alignment::HORIZONTAL_RIGHT => 3, + PHPExcel_Style_Alignment::HORIZONTAL_FILL => 4, + PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY => 5, + PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6, + ); + /** * Map to BIFF2-BIFF8 codes for horizontal alignment * * @param string $hAlign * @return int */ - private function _mapHAlign($hAlign) + private function mapHAlign($hAlign) { - if (isset(self::$_mapHAlign[$hAlign])) { - return self::$_mapHAlign[$hAlign]; + if (isset(self::$mapHAlignments[$hAlign])) { + return self::$mapHAlignments[$hAlign]; } return 0; } @@ -480,21 +485,23 @@ class PHPExcel_Writer_Excel5_Xf * @static array of int * */ - private static $_mapVAlign = array( PHPExcel_Style_Alignment::VERTICAL_TOP => 0, - PHPExcel_Style_Alignment::VERTICAL_CENTER => 1, - PHPExcel_Style_Alignment::VERTICAL_BOTTOM => 2, - PHPExcel_Style_Alignment::VERTICAL_JUSTIFY => 3, - ); + private static $mapVAlignments = array( + PHPExcel_Style_Alignment::VERTICAL_TOP => 0, + PHPExcel_Style_Alignment::VERTICAL_CENTER => 1, + PHPExcel_Style_Alignment::VERTICAL_BOTTOM => 2, + PHPExcel_Style_Alignment::VERTICAL_JUSTIFY => 3, + ); + /** * Map to BIFF2-BIFF8 codes for vertical alignment * * @param string $vAlign * @return int */ - private static function _mapVAlign($vAlign) + private static function mapVAlign($vAlign) { - if (isset(self::$_mapVAlign[$vAlign])) { - return self::$_mapVAlign[$vAlign]; + if (isset(self::$mapVAlignments[$vAlign])) { + return self::$mapVAlignments[$vAlign]; } return 2; } @@ -505,15 +512,13 @@ class PHPExcel_Writer_Excel5_Xf * @param int $textRotation * @return int */ - private static function _mapTextRotation($textRotation) + private static function mapTextRotation($textRotation) { if ($textRotation >= 0) { return $textRotation; - } - if ($textRotation == -165) { + } elseif ($textRotation == -165) { return 255; - } - if ($textRotation < 0) { + } elseif ($textRotation < 0) { return 90 - $textRotation; } } @@ -524,7 +529,7 @@ class PHPExcel_Writer_Excel5_Xf * @param string * @return int */ - private static function _mapLocked($locked) + private static function mapLocked($locked) { switch ($locked) { case PHPExcel_Style_Protection::PROTECTION_INHERIT: @@ -544,7 +549,7 @@ class PHPExcel_Writer_Excel5_Xf * @param string * @return int */ - private static function _mapHidden($hidden) + private static function mapHidden($hidden) { switch ($hidden) { case PHPExcel_Style_Protection::PROTECTION_INHERIT: diff --git a/Classes/PHPExcel/Writer/PDF/Core.php b/Classes/PHPExcel/Writer/PDF/Core.php index 8075c555..ec3254b9 100644 --- a/Classes/PHPExcel/Writer/PDF/Core.php +++ b/Classes/PHPExcel/Writer/PDF/Core.php @@ -32,14 +32,14 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML * * @var string */ - protected $_tempDir = ''; + protected $tempDir = ''; /** * Font * * @var string */ - protected $_font = 'freesans'; + protected $font = 'freesans'; /** * Orientation (Over-ride) @@ -212,7 +212,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML { parent::__construct($phpExcel); $this->setUseInlineCss(true); - $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); + $this->tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); } /** @@ -222,7 +222,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML */ public function getFont() { - return $this->_font; + return $this->font; } /** @@ -236,7 +236,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML */ public function setFont($fontName) { - $this->_font = $fontName; + $this->font = $fontName; return $this; } @@ -291,7 +291,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML */ public function getTempDir() { - return $this->_tempDir; + return $this->tempDir; } /** @@ -304,7 +304,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML public function setTempDir($pValue = '') { if (is_dir($pValue)) { - $this->_tempDir = $pValue; + $this->tempDir = $pValue; } else { throw new PHPExcel_Writer_Exception("Directory does not exist: $pValue"); } diff --git a/unitTests/Classes/PHPExcel/AutoloaderTest.php b/unitTests/Classes/PHPExcel/AutoloaderTest.php index 286ef627..842d1797 100644 --- a/unitTests/Classes/PHPExcel/AutoloaderTest.php +++ b/unitTests/Classes/PHPExcel/AutoloaderTest.php @@ -6,8 +6,7 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); @@ -46,11 +45,10 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase public function testAutoloadInstantiateSuccess() { - $result = new PHPExcel_Calculation_Function(1,2,3); + $result = new PHPExcel_Calculation_Function(1, 2, 3); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type - $this->assertTrue(is_a($result,'PHPExcel_Calculation_Function')); + $this->assertTrue(is_a($result, 'PHPExcel_Calculation_Function')); } - -} \ No newline at end of file +} diff --git a/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php b/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php index d4bdc5ab..d42ae44d 100644 --- a/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php @@ -8,459 +8,457 @@ class DateTimeTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } /** * @dataProvider providerDATE */ - public function testDATE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'DATE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDATE() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/DATE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/DATE.data'); + } - public function testDATEtoPHP() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); - $result = PHPExcel_Calculation_DateTime::DATE(2012,1,31); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); - $this->assertEquals(1327968000, $result, NULL, 1E-8); - } + public function testDATEtoPHP() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); + $result = PHPExcel_Calculation_DateTime::DATE(2012, 1, 31); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + $this->assertEquals(1327968000, $result, null, 1E-8); + } - public function testDATEtoPHPObject() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); - $result = PHPExcel_Calculation_DateTime::DATE(2012,1,31); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + public function testDATEtoPHPObject() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); + $result = PHPExcel_Calculation_DateTime::DATE(2012, 1, 31); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type - $this->assertTrue(is_a($result,'DateTime')); + $this->assertTrue(is_a($result, 'DateTime')); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'),'31-Jan-2012'); - } + $this->assertEquals($result->format('d-M-Y'), '31-Jan-2012'); + } - public function testDATEwith1904Calendar() - { - PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); - $result = PHPExcel_Calculation_DateTime::DATE(1918,11,11); - PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); - $this->assertEquals($result,5428); - } + public function testDATEwith1904Calendar() + { + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); + $result = PHPExcel_Calculation_DateTime::DATE(1918, 11, 11); + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); + $this->assertEquals($result, 5428); + } - public function testDATEwith1904CalendarError() - { - PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); - $result = PHPExcel_Calculation_DateTime::DATE(1901,1,31); - PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); - $this->assertEquals($result,'#NUM!'); - } + public function testDATEwith1904CalendarError() + { + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); + $result = PHPExcel_Calculation_DateTime::DATE(1901, 1, 31); + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); + $this->assertEquals($result, '#NUM!'); + } /** * @dataProvider providerDATEVALUE */ - public function testDATEVALUE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEVALUE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDATEVALUE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'DATEVALUE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDATEVALUE() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data'); + } - public function testDATEVALUEtoPHP() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); - $result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31'); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); - $this->assertEquals(1327968000, $result, NULL, 1E-8); - } + public function testDATEVALUEtoPHP() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); + $result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31'); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + $this->assertEquals(1327968000, $result, null, 1E-8); + } - public function testDATEVALUEtoPHPObject() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); - $result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31'); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + public function testDATEVALUEtoPHPObject() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); + $result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31'); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type - $this->assertTrue(is_a($result,'DateTime')); + $this->assertTrue(is_a($result, 'DateTime')); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'),'31-Jan-2012'); - } + $this->assertEquals($result->format('d-M-Y'), '31-Jan-2012'); + } /** * @dataProvider providerYEAR */ - public function testYEAR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEAR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testYEAR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'YEAR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerYEAR() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data'); + } /** * @dataProvider providerMONTH */ - public function testMONTH() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MONTHOFYEAR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testMONTH() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'MONTHOFYEAR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerMONTH() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data'); + } /** * @dataProvider providerWEEKNUM */ - public function testWEEKNUM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WEEKOFYEAR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testWEEKNUM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'WEEKOFYEAR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerWEEKNUM() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data'); + } /** * @dataProvider providerWEEKDAY */ - public function testWEEKDAY() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFWEEK'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testWEEKDAY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'DAYOFWEEK'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerWEEKDAY() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data'); + } /** * @dataProvider providerDAY */ - public function testDAY() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFMONTH'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDAY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'DAYOFMONTH'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDAY() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/DAY.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/DAY.data'); + } /** * @dataProvider providerTIME */ - public function testTIME() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIME'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testTIME() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'TIME'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerTIME() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/TIME.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/TIME.data'); + } - public function testTIMEtoPHP() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); - $result = PHPExcel_Calculation_DateTime::TIME(7,30,20); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); - $this->assertEquals(27020, $result, NULL, 1E-8); - } + public function testTIMEtoPHP() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); + $result = PHPExcel_Calculation_DateTime::TIME(7, 30, 20); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + $this->assertEquals(27020, $result, null, 1E-8); + } - public function testTIMEtoPHPObject() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); - $result = PHPExcel_Calculation_DateTime::TIME(7,30,20); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + public function testTIMEtoPHPObject() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); + $result = PHPExcel_Calculation_DateTime::TIME(7, 30, 20); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type - $this->assertTrue(is_a($result,'DateTime')); + $this->assertTrue(is_a($result, 'DateTime')); // ... with the correct value - $this->assertEquals($result->format('H:i:s'),'07:30:20'); - } + $this->assertEquals($result->format('H:i:s'), '07:30:20'); + } /** * @dataProvider providerTIMEVALUE */ - public function testTIMEVALUE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIMEVALUE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testTIMEVALUE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'TIMEVALUE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerTIMEVALUE() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data'); + } - public function testTIMEVALUEtoPHP() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); - $result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20'); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); - $this->assertEquals(23420, $result, NULL, 1E-8); - } + public function testTIMEVALUEtoPHP() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); + $result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20'); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + $this->assertEquals(23420, $result, null, 1E-8); + } - public function testTIMEVALUEtoPHPObject() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); - $result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20'); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + public function testTIMEVALUEtoPHPObject() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); + $result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20'); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type - $this->assertTrue(is_a($result,'DateTime')); + $this->assertTrue(is_a($result, 'DateTime')); // ... with the correct value - $this->assertEquals($result->format('H:i:s'),'07:30:20'); - } + $this->assertEquals($result->format('H:i:s'), '07:30:20'); + } /** * @dataProvider providerHOUR */ - public function testHOUR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','HOUROFDAY'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testHOUR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'HOUROFDAY'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerHOUR() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data'); + } /** * @dataProvider providerMINUTE */ - public function testMINUTE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MINUTEOFHOUR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testMINUTE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'MINUTEOFHOUR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerMINUTE() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data'); + } /** * @dataProvider providerSECOND */ - public function testSECOND() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','SECONDOFMINUTE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testSECOND() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'SECONDOFMINUTE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerSECOND() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data'); + } /** * @dataProvider providerNETWORKDAYS */ - public function testNETWORKDAYS() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','NETWORKDAYS'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testNETWORKDAYS() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'NETWORKDAYS'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerNETWORKDAYS() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data'); + } /** * @dataProvider providerWORKDAY */ - public function testWORKDAY() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WORKDAY'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testWORKDAY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'WORKDAY'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerWORKDAY() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data'); + } /** * @dataProvider providerEDATE */ - public function testEDATE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EDATE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testEDATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'EDATE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerEDATE() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data'); + } - public function testEDATEtoPHP() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); - $result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26',-1); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); - $this->assertEquals(1324857600, $result, NULL, 1E-8); - } + public function testEDATEtoPHP() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); + $result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26', -1); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + $this->assertEquals(1324857600, $result, null, 1E-8); + } - public function testEDATEtoPHPObject() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); - $result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26',-1); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + public function testEDATEtoPHPObject() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); + $result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26', -1); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type - $this->assertTrue(is_a($result,'DateTime')); + $this->assertTrue(is_a($result, 'DateTime')); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'),'26-Dec-2011'); - } + $this->assertEquals($result->format('d-M-Y'), '26-Dec-2011'); + } /** * @dataProvider providerEOMONTH */ - public function testEOMONTH() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EOMONTH'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testEOMONTH() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'EOMONTH'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerEOMONTH() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data'); + } - public function testEOMONTHtoPHP() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); - $result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26',-1); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); - $this->assertEquals(1325289600, $result, NULL, 1E-8); - } + public function testEOMONTHtoPHP() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); + $result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26', -1); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + $this->assertEquals(1325289600, $result, null, 1E-8); + } - public function testEOMONTHtoPHPObject() - { - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); - $result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26',-1); - PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + public function testEOMONTHtoPHPObject() + { + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT); + $result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26', -1); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type - $this->assertTrue(is_a($result,'DateTime')); + $this->assertTrue(is_a($result, 'DateTime')); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'),'31-Dec-2011'); - } + $this->assertEquals($result->format('d-M-Y'), '31-Dec-2011'); + } /** * @dataProvider providerDATEDIF */ - public function testDATEDIF() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEDIF'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDATEDIF() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'DATEDIF'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDATEDIF() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data'); + } /** * @dataProvider providerDAYS360 */ - public function testDAYS360() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYS360'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDAYS360() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'DAYS360'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDAYS360() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data'); - } + return new testDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data'); + } /** * @dataProvider providerYEARFRAC */ - public function testYEARFRAC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEARFRAC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testYEARFRAC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime', 'YEARFRAC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerYEARFRAC() { - return new testDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data'); - } - + return new testDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php b/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php index 1f511ffa..08448f55 100644 --- a/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php @@ -12,687 +12,672 @@ class EngineeringTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } /** * @dataProvider providerBESSELI */ - public function testBESSELI() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELI'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testBESSELI() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELI'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerBESSELI() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELI.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELI.data'); + } /** * @dataProvider providerBESSELJ */ - public function testBESSELJ() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELJ'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testBESSELJ() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELJ'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerBESSELJ() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELJ.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELJ.data'); + } /** * @dataProvider providerBESSELK */ - public function testBESSELK() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELK'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testBESSELK() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELK'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerBESSELK() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELK.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELK.data'); + } /** * @dataProvider providerBESSELY */ - public function testBESSELY() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELY'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testBESSELY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BESSELY'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerBESSELY() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELY.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/BESSELY.data'); + } /** * @dataProvider providerCOMPLEX */ - public function testCOMPLEX() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','COMPLEX'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCOMPLEX() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','COMPLEX'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCOMPLEX() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/COMPLEX.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/COMPLEX.data'); + } /** * @dataProvider providerIMAGINARY */ - public function testIMAGINARY() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMAGINARY'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIMAGINARY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMAGINARY'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIMAGINARY() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMAGINARY.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMAGINARY.data'); + } /** * @dataProvider providerIMREAL */ - public function testIMREAL() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMREAL'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIMREAL() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMREAL'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIMREAL() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMREAL.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMREAL.data'); + } /** * @dataProvider providerIMABS */ - public function testIMABS() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMABS'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIMABS() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMABS'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIMABS() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMABS.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMABS.data'); + } /** * @dataProvider providerIMARGUMENT */ - public function testIMARGUMENT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMARGUMENT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIMARGUMENT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMARGUMENT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIMARGUMENT() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMARGUMENT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMARGUMENT.data'); + } /** * @dataProvider providerIMCONJUGATE */ - public function testIMCONJUGATE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMCONJUGATE'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMCONJUGATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMCONJUGATE'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMCONJUGATE() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMCONJUGATE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMCONJUGATE.data'); + } /** * @dataProvider providerIMCOS */ - public function testIMCOS() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMCOS'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMCOS() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMCOS'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMCOS() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMCOS.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMCOS.data'); + } /** * @dataProvider providerIMDIV */ - public function testIMDIV() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMDIV'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMDIV() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMDIV'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMDIV() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMDIV.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMDIV.data'); + } /** * @dataProvider providerIMEXP */ - public function testIMEXP() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMEXP'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMEXP() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMEXP'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMEXP() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMEXP.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMEXP.data'); + } /** * @dataProvider providerIMLN */ - public function testIMLN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMLN'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMLN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMLN'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMLN() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMLN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMLN.data'); + } /** * @dataProvider providerIMLOG2 */ - public function testIMLOG2() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMLOG2'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMLOG2() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMLOG2'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMLOG2() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMLOG2.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMLOG2.data'); + } /** * @dataProvider providerIMLOG10 */ - public function testIMLOG10() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMLOG10'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMLOG10() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMLOG10'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMLOG10() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMLOG10.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMLOG10.data'); + } /** * @dataProvider providerIMPOWER */ - public function testIMPOWER() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMPOWER'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMPOWER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMPOWER'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMPOWER() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMPOWER.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMPOWER.data'); + } /** * @dataProvider providerIMPRODUCT */ - public function testIMPRODUCT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMPRODUCT'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMPRODUCT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMPRODUCT'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMPRODUCT() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMPRODUCT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMPRODUCT.data'); + } /** * @dataProvider providerIMSIN */ - public function testIMSIN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSIN'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMSIN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSIN'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMSIN() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSIN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSIN.data'); + } /** * @dataProvider providerIMSQRT */ - public function testIMSQRT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSQRT'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMSQRT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSQRT'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMSQRT() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSQRT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSQRT.data'); + } /** * @dataProvider providerIMSUB */ - public function testIMSUB() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSUB'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMSUB() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSUB'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMSUB() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSUB.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSUB.data'); + } /** * @dataProvider providerIMSUM */ - public function testIMSUM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSUM'),$args); - $complexAssert = new complexAssert(); - $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), - $complexAssert->getErrorMessage()); - } + public function testIMSUM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','IMSUM'), $args); + $complexAssert = new complexAssert(); + $this->assertTrue($complexAssert->assertComplexEquals($expectedResult, $result, 1E-8), $complexAssert->getErrorMessage()); + } public function providerIMSUM() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSUM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/IMSUM.data'); + } /** * @dataProvider providerERF */ - public function testERF() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','ERF'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testERF() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','ERF'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerERF() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/ERF.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/ERF.data'); + } /** * @dataProvider providerERFC */ - public function testERFC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','ERFC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testERFC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','ERFC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerERFC() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/ERFC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/ERFC.data'); + } /** * @dataProvider providerBIN2DEC */ - public function testBIN2DEC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BINTODEC'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testBIN2DEC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BINTODEC'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerBIN2DEC() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/BIN2DEC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/BIN2DEC.data'); + } /** * @dataProvider providerBIN2HEX */ - public function testBIN2HEX() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BINTOHEX'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testBIN2HEX() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BINTOHEX'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerBIN2HEX() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/BIN2HEX.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/BIN2HEX.data'); + } /** * @dataProvider providerBIN2OCT */ - public function testBIN2OCT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BINTOOCT'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testBIN2OCT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','BINTOOCT'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerBIN2OCT() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/BIN2OCT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/BIN2OCT.data'); + } /** * @dataProvider providerDEC2BIN */ - public function testDEC2BIN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DECTOBIN'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testDEC2BIN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DECTOBIN'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerDEC2BIN() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/DEC2BIN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/DEC2BIN.data'); + } /** * @dataProvider providerDEC2HEX */ - public function testDEC2HEX() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DECTOHEX'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testDEC2HEX() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DECTOHEX'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerDEC2HEX() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/DEC2HEX.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/DEC2HEX.data'); + } /** * @dataProvider providerDEC2OCT */ - public function testDEC2OCT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DECTOOCT'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testDEC2OCT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DECTOOCT'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerDEC2OCT() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/DEC2OCT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/DEC2OCT.data'); + } /** * @dataProvider providerHEX2BIN */ - public function testHEX2BIN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','HEXTOBIN'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testHEX2BIN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','HEXTOBIN'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerHEX2BIN() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/HEX2BIN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/HEX2BIN.data'); + } /** * @dataProvider providerHEX2DEC */ - public function testHEX2DEC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','HEXTODEC'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testHEX2DEC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','HEXTODEC'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerHEX2DEC() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/HEX2DEC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/HEX2DEC.data'); + } /** * @dataProvider providerHEX2OCT */ - public function testHEX2OCT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','HEXTOOCT'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testHEX2OCT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','HEXTOOCT'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerHEX2OCT() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/HEX2OCT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/HEX2OCT.data'); + } /** * @dataProvider providerOCT2BIN */ - public function testOCT2BIN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','OCTTOBIN'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testOCT2BIN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','OCTTOBIN'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerOCT2BIN() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/OCT2BIN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/OCT2BIN.data'); + } /** * @dataProvider providerOCT2DEC */ - public function testOCT2DEC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','OCTTODEC'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testOCT2DEC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','OCTTODEC'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerOCT2DEC() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/OCT2DEC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/OCT2DEC.data'); + } /** * @dataProvider providerOCT2HEX */ - public function testOCT2HEX() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','OCTTOHEX'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testOCT2HEX() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','OCTTOHEX'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerOCT2HEX() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/OCT2HEX.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/OCT2HEX.data'); + } /** * @dataProvider providerDELTA */ - public function testDELTA() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DELTA'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testDELTA() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','DELTA'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerDELTA() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/DELTA.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/DELTA.data'); + } /** * @dataProvider providerGESTEP */ - public function testGESTEP() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','GESTEP'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testGESTEP() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','GESTEP'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerGESTEP() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/GESTEP.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Engineering/GESTEP.data'); + } - public function testGetConversionGroups() - { - $result = PHPExcel_Calculation_Engineering::getConversionGroups(); - $this->assertInternalType('array', $result); - } + public function testGetConversionGroups() + { + $result = PHPExcel_Calculation_Engineering::getConversionGroups(); + $this->assertInternalType('array', $result); + } - public function testGetConversionGroupUnits() - { - $result = PHPExcel_Calculation_Engineering::getConversionGroupUnits(); - $this->assertInternalType('array', $result); - } + public function testGetConversionGroupUnits() + { + $result = PHPExcel_Calculation_Engineering::getConversionGroupUnits(); + $this->assertInternalType('array', $result); + } - public function testGetConversionGroupUnitDetails() - { - $result = PHPExcel_Calculation_Engineering::getConversionGroupUnitDetails(); - $this->assertInternalType('array', $result); - } + public function testGetConversionGroupUnitDetails() + { + $result = PHPExcel_Calculation_Engineering::getConversionGroupUnitDetails(); + $this->assertInternalType('array', $result); + } - public function testGetConversionMultipliers() - { - $result = PHPExcel_Calculation_Engineering::getConversionMultipliers(); - $this->assertInternalType('array', $result); - } + public function testGetConversionMultipliers() + { + $result = PHPExcel_Calculation_Engineering::getConversionMultipliers(); + $this->assertInternalType('array', $result); + } /** * @dataProvider providerCONVERTUOM */ - public function testCONVERTUOM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','CONVERTUOM'),$args); - $this->assertEquals($expectedResult, $result, NULL); - } + public function testCONVERTUOM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Engineering','CONVERTUOM'), $args); + $this->assertEquals($expectedResult, $result, null); + } public function providerCONVERTUOM() { - return new testDataFileIterator('rawTestData/Calculation/Engineering/CONVERTUOM.data'); - } - + return new testDataFileIterator('rawTestData/Calculation/Engineering/CONVERTUOM.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php b/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php index f5689c95..f6e39814 100644 --- a/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php @@ -8,509 +8,507 @@ class FinancialTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } /** * @dataProvider providerACCRINT */ - public function testACCRINT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testACCRINT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerACCRINT() { - return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINT.data'); + } /** * @dataProvider providerACCRINTM */ - public function testACCRINTM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINTM'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testACCRINTM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINTM'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerACCRINTM() { - return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINTM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINTM.data'); + } /** * @dataProvider providerAMORDEGRC */ - public function testAMORDEGRC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORDEGRC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testAMORDEGRC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORDEGRC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerAMORDEGRC() { - return new testDataFileIterator('rawTestData/Calculation/Financial/AMORDEGRC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/AMORDEGRC.data'); + } /** * @dataProvider providerAMORLINC */ - public function testAMORLINC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORLINC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testAMORLINC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORLINC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerAMORLINC() { - return new testDataFileIterator('rawTestData/Calculation/Financial/AMORLINC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/AMORLINC.data'); + } /** * @dataProvider providerCOUPDAYBS */ - public function testCOUPDAYBS() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYBS'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCOUPDAYBS() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYBS'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCOUPDAYBS() { - return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYBS.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYBS.data'); + } /** * @dataProvider providerCOUPDAYS */ - public function testCOUPDAYS() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYS'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCOUPDAYS() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYS'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCOUPDAYS() { - return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYS.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYS.data'); + } /** * @dataProvider providerCOUPDAYSNC */ - public function testCOUPDAYSNC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYSNC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCOUPDAYSNC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYSNC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCOUPDAYSNC() { - return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYSNC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYSNC.data'); + } /** * @dataProvider providerCOUPNCD */ - public function testCOUPNCD() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNCD'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCOUPNCD() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNCD'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCOUPNCD() { - return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNCD.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNCD.data'); + } /** * @dataProvider providerCOUPNUM */ - public function testCOUPNUM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNUM'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCOUPNUM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNUM'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCOUPNUM() { - return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNUM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNUM.data'); + } /** * @dataProvider providerCOUPPCD */ - public function testCOUPPCD() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPPCD'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCOUPPCD() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPPCD'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCOUPPCD() { - return new testDataFileIterator('rawTestData/Calculation/Financial/COUPPCD.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/COUPPCD.data'); + } /** * @dataProvider providerCUMIPMT */ - public function testCUMIPMT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMIPMT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCUMIPMT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMIPMT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCUMIPMT() { - return new testDataFileIterator('rawTestData/Calculation/Financial/CUMIPMT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/CUMIPMT.data'); + } /** * @dataProvider providerCUMPRINC */ - public function testCUMPRINC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMPRINC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testCUMPRINC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMPRINC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerCUMPRINC() { - return new testDataFileIterator('rawTestData/Calculation/Financial/CUMPRINC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/CUMPRINC.data'); + } /** * @dataProvider providerDB */ - public function testDB() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DB'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDB() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DB'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDB() { - return new testDataFileIterator('rawTestData/Calculation/Financial/DB.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/DB.data'); + } /** * @dataProvider providerDDB */ - public function testDDB() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DDB'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDDB() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DDB'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDDB() { - return new testDataFileIterator('rawTestData/Calculation/Financial/DDB.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/DDB.data'); + } /** * @dataProvider providerDISC */ - public function testDISC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DISC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDISC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DISC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDISC() { - return new testDataFileIterator('rawTestData/Calculation/Financial/DISC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/DISC.data'); + } /** * @dataProvider providerDOLLARDE */ - public function testDOLLARDE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARDE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDOLLARDE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARDE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDOLLARDE() { - return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARDE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARDE.data'); + } /** * @dataProvider providerDOLLARFR */ - public function testDOLLARFR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARFR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testDOLLARFR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARFR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerDOLLARFR() { - return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARFR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARFR.data'); + } /** * @dataProvider providerEFFECT */ - public function testEFFECT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','EFFECT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testEFFECT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','EFFECT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerEFFECT() { - return new testDataFileIterator('rawTestData/Calculation/Financial/EFFECT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/EFFECT.data'); + } /** * @dataProvider providerFV */ - public function testFV() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','FV'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testFV() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','FV'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerFV() { - return new testDataFileIterator('rawTestData/Calculation/Financial/FV.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/FV.data'); + } /** * @dataProvider providerFVSCHEDULE */ - public function testFVSCHEDULE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','FVSCHEDULE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testFVSCHEDULE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','FVSCHEDULE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerFVSCHEDULE() { - return new testDataFileIterator('rawTestData/Calculation/Financial/FVSCHEDULE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/FVSCHEDULE.data'); + } /** * @dataProvider providerINTRATE */ - public function testINTRATE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','INTRATE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testINTRATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','INTRATE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerINTRATE() { - return new testDataFileIterator('rawTestData/Calculation/Financial/INTRATE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/INTRATE.data'); + } /** * @dataProvider providerIPMT */ - public function testIPMT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','IPMT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIPMT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','IPMT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIPMT() { - return new testDataFileIterator('rawTestData/Calculation/Financial/IPMT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/IPMT.data'); + } /** * @dataProvider providerIRR */ - public function testIRR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','IRR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIRR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','IRR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIRR() { - return new testDataFileIterator('rawTestData/Calculation/Financial/IRR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/IRR.data'); + } /** * @dataProvider providerISPMT */ - public function testISPMT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ISPMT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testISPMT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ISPMT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerISPMT() { - return new testDataFileIterator('rawTestData/Calculation/Financial/ISPMT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/ISPMT.data'); + } /** * @dataProvider providerMIRR */ - public function testMIRR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','MIRR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testMIRR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','MIRR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerMIRR() { - return new testDataFileIterator('rawTestData/Calculation/Financial/MIRR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/MIRR.data'); + } /** * @dataProvider providerNOMINAL */ - public function testNOMINAL() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NOMINAL'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testNOMINAL() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NOMINAL'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerNOMINAL() { - return new testDataFileIterator('rawTestData/Calculation/Financial/NOMINAL.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/NOMINAL.data'); + } /** * @dataProvider providerNPER */ - public function testNPER() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPER'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testNPER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPER'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerNPER() { - return new testDataFileIterator('rawTestData/Calculation/Financial/NPER.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/NPER.data'); + } /** * @dataProvider providerNPV */ - public function testNPV() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPV'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testNPV() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPV'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerNPV() { - return new testDataFileIterator('rawTestData/Calculation/Financial/NPV.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/NPV.data'); + } /** * @dataProvider providerPRICE */ - public function testPRICE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','PRICE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testPRICE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','PRICE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerPRICE() { - return new testDataFileIterator('rawTestData/Calculation/Financial/PRICE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/PRICE.data'); + } /** * @dataProvider providerRATE */ - public function testRATE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','RATE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testRATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','RATE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerRATE() { - return new testDataFileIterator('rawTestData/Calculation/Financial/RATE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Financial/RATE.data'); + } /** * @dataProvider providerXIRR */ - public function testXIRR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Financial','XIRR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testXIRR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Financial','XIRR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerXIRR() { - return new testDataFileIterator('rawTestData/Calculation/Financial/XIRR.data'); - } - + return new testDataFileIterator('rawTestData/Calculation/Financial/XIRR.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php b/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php index 01333294..61c48205 100644 --- a/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php @@ -8,269 +8,267 @@ class FunctionsTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } - public function testDUMMY() - { - $result = PHPExcel_Calculation_Functions::DUMMY(); - $this->assertEquals('#Not Yet Implemented', $result); - } + public function testDUMMY() + { + $result = PHPExcel_Calculation_Functions::DUMMY(); + $this->assertEquals('#Not Yet Implemented', $result); + } - public function testDIV0() - { - $result = PHPExcel_Calculation_Functions::DIV0(); - $this->assertEquals('#DIV/0!', $result); - } + public function testDIV0() + { + $result = PHPExcel_Calculation_Functions::DIV0(); + $this->assertEquals('#DIV/0!', $result); + } - public function testNA() - { - $result = PHPExcel_Calculation_Functions::NA(); - $this->assertEquals('#N/A', $result); - } + public function testNA() + { + $result = PHPExcel_Calculation_Functions::NA(); + $this->assertEquals('#N/A', $result); + } - public function testNaN() - { - $result = PHPExcel_Calculation_Functions::NaN(); - $this->assertEquals('#NUM!', $result); - } + public function testNaN() + { + $result = PHPExcel_Calculation_Functions::NaN(); + $this->assertEquals('#NUM!', $result); + } - public function testNAME() - { - $result = PHPExcel_Calculation_Functions::NAME(); - $this->assertEquals('#NAME?', $result); - } + public function testNAME() + { + $result = PHPExcel_Calculation_Functions::NAME(); + $this->assertEquals('#NAME?', $result); + } - public function testREF() - { - $result = PHPExcel_Calculation_Functions::REF(); - $this->assertEquals('#REF!', $result); - } + public function testREF() + { + $result = PHPExcel_Calculation_Functions::REF(); + $this->assertEquals('#REF!', $result); + } - public function testNULL() - { - $result = PHPExcel_Calculation_Functions::NULL(); - $this->assertEquals('#NULL!', $result); - } + public function testNULL() + { + $result = PHPExcel_Calculation_Functions::null(); + $this->assertEquals('#NULL!', $result); + } - public function testVALUE() - { - $result = PHPExcel_Calculation_Functions::VALUE(); - $this->assertEquals('#VALUE!', $result); - } + public function testVALUE() + { + $result = PHPExcel_Calculation_Functions::VALUE(); + $this->assertEquals('#VALUE!', $result); + } /** * @dataProvider providerIS_BLANK */ - public function testIS_BLANK() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_BLANK'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_BLANK() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_BLANK'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_BLANK() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_BLANK.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_BLANK.data'); + } /** * @dataProvider providerIS_ERR */ - public function testIS_ERR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_ERR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_ERR() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERR.data'); + } /** * @dataProvider providerIS_ERROR */ - public function testIS_ERROR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERROR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_ERROR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERROR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_ERROR() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERROR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERROR.data'); + } /** * @dataProvider providerERROR_TYPE */ - public function testERROR_TYPE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','ERROR_TYPE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testERROR_TYPE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','ERROR_TYPE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerERROR_TYPE() { - return new testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data'); + } /** * @dataProvider providerIS_LOGICAL */ - public function testIS_LOGICAL() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_LOGICAL'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_LOGICAL() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_LOGICAL'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_LOGICAL() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_LOGICAL.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_LOGICAL.data'); + } /** * @dataProvider providerIS_NA */ - public function testIS_NA() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NA'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_NA() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NA'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_NA() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NA.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NA.data'); + } /** * @dataProvider providerIS_NUMBER */ - public function testIS_NUMBER() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NUMBER'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_NUMBER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NUMBER'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_NUMBER() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NUMBER.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NUMBER.data'); + } /** * @dataProvider providerIS_TEXT */ - public function testIS_TEXT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_TEXT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_TEXT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_TEXT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_TEXT() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_TEXT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_TEXT.data'); + } /** * @dataProvider providerIS_NONTEXT */ - public function testIS_NONTEXT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NONTEXT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_NONTEXT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NONTEXT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_NONTEXT() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NONTEXT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NONTEXT.data'); + } /** * @dataProvider providerIS_EVEN */ - public function testIS_EVEN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_EVEN'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_EVEN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_EVEN'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_EVEN() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_EVEN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_EVEN.data'); + } /** * @dataProvider providerIS_ODD */ - public function testIS_ODD() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ODD'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testIS_ODD() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ODD'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerIS_ODD() { - return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ODD.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ODD.data'); + } /** * @dataProvider providerTYPE */ - public function testTYPE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','TYPE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testTYPE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','TYPE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerTYPE() { - return new testDataFileIterator('rawTestData/Calculation/Functions/TYPE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Functions/TYPE.data'); + } /** * @dataProvider providerN */ - public function testN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Functions','N'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + public function testN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Functions','N'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerN() { - return new testDataFileIterator('rawTestData/Calculation/Functions/N.data'); - } - + return new testDataFileIterator('rawTestData/Calculation/Functions/N.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php b/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php index cc8f8b33..e475c30f 100644 --- a/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php @@ -8,105 +8,103 @@ class LogicalTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } - public function testTRUE() - { - $result = PHPExcel_Calculation_Logical::TRUE(); - $this->assertEquals(TRUE, $result); - } + public function testTRUE() + { + $result = PHPExcel_Calculation_Logical::TRUE(); + $this->assertEquals(true, $result); + } - public function testFALSE() - { - $result = PHPExcel_Calculation_Logical::FALSE(); - $this->assertEquals(FALSE, $result); - } + public function testFALSE() + { + $result = PHPExcel_Calculation_Logical::FALSE(); + $this->assertEquals(false, $result); + } /** * @dataProvider providerAND */ - public function testAND() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_AND'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testAND() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_AND'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerAND() { - return new testDataFileIterator('rawTestData/Calculation/Logical/AND.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Logical/AND.data'); + } /** * @dataProvider providerOR */ - public function testOR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_OR'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testOR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_OR'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerOR() { - return new testDataFileIterator('rawTestData/Calculation/Logical/OR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Logical/OR.data'); + } /** * @dataProvider providerNOT */ public function testNOT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Logical','NOT'),$args); - $this->assertEquals($expectedResult, $result); - } + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Logical','NOT'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerNOT() { - return new testDataFileIterator('rawTestData/Calculation/Logical/NOT.data'); + return new testDataFileIterator('rawTestData/Calculation/Logical/NOT.data'); } /** * @dataProvider providerIF */ public function testIF() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Logical','STATEMENT_IF'),$args); - $this->assertEquals($expectedResult, $result); - } + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Logical','STATEMENT_IF'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerIF() { - return new testDataFileIterator('rawTestData/Calculation/Logical/IF.data'); - } + return new testDataFileIterator('rawTestData/Calculation/Logical/IF.data'); + } /** * @dataProvider providerIFERROR */ public function testIFERROR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_Logical','IFERROR'),$args); - $this->assertEquals($expectedResult, $result); - } + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_Logical','IFERROR'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerIFERROR() { return new testDataFileIterator('rawTestData/Calculation/Logical/IFERROR.data'); - } - + } } diff --git a/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php b/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php index 6450b082..1408b73b 100644 --- a/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php @@ -8,45 +8,43 @@ class LookupRefTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } /** * @dataProvider providerHLOOKUP */ - public function testHLOOKUP() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_LookupRef','HLOOKUP'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testHLOOKUP() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_LookupRef','HLOOKUP'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerHLOOKUP() { - return new testDataFileIterator('rawTestData/Calculation/LookupRef/HLOOKUP.data'); - } + return new testDataFileIterator('rawTestData/Calculation/LookupRef/HLOOKUP.data'); + } /** * @dataProvider providerVLOOKUP */ - public function testVLOOKUP() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_LookupRef','VLOOKUP'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testVLOOKUP() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_LookupRef','VLOOKUP'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerVLOOKUP() { - return new testDataFileIterator('rawTestData/Calculation/LookupRef/VLOOKUP.data'); - } - + return new testDataFileIterator('rawTestData/Calculation/LookupRef/VLOOKUP.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php b/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php index 0059ed08..40d1c505 100644 --- a/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php @@ -8,479 +8,478 @@ class MathTrigTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } /** * @dataProvider providerATAN2 */ - public function testATAN2() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ATAN2'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testATAN2() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ATAN2'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerATAN2() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/ATAN2.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ATAN2.data'); + } /** * @dataProvider providerCEILING */ - public function testCEILING() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','CEILING'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testCEILING() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','CEILING'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerCEILING() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/CEILING.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/CEILING.data'); + } /** * @dataProvider providerCOMBIN */ - public function testCOMBIN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','COMBIN'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testCOMBIN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','COMBIN'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerCOMBIN() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/COMBIN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/COMBIN.data'); + } /** * @dataProvider providerEVEN */ - public function testEVEN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','EVEN'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testEVEN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','EVEN'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerEVEN() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/EVEN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/EVEN.data'); + } /** * @dataProvider providerODD */ - public function testODD() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ODD'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testODD() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ODD'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerODD() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/ODD.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ODD.data'); + } /** * @dataProvider providerFACT */ - public function testFACT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testFACT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerFACT() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACT.data'); + } /** * @dataProvider providerFACTDOUBLE */ - public function testFACTDOUBLE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACTDOUBLE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testFACTDOUBLE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACTDOUBLE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerFACTDOUBLE() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACTDOUBLE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACTDOUBLE.data'); + } /** * @dataProvider providerFLOOR */ - public function testFLOOR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FLOOR'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testFLOOR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FLOOR'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerFLOOR() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/FLOOR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/FLOOR.data'); + } /** * @dataProvider providerGCD */ - public function testGCD() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','GCD'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testGCD() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','GCD'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerGCD() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/GCD.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/GCD.data'); + } /** * @dataProvider providerLCM */ - public function testLCM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LCM'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testLCM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LCM'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerLCM() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data'); + } /** * @dataProvider providerINT */ - public function testINT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','INT'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testINT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','INT'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerINT() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/INT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/INT.data'); + } /** * @dataProvider providerSIGN */ - public function testSIGN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SIGN'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testSIGN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SIGN'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerSIGN() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data'); + } /** * @dataProvider providerPOWER */ - public function testPOWER() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','POWER'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testPOWER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','POWER'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerPOWER() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data'); + } /** * @dataProvider providerLOG */ - public function testLOG() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LOG_BASE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testLOG() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LOG_BASE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerLOG() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data'); + } /** * @dataProvider providerMOD */ - public function testMOD() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MOD'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testMOD() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MOD'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerMOD() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data'); + } /** * @dataProvider providerMDETERM */ - public function testMDETERM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MDETERM'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testMDETERM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MDETERM'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerMDETERM() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data'); + } /** * @dataProvider providerMINVERSE */ - public function testMINVERSE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MINVERSE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testMINVERSE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MINVERSE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerMINVERSE() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data'); + } /** * @dataProvider providerMMULT */ - public function testMMULT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MMULT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testMMULT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MMULT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerMMULT() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/MMULT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MMULT.data'); + } /** * @dataProvider providerMULTINOMIAL */ - public function testMULTINOMIAL() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MULTINOMIAL'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testMULTINOMIAL() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MULTINOMIAL'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerMULTINOMIAL() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/MULTINOMIAL.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MULTINOMIAL.data'); + } /** * @dataProvider providerMROUND */ - public function testMROUND() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MROUND'),$args); - PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_ARRAY); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testMROUND() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MROUND'), $args); + PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_ARRAY); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerMROUND() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data'); + } /** * @dataProvider providerPRODUCT */ - public function testPRODUCT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','PRODUCT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testPRODUCT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','PRODUCT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerPRODUCT() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/PRODUCT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/PRODUCT.data'); + } /** * @dataProvider providerQUOTIENT */ - public function testQUOTIENT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','QUOTIENT'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testQUOTIENT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','QUOTIENT'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerQUOTIENT() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/QUOTIENT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/QUOTIENT.data'); + } /** * @dataProvider providerROUNDUP */ - public function testROUNDUP() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDUP'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testROUNDUP() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDUP'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerROUNDUP() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data'); + } /** * @dataProvider providerROUNDDOWN */ - public function testROUNDDOWN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDDOWN'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testROUNDDOWN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDDOWN'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerROUNDDOWN() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data'); + } /** * @dataProvider providerSERIESSUM */ - public function testSERIESSUM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SERIESSUM'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testSERIESSUM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SERIESSUM'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerSERIESSUM() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data'); + } /** * @dataProvider providerSUMSQ */ - public function testSUMSQ() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SUMSQ'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testSUMSQ() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SUMSQ'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerSUMSQ() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/SUMSQ.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/SUMSQ.data'); + } /** * @dataProvider providerTRUNC */ - public function testTRUNC() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','TRUNC'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testTRUNC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','TRUNC'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerTRUNC() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/TRUNC.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/TRUNC.data'); + } /** * @dataProvider providerROMAN */ - public function testROMAN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROMAN'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testROMAN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROMAN'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerROMAN() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data'); + } /** * @dataProvider providerSQRTPI */ - public function testSQRTPI() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SQRTPI'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); - } + public function testSQRTPI() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SQRTPI'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-12); + } public function providerSQRTPI() { - return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data'); + return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data'); } /** @@ -491,7 +490,7 @@ class MathTrigTest extends PHPUnit_Framework_TestCase $args = func_get_args(); $expectedResult = array_pop($args); $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig', 'SUMIF'), $args); - $this->assertEquals($expectedResult, $result, NULL, 1E-12); + $this->assertEquals($expectedResult, $result, null, 1E-12); } public function providerSUMIF() @@ -555,6 +554,5 @@ class MathTrigTest extends PHPUnit_Framework_TestCase 100 ), ); - } - + } } diff --git a/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php b/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php index 4b1caf51..135d4b09 100644 --- a/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php @@ -8,358 +8,356 @@ class TextDataTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); - } + } /** * @dataProvider providerCHAR */ - public function testCHAR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','CHARACTER'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCHAR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','CHARACTER'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCHAR() { - return new testDataFileIterator('rawTestData/Calculation/TextData/CHAR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/CHAR.data'); + } /** * @dataProvider providerCODE */ - public function testCODE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','ASCIICODE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCODE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','ASCIICODE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCODE() { - return new testDataFileIterator('rawTestData/Calculation/TextData/CODE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/CODE.data'); + } /** * @dataProvider providerCONCATENATE */ - public function testCONCATENATE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','CONCATENATE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCONCATENATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','CONCATENATE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCONCATENATE() { - return new testDataFileIterator('rawTestData/Calculation/TextData/CONCATENATE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/CONCATENATE.data'); + } /** * @dataProvider providerLEFT */ - public function testLEFT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','LEFT'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testLEFT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','LEFT'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerLEFT() { - return new testDataFileIterator('rawTestData/Calculation/TextData/LEFT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/LEFT.data'); + } /** * @dataProvider providerMID */ - public function testMID() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','MID'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testMID() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','MID'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerMID() { - return new testDataFileIterator('rawTestData/Calculation/TextData/MID.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/MID.data'); + } /** * @dataProvider providerRIGHT */ - public function testRIGHT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','RIGHT'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testRIGHT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','RIGHT'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerRIGHT() { - return new testDataFileIterator('rawTestData/Calculation/TextData/RIGHT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/RIGHT.data'); + } /** * @dataProvider providerLOWER */ - public function testLOWER() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','LOWERCASE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testLOWER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','LOWERCASE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerLOWER() { - return new testDataFileIterator('rawTestData/Calculation/TextData/LOWER.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/LOWER.data'); + } /** * @dataProvider providerUPPER */ - public function testUPPER() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','UPPERCASE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testUPPER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','UPPERCASE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerUPPER() { - return new testDataFileIterator('rawTestData/Calculation/TextData/UPPER.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/UPPER.data'); + } /** * @dataProvider providerPROPER */ - public function testPROPER() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','PROPERCASE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testPROPER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','PROPERCASE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerPROPER() { - return new testDataFileIterator('rawTestData/Calculation/TextData/PROPER.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/PROPER.data'); + } /** * @dataProvider providerLEN */ - public function testLEN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','STRINGLENGTH'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testLEN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','STRINGLENGTH'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerLEN() { - return new testDataFileIterator('rawTestData/Calculation/TextData/LEN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/LEN.data'); + } /** * @dataProvider providerSEARCH */ - public function testSEARCH() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHINSENSITIVE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testSEARCH() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHINSENSITIVE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerSEARCH() { - return new testDataFileIterator('rawTestData/Calculation/TextData/SEARCH.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/SEARCH.data'); + } /** * @dataProvider providerFIND */ - public function testFIND() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHSENSITIVE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testFIND() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHSENSITIVE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerFIND() { - return new testDataFileIterator('rawTestData/Calculation/TextData/FIND.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/FIND.data'); + } /** * @dataProvider providerREPLACE */ - public function testREPLACE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','REPLACE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testREPLACE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','REPLACE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerREPLACE() { - return new testDataFileIterator('rawTestData/Calculation/TextData/REPLACE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/REPLACE.data'); + } /** * @dataProvider providerSUBSTITUTE */ - public function testSUBSTITUTE() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SUBSTITUTE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testSUBSTITUTE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SUBSTITUTE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerSUBSTITUTE() { - return new testDataFileIterator('rawTestData/Calculation/TextData/SUBSTITUTE.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/SUBSTITUTE.data'); + } /** * @dataProvider providerTRIM */ - public function testTRIM() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMSPACES'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testTRIM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMSPACES'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerTRIM() { - return new testDataFileIterator('rawTestData/Calculation/TextData/TRIM.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/TRIM.data'); + } /** * @dataProvider providerCLEAN */ - public function testCLEAN() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMNONPRINTABLE'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCLEAN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMNONPRINTABLE'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCLEAN() { - return new testDataFileIterator('rawTestData/Calculation/TextData/CLEAN.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/CLEAN.data'); + } /** * @dataProvider providerDOLLAR */ - public function testDOLLAR() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','DOLLAR'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testDOLLAR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','DOLLAR'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerDOLLAR() { - return new testDataFileIterator('rawTestData/Calculation/TextData/DOLLAR.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/DOLLAR.data'); + } /** * @dataProvider providerFIXED */ - public function testFIXED() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','FIXEDFORMAT'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testFIXED() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','FIXEDFORMAT'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerFIXED() { - return new testDataFileIterator('rawTestData/Calculation/TextData/FIXED.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/FIXED.data'); + } /** * @dataProvider providerT */ - public function testT() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','RETURNSTRING'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','RETURNSTRING'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerT() { - return new testDataFileIterator('rawTestData/Calculation/TextData/T.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/T.data'); + } /** * @dataProvider providerTEXT */ - public function testTEXT() - { - // Enforce decimal and thousands separator values to UK/US, and currency code to USD - call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),'.'); - call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),','); - call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),'$'); + public function testTEXT() + { + // Enforce decimal and thousands separator values to UK/US, and currency code to USD + call_user_func(array('PHPExcel_Shared_String', 'setDecimalSeparator'), '.'); + call_user_func(array('PHPExcel_Shared_String', 'setThousandsSeparator'), ','); + call_user_func(array('PHPExcel_Shared_String', 'setCurrencyCode'), '$'); - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TEXTFORMAT'),$args); - $this->assertEquals($expectedResult, $result); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData', 'TEXTFORMAT'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerTEXT() { - return new testDataFileIterator('rawTestData/Calculation/TextData/TEXT.data'); - } + return new testDataFileIterator('rawTestData/Calculation/TextData/TEXT.data'); + } /** * @dataProvider providerVALUE */ - public function testVALUE() - { - call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),'.'); - call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),' '); - call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),'$'); + public function testVALUE() + { + call_user_func(array('PHPExcel_Shared_String', 'setDecimalSeparator'), '.'); + call_user_func(array('PHPExcel_Shared_String', 'setThousandsSeparator'), ' '); + call_user_func(array('PHPExcel_Shared_String', 'setCurrencyCode'), '$'); - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Calculation_TextData','VALUE'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-8); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData', 'VALUE'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-8); + } public function providerVALUE() { - return new testDataFileIterator('rawTestData/Calculation/TextData/VALUE.data'); - } - + return new testDataFileIterator('rawTestData/Calculation/TextData/VALUE.data'); + } } diff --git a/unitTests/Classes/PHPExcel/CalculationTest.php b/unitTests/Classes/PHPExcel/CalculationTest.php index 1de827ca..bc221ce2 100644 --- a/unitTests/Classes/PHPExcel/CalculationTest.php +++ b/unitTests/Classes/PHPExcel/CalculationTest.php @@ -4,7 +4,6 @@ require_once 'testDataFileIterator.php'; class CalculationTest extends PHPUnit_Framework_TestCase { - public function setUp() { if (!defined('PHPEXCEL_ROOT')) { @@ -33,5 +32,4 @@ class CalculationTest extends PHPUnit_Framework_TestCase { return new testDataFileIterator('rawTestData/CalculationBinaryComparisonOperation.data'); } - } diff --git a/unitTests/Classes/PHPExcel/Cell/AdvancedValueBinderTest.php b/unitTests/Classes/PHPExcel/Cell/AdvancedValueBinderTest.php index 0a6ca54d..0a55ba73 100644 --- a/unitTests/Classes/PHPExcel/Cell/AdvancedValueBinderTest.php +++ b/unitTests/Classes/PHPExcel/Cell/AdvancedValueBinderTest.php @@ -13,20 +13,20 @@ class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase public function provider() { if (!class_exists('PHPExcel_Style_NumberFormat')) { - $this->setUp(); + $this->setUp(); } $currencyUSD = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; $currencyEURO = str_replace('$', '€', PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); return array( - array('10%', 0.1, PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00, ',', '.', '$'), - array('$10.11', 10.11, $currencyUSD, ',', '.', '$'), - array('$1,010.12', 1010.12, $currencyUSD, ',', '.', '$'), - array('$20,20', 20.2, $currencyUSD, '.', ',', '$'), - array('$2.020,20', 2020.2, $currencyUSD, '.', ',', '$'), - array('€2.020,20', 2020.2, $currencyEURO, '.', ',', '€'), - array('€ 2.020,20', 2020.2, $currencyEURO, '.', ',', '€'), - array('€2,020.22', 2020.22, $currencyEURO, ',', '.', '€'), + array('10%', 0.1, PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00, ',', '.', '$'), + array('$10.11', 10.11, $currencyUSD, ',', '.', '$'), + array('$1,010.12', 1010.12, $currencyUSD, ',', '.', '$'), + array('$20,20', 20.2, $currencyUSD, '.', ',', '$'), + array('$2.020,20', 2020.2, $currencyUSD, '.', ',', '$'), + array('€2.020,20', 2020.2, $currencyEURO, '.', ',', '€'), + array('€ 2.020,20', 2020.2, $currencyEURO, '.', ',', '€'), + array('€2,020.22', 2020.22, $currencyEURO, ',', '.', '€'), ); } @@ -36,12 +36,12 @@ class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode) { $sheet = $this->getMock( - 'PHPExcel_Worksheet', - array('getStyle', 'getNumberFormat', 'setFormatCode','getCellCacheController') - ); + 'PHPExcel_Worksheet', + array('getStyle', 'getNumberFormat', 'setFormatCode','getCellCacheController') + ); $cache = $this->getMockBuilder('PHPExcel_CachedObjectStorage_Memory') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $cache->expects($this->any()) ->method('getParent') ->will($this->returnValue($sheet)); @@ -64,10 +64,10 @@ class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase PHPExcel_Shared_String::setDecimalSeparator($decimalSeparator); PHPExcel_Shared_String::setThousandsSeparator($thousandsSeparator); - $cell = new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_STRING, $sheet); + $cell = new PHPExcel_Cell(null, PHPExcel_Cell_DataType::TYPE_STRING, $sheet); $binder = new PHPExcel_Cell_AdvancedValueBinder(); $binder->bindValue($cell, $value); $this->assertEquals($valueBinded, $cell->getValue()); } -} \ No newline at end of file +} diff --git a/unitTests/Classes/PHPExcel/Cell/DataTypeTest.php b/unitTests/Classes/PHPExcel/Cell/DataTypeTest.php index c17c5d0f..1180c9d6 100644 --- a/unitTests/Classes/PHPExcel/Cell/DataTypeTest.php +++ b/unitTests/Classes/PHPExcel/Cell/DataTypeTest.php @@ -6,19 +6,17 @@ class DataTypeTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } - - public function testGetErrorCodes() - { - $result = call_user_func(array('PHPExcel_Cell_DataType','getErrorCodes')); - $this->assertInternalType('array', $result); - $this->assertGreaterThan(0, count($result)); - $this->assertArrayHasKey('#NULL!', $result); - } + } + public function testGetErrorCodes() + { + $result = call_user_func(array('PHPExcel_Cell_DataType','getErrorCodes')); + $this->assertInternalType('array', $result); + $this->assertGreaterThan(0, count($result)); + $this->assertArrayHasKey('#NULL!', $result); + } } diff --git a/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php b/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php index 1c74d96f..37287b1f 100644 --- a/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php +++ b/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php @@ -8,12 +8,11 @@ class DefaultValueBinderTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } protected function createCellStub() { @@ -32,12 +31,12 @@ class DefaultValueBinderTest extends PHPUnit_Framework_TestCase * @dataProvider binderProvider */ public function testBindValue($value) - { - $this->createCellStub(); + { + $this->createCellStub(); $binder = new PHPExcel_Cell_DefaultValueBinder(); - $result = $binder->bindValue($this->cellStub, $value); - $this->assertTrue($result); - } + $result = $binder->bindValue($this->cellStub, $value); + $this->assertTrue($result); + } public function binderProvider() { @@ -60,26 +59,26 @@ class DefaultValueBinderTest extends PHPUnit_Framework_TestCase /** * @dataProvider providerDataTypeForValue */ - public function testDataTypeForValue() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $args); - $this->assertEquals($expectedResult, $result); - } + public function testDataTypeForValue() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerDataTypeForValue() { - return new testDataFileIterator('rawTestData/Cell/DefaultValueBinder.data'); - } + return new testDataFileIterator('rawTestData/Cell/DefaultValueBinder.data'); + } - public function testDataTypeForRichTextObject() - { + public function testDataTypeForRichTextObject() + { $objRichText = new PHPExcel_RichText(); $objRichText->createText('Hello World'); $expectedResult = PHPExcel_Cell_DataType::TYPE_INLINE; - $result = call_user_func(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $objRichText); - $this->assertEquals($expectedResult, $result); - } + $result = call_user_func(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $objRichText); + $this->assertEquals($expectedResult, $result); + } } diff --git a/unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php b/unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php index 54910cfd..42dff6a5 100644 --- a/unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php +++ b/unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php @@ -6,83 +6,81 @@ class HyperlinkTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testGetUrl() - { - $urlValue = 'http://www.phpexcel.net'; + public function testGetUrl() + { + $urlValue = 'http://www.phpexcel.net'; - $testInstance = new PHPExcel_Cell_Hyperlink($urlValue); + $testInstance = new PHPExcel_Cell_Hyperlink($urlValue); - $result = $testInstance->getUrl(); - $this->assertEquals($urlValue,$result); - } + $result = $testInstance->getUrl(); + $this->assertEquals($urlValue, $result); + } - public function testSetUrl() - { - $initialUrlValue = 'http://www.phpexcel.net'; - $newUrlValue = 'http://github.com/PHPOffice/PHPExcel'; + public function testSetUrl() + { + $initialUrlValue = 'http://www.phpexcel.net'; + $newUrlValue = 'http://github.com/PHPOffice/PHPExcel'; - $testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue); - $result = $testInstance->setUrl($newUrlValue); - $this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink); + $testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue); + $result = $testInstance->setUrl($newUrlValue); + $this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink); - $result = $testInstance->getUrl(); - $this->assertEquals($newUrlValue,$result); - } + $result = $testInstance->getUrl(); + $this->assertEquals($newUrlValue, $result); + } - public function testGetTooltip() - { - $tooltipValue = 'PHPExcel Web Site'; + public function testGetTooltip() + { + $tooltipValue = 'PHPExcel Web Site'; - $testInstance = new PHPExcel_Cell_Hyperlink(NULL, $tooltipValue); + $testInstance = new PHPExcel_Cell_Hyperlink(null, $tooltipValue); - $result = $testInstance->getTooltip(); - $this->assertEquals($tooltipValue,$result); - } + $result = $testInstance->getTooltip(); + $this->assertEquals($tooltipValue, $result); + } - public function testSetTooltip() - { - $initialTooltipValue = 'PHPExcel Web Site'; - $newTooltipValue = 'PHPExcel Repository on Github'; + public function testSetTooltip() + { + $initialTooltipValue = 'PHPExcel Web Site'; + $newTooltipValue = 'PHPExcel Repository on Github'; - $testInstance = new PHPExcel_Cell_Hyperlink(NULL, $initialTooltipValue); - $result = $testInstance->setTooltip($newTooltipValue); - $this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink); + $testInstance = new PHPExcel_Cell_Hyperlink(null, $initialTooltipValue); + $result = $testInstance->setTooltip($newTooltipValue); + $this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink); - $result = $testInstance->getTooltip(); - $this->assertEquals($newTooltipValue,$result); - } + $result = $testInstance->getTooltip(); + $this->assertEquals($newTooltipValue, $result); + } - public function testIsInternal() - { - $initialUrlValue = 'http://www.phpexcel.net'; - $newUrlValue = 'sheet://Worksheet1!A1'; + public function testIsInternal() + { + $initialUrlValue = 'http://www.phpexcel.net'; + $newUrlValue = 'sheet://Worksheet1!A1'; - $testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue); - $result = $testInstance->isInternal(); - $this->assertFalse($result); + $testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue); + $result = $testInstance->isInternal(); + $this->assertFalse($result); - $testInstance->setUrl($newUrlValue); - $result = $testInstance->isInternal(); - $this->assertTrue($result); - } + $testInstance->setUrl($newUrlValue); + $result = $testInstance->isInternal(); + $this->assertTrue($result); + } - public function testGetHashCode() - { - $urlValue = 'http://www.phpexcel.net'; - $tooltipValue = 'PHPExcel Web Site'; - $initialExpectedHash = 'd84d713aed1dbbc8a7c5af183d6c7dbb'; + public function testGetHashCode() + { + $urlValue = 'http://www.phpexcel.net'; + $tooltipValue = 'PHPExcel Web Site'; + $initialExpectedHash = 'd84d713aed1dbbc8a7c5af183d6c7dbb'; - $testInstance = new PHPExcel_Cell_Hyperlink($urlValue, $tooltipValue); - - $result = $testInstance->getHashCode(); - $this->assertEquals($initialExpectedHash,$result); - } + $testInstance = new PHPExcel_Cell_Hyperlink($urlValue, $tooltipValue); + $result = $testInstance->getHashCode(); + $this->assertEquals($initialExpectedHash, $result); + } } diff --git a/unitTests/Classes/PHPExcel/CellTest.php b/unitTests/Classes/PHPExcel/CellTest.php index 11df404c..9680294a 100644 --- a/unitTests/Classes/PHPExcel/CellTest.php +++ b/unitTests/Classes/PHPExcel/CellTest.php @@ -12,284 +12,283 @@ class CellTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } /** * @dataProvider providerColumnString */ - public function testColumnIndexFromString() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','columnIndexFromString'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testColumnIndexFromString() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','columnIndexFromString'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerColumnString() { - return new testDataFileIterator('rawTestData/ColumnString.data'); - } + return new testDataFileIterator('rawTestData/ColumnString.data'); + } public function testColumnIndexFromStringTooLong() - { - $cellAddress = 'ABCD'; - try { - $result = call_user_func(array('PHPExcel_Cell','columnIndexFromString'),$cellAddress); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Column string index can not be longer than 3 characters'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellAddress = 'ABCD'; + try { + $result = call_user_func(array('PHPExcel_Cell','columnIndexFromString'), $cellAddress); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Column string index can not be longer than 3 characters'); + return; + } + $this->fail('An expected exception has not been raised.'); + } public function testColumnIndexFromStringTooShort() - { - $cellAddress = ''; - try { - $result = call_user_func(array('PHPExcel_Cell','columnIndexFromString'),$cellAddress); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Column string index can not be empty'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellAddress = ''; + try { + $result = call_user_func(array('PHPExcel_Cell','columnIndexFromString'), $cellAddress); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Column string index can not be empty'); + return; + } + $this->fail('An expected exception has not been raised.'); + } /** * @dataProvider providerColumnIndex */ - public function testStringFromColumnIndex() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','stringFromColumnIndex'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testStringFromColumnIndex() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','stringFromColumnIndex'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerColumnIndex() { - return new testDataFileIterator('rawTestData/ColumnIndex.data'); - } + return new testDataFileIterator('rawTestData/ColumnIndex.data'); + } /** * @dataProvider providerCoordinates */ - public function testCoordinateFromString() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','coordinateFromString'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCoordinateFromString() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','coordinateFromString'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCoordinates() { - return new testDataFileIterator('rawTestData/CellCoordinates.data'); - } + return new testDataFileIterator('rawTestData/CellCoordinates.data'); + } public function testCoordinateFromStringWithRangeAddress() - { - $cellAddress = 'A1:AI2012'; - try { - $result = call_user_func(array('PHPExcel_Cell','coordinateFromString'),$cellAddress); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellAddress = 'A1:AI2012'; + try { + $result = call_user_func(array('PHPExcel_Cell','coordinateFromString'), $cellAddress); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); + return; + } + $this->fail('An expected exception has not been raised.'); + } public function testCoordinateFromStringWithEmptyAddress() - { - $cellAddress = ''; - try { - $result = call_user_func(array('PHPExcel_Cell','coordinateFromString'),$cellAddress); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Cell coordinate can not be zero-length string'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellAddress = ''; + try { + $result = call_user_func(array('PHPExcel_Cell','coordinateFromString'), $cellAddress); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Cell coordinate can not be zero-length string'); + return; + } + $this->fail('An expected exception has not been raised.'); + } public function testCoordinateFromStringWithInvalidAddress() - { - $cellAddress = 'AI'; - try { - $result = call_user_func(array('PHPExcel_Cell','coordinateFromString'),$cellAddress); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Invalid cell coordinate '.$cellAddress); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellAddress = 'AI'; + try { + $result = call_user_func(array('PHPExcel_Cell','coordinateFromString'), $cellAddress); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Invalid cell coordinate '.$cellAddress); + return; + } + $this->fail('An expected exception has not been raised.'); + } /** * @dataProvider providerAbsoluteCoordinates */ - public function testAbsoluteCoordinateFromString() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','absoluteCoordinate'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testAbsoluteCoordinateFromString() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','absoluteCoordinate'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerAbsoluteCoordinates() { - return new testDataFileIterator('rawTestData/CellAbsoluteCoordinate.data'); - } + return new testDataFileIterator('rawTestData/CellAbsoluteCoordinate.data'); + } public function testAbsoluteCoordinateFromStringWithRangeAddress() - { - $cellAddress = 'A1:AI2012'; - try { - $result = call_user_func(array('PHPExcel_Cell','absoluteCoordinate'),$cellAddress); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellAddress = 'A1:AI2012'; + try { + $result = call_user_func(array('PHPExcel_Cell','absoluteCoordinate'), $cellAddress); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); + return; + } + $this->fail('An expected exception has not been raised.'); + } /** * @dataProvider providerAbsoluteReferences */ - public function testAbsoluteReferenceFromString() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','absoluteReference'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testAbsoluteReferenceFromString() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','absoluteReference'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerAbsoluteReferences() { - return new testDataFileIterator('rawTestData/CellAbsoluteReference.data'); - } + return new testDataFileIterator('rawTestData/CellAbsoluteReference.data'); + } public function testAbsoluteReferenceFromStringWithRangeAddress() - { - $cellAddress = 'A1:AI2012'; - try { - $result = call_user_func(array('PHPExcel_Cell','absoluteReference'),$cellAddress); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellAddress = 'A1:AI2012'; + try { + $result = call_user_func(array('PHPExcel_Cell','absoluteReference'), $cellAddress); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); + return; + } + $this->fail('An expected exception has not been raised.'); + } /** * @dataProvider providerSplitRange */ - public function testSplitRange() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','splitRange'),$args); - foreach($result as $key => $split) { - if (!is_array($expectedResult[$key])) { - $this->assertEquals($expectedResult[$key], $split[0]); - } else { - $this->assertEquals($expectedResult[$key], $split); - } - } - } + public function testSplitRange() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','splitRange'), $args); + foreach ($result as $key => $split) { + if (!is_array($expectedResult[$key])) { + $this->assertEquals($expectedResult[$key], $split[0]); + } else { + $this->assertEquals($expectedResult[$key], $split); + } + } + } public function providerSplitRange() { - return new testDataFileIterator('rawTestData/CellSplitRange.data'); - } + return new testDataFileIterator('rawTestData/CellSplitRange.data'); + } /** * @dataProvider providerBuildRange */ - public function testBuildRange() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','buildRange'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testBuildRange() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','buildRange'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerBuildRange() { - return new testDataFileIterator('rawTestData/CellBuildRange.data'); - } + return new testDataFileIterator('rawTestData/CellBuildRange.data'); + } public function testBuildRangeInvalid() - { - $cellRange = ''; - try { - $result = call_user_func(array('PHPExcel_Cell','buildRange'),$cellRange); - } catch (PHPExcel_Exception $e) { - $this->assertEquals($e->getMessage(), 'Range does not contain any information'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $cellRange = ''; + try { + $result = call_user_func(array('PHPExcel_Cell','buildRange'), $cellRange); + } catch (PHPExcel_Exception $e) { + $this->assertEquals($e->getMessage(), 'Range does not contain any information'); + return; + } + $this->fail('An expected exception has not been raised.'); + } /** * @dataProvider providerRangeBoundaries */ - public function testRangeBoundaries() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','rangeBoundaries'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testRangeBoundaries() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','rangeBoundaries'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerRangeBoundaries() { - return new testDataFileIterator('rawTestData/CellRangeBoundaries.data'); - } + return new testDataFileIterator('rawTestData/CellRangeBoundaries.data'); + } /** * @dataProvider providerRangeDimension */ - public function testRangeDimension() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','rangeDimension'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testRangeDimension() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','rangeDimension'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerRangeDimension() { - return new testDataFileIterator('rawTestData/CellRangeDimension.data'); - } + return new testDataFileIterator('rawTestData/CellRangeDimension.data'); + } /** * @dataProvider providerGetRangeBoundaries */ - public function testGetRangeBoundaries() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','getRangeBoundaries'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testGetRangeBoundaries() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','getRangeBoundaries'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerGetRangeBoundaries() { - return new testDataFileIterator('rawTestData/CellGetRangeBoundaries.data'); - } + return new testDataFileIterator('rawTestData/CellGetRangeBoundaries.data'); + } /** * @dataProvider providerExtractAllCellReferencesInRange */ - public function testExtractAllCellReferencesInRange() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Cell','extractAllCellReferencesInRange'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testExtractAllCellReferencesInRange() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell','extractAllCellReferencesInRange'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerExtractAllCellReferencesInRange() { - return new testDataFileIterator('rawTestData/CellExtractAllCellReferencesInRange.data'); - } - + return new testDataFileIterator('rawTestData/CellExtractAllCellReferencesInRange.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Chart/DataSeriesValuesTest.php b/unitTests/Classes/PHPExcel/Chart/DataSeriesValuesTest.php index 38284de9..5bb527cd 100644 --- a/unitTests/Classes/PHPExcel/Chart/DataSeriesValuesTest.php +++ b/unitTests/Classes/PHPExcel/Chart/DataSeriesValuesTest.php @@ -6,50 +6,48 @@ class DataSeriesValuesTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testSetDataType() - { - $dataTypeValues = array( - 'Number', - 'String' - ); + public function testSetDataType() + { + $dataTypeValues = array( + 'Number', + 'String' + ); - $testInstance = new PHPExcel_Chart_DataSeriesValues; + $testInstance = new PHPExcel_Chart_DataSeriesValues; - foreach($dataTypeValues as $dataTypeValue) { - $result = $testInstance->setDataType($dataTypeValue); - $this->assertTrue($result instanceof PHPExcel_Chart_DataSeriesValues); - } - } + foreach ($dataTypeValues as $dataTypeValue) { + $result = $testInstance->setDataType($dataTypeValue); + $this->assertTrue($result instanceof PHPExcel_Chart_DataSeriesValues); + } + } - public function testSetInvalidDataTypeThrowsException() - { - $testInstance = new PHPExcel_Chart_DataSeriesValues; + public function testSetInvalidDataTypeThrowsException() + { + $testInstance = new PHPExcel_Chart_DataSeriesValues; - try { - $result = $testInstance->setDataType('BOOLEAN'); - } catch (Exception $e) { - $this->assertEquals($e->getMessage(), 'Invalid datatype for chart data series values'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + try { + $result = $testInstance->setDataType('BOOLEAN'); + } catch (Exception $e) { + $this->assertEquals($e->getMessage(), 'Invalid datatype for chart data series values'); + return; + } + $this->fail('An expected exception has not been raised.'); + } - public function testGetDataType() - { - $dataTypeValue = 'String'; + public function testGetDataType() + { + $dataTypeValue = 'String'; - $testInstance = new PHPExcel_Chart_DataSeriesValues; - $setValue = $testInstance->setDataType($dataTypeValue); - - $result = $testInstance->getDataType(); - $this->assertEquals($dataTypeValue,$result); - } + $testInstance = new PHPExcel_Chart_DataSeriesValues; + $setValue = $testInstance->setDataType($dataTypeValue); + $result = $testInstance->getDataType(); + $this->assertEquals($dataTypeValue, $result); + } } diff --git a/unitTests/Classes/PHPExcel/Chart/LayoutTest.php b/unitTests/Classes/PHPExcel/Chart/LayoutTest.php index f24e01c3..a06b09b4 100644 --- a/unitTests/Classes/PHPExcel/Chart/LayoutTest.php +++ b/unitTests/Classes/PHPExcel/Chart/LayoutTest.php @@ -6,32 +6,30 @@ class LayoutTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testSetLayoutTarget() - { - $LayoutTargetValue = 'String'; + public function testSetLayoutTarget() + { + $LayoutTargetValue = 'String'; - $testInstance = new PHPExcel_Chart_Layout; + $testInstance = new PHPExcel_Chart_Layout; - $result = $testInstance->setLayoutTarget($LayoutTargetValue); - $this->assertTrue($result instanceof PHPExcel_Chart_Layout); - } + $result = $testInstance->setLayoutTarget($LayoutTargetValue); + $this->assertTrue($result instanceof PHPExcel_Chart_Layout); + } - public function testGetLayoutTarget() - { - $LayoutTargetValue = 'String'; + public function testGetLayoutTarget() + { + $LayoutTargetValue = 'String'; - $testInstance = new PHPExcel_Chart_Layout; - $setValue = $testInstance->setLayoutTarget($LayoutTargetValue); - - $result = $testInstance->getLayoutTarget(); - $this->assertEquals($LayoutTargetValue,$result); - } + $testInstance = new PHPExcel_Chart_Layout; + $setValue = $testInstance->setLayoutTarget($LayoutTargetValue); + $result = $testInstance->getLayoutTarget(); + $this->assertEquals($LayoutTargetValue, $result); + } } diff --git a/unitTests/Classes/PHPExcel/Chart/LegendTest.php b/unitTests/Classes/PHPExcel/Chart/LegendTest.php index 4c4f8df8..b4df4119 100644 --- a/unitTests/Classes/PHPExcel/Chart/LegendTest.php +++ b/unitTests/Classes/PHPExcel/Chart/LegendTest.php @@ -6,129 +6,127 @@ class LegendTest extends PHPUnit_Framework_TestCase public function setUp() { - if (!defined('PHPEXCEL_ROOT')) - { + if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testSetPosition() - { - $positionValues = array( - PHPExcel_Chart_Legend::POSITION_RIGHT, - PHPExcel_Chart_Legend::POSITION_LEFT, - PHPExcel_Chart_Legend::POSITION_TOP, - PHPExcel_Chart_Legend::POSITION_BOTTOM, - PHPExcel_Chart_Legend::POSITION_TOPRIGHT, - ); + public function testSetPosition() + { + $positionValues = array( + PHPExcel_Chart_Legend::POSITION_RIGHT, + PHPExcel_Chart_Legend::POSITION_LEFT, + PHPExcel_Chart_Legend::POSITION_TOP, + PHPExcel_Chart_Legend::POSITION_BOTTOM, + PHPExcel_Chart_Legend::POSITION_TOPRIGHT, + ); - $testInstance = new PHPExcel_Chart_Legend; + $testInstance = new PHPExcel_Chart_Legend; - foreach($positionValues as $positionValue) { - $result = $testInstance->setPosition($positionValue); - $this->assertTrue($result); - } - } + foreach ($positionValues as $positionValue) { + $result = $testInstance->setPosition($positionValue); + $this->assertTrue($result); + } + } - public function testSetInvalidPositionReturnsFalse() - { - $testInstance = new PHPExcel_Chart_Legend; + public function testSetInvalidPositionReturnsFalse() + { + $testInstance = new PHPExcel_Chart_Legend; - $result = $testInstance->setPosition('BottomLeft'); - $this->assertFalse($result); - // Ensure that value is unchanged - $result = $testInstance->getPosition(); - $this->assertEquals(PHPExcel_Chart_Legend::POSITION_RIGHT,$result); - } + $result = $testInstance->setPosition('BottomLeft'); + $this->assertFalse($result); + // Ensure that value is unchanged + $result = $testInstance->getPosition(); + $this->assertEquals(PHPExcel_Chart_Legend::POSITION_RIGHT, $result); + } - public function testGetPosition() - { - $PositionValue = PHPExcel_Chart_Legend::POSITION_BOTTOM; + public function testGetPosition() + { + $PositionValue = PHPExcel_Chart_Legend::POSITION_BOTTOM; - $testInstance = new PHPExcel_Chart_Legend; - $setValue = $testInstance->setPosition($PositionValue); + $testInstance = new PHPExcel_Chart_Legend; + $setValue = $testInstance->setPosition($PositionValue); - $result = $testInstance->getPosition(); - $this->assertEquals($PositionValue,$result); - } + $result = $testInstance->getPosition(); + $this->assertEquals($PositionValue, $result); + } - public function testSetPositionXL() - { - $positionValues = array( - PHPExcel_Chart_Legend::xlLegendPositionBottom, - PHPExcel_Chart_Legend::xlLegendPositionCorner, - PHPExcel_Chart_Legend::xlLegendPositionCustom, - PHPExcel_Chart_Legend::xlLegendPositionLeft, - PHPExcel_Chart_Legend::xlLegendPositionRight, - PHPExcel_Chart_Legend::xlLegendPositionTop, - ); + public function testSetPositionXL() + { + $positionValues = array( + PHPExcel_Chart_Legend::xlLegendPositionBottom, + PHPExcel_Chart_Legend::xlLegendPositionCorner, + PHPExcel_Chart_Legend::xlLegendPositionCustom, + PHPExcel_Chart_Legend::xlLegendPositionLeft, + PHPExcel_Chart_Legend::xlLegendPositionRight, + PHPExcel_Chart_Legend::xlLegendPositionTop, + ); - $testInstance = new PHPExcel_Chart_Legend; + $testInstance = new PHPExcel_Chart_Legend; - foreach($positionValues as $positionValue) { - $result = $testInstance->setPositionXL($positionValue); - $this->assertTrue($result); - } - } + foreach ($positionValues as $positionValue) { + $result = $testInstance->setPositionXL($positionValue); + $this->assertTrue($result); + } + } - public function testSetInvalidXLPositionReturnsFalse() - { - $testInstance = new PHPExcel_Chart_Legend; + public function testSetInvalidXLPositionReturnsFalse() + { + $testInstance = new PHPExcel_Chart_Legend; - $result = $testInstance->setPositionXL(999); - $this->assertFalse($result); - // Ensure that value is unchanged - $result = $testInstance->getPositionXL(); - $this->assertEquals(PHPExcel_Chart_Legend::xlLegendPositionRight,$result); - } + $result = $testInstance->setPositionXL(999); + $this->assertFalse($result); + // Ensure that value is unchanged + $result = $testInstance->getPositionXL(); + $this->assertEquals(PHPExcel_Chart_Legend::xlLegendPositionRight, $result); + } - public function testGetPositionXL() - { - $PositionValue = PHPExcel_Chart_Legend::xlLegendPositionCorner; + public function testGetPositionXL() + { + $PositionValue = PHPExcel_Chart_Legend::xlLegendPositionCorner; - $testInstance = new PHPExcel_Chart_Legend; - $setValue = $testInstance->setPositionXL($PositionValue); + $testInstance = new PHPExcel_Chart_Legend; + $setValue = $testInstance->setPositionXL($PositionValue); - $result = $testInstance->getPositionXL(); - $this->assertEquals($PositionValue,$result); - } + $result = $testInstance->getPositionXL(); + $this->assertEquals($PositionValue, $result); + } - public function testSetOverlay() - { - $overlayValues = array( - TRUE, - FALSE, - ); + public function testSetOverlay() + { + $overlayValues = array( + true, + false, + ); - $testInstance = new PHPExcel_Chart_Legend; + $testInstance = new PHPExcel_Chart_Legend; - foreach($overlayValues as $overlayValue) { - $result = $testInstance->setOverlay($overlayValue); - $this->assertTrue($result); - } - } + foreach ($overlayValues as $overlayValue) { + $result = $testInstance->setOverlay($overlayValue); + $this->assertTrue($result); + } + } - public function testSetInvalidOverlayReturnsFalse() - { - $testInstance = new PHPExcel_Chart_Legend; + public function testSetInvalidOverlayReturnsFalse() + { + $testInstance = new PHPExcel_Chart_Legend; - $result = $testInstance->setOverlay('INVALID'); - $this->assertFalse($result); + $result = $testInstance->setOverlay('INVALID'); + $this->assertFalse($result); - $result = $testInstance->getOverlay(); - $this->assertFalse($result); - } + $result = $testInstance->getOverlay(); + $this->assertFalse($result); + } - public function testGetOverlay() - { - $OverlayValue = TRUE; + public function testGetOverlay() + { + $OverlayValue = true; - $testInstance = new PHPExcel_Chart_Legend; - $setValue = $testInstance->setOverlay($OverlayValue); - - $result = $testInstance->getOverlay(); - $this->assertEquals($OverlayValue,$result); - } + $testInstance = new PHPExcel_Chart_Legend; + $setValue = $testInstance->setOverlay($OverlayValue); + $result = $testInstance->getOverlay(); + $this->assertEquals($OverlayValue, $result); + } } diff --git a/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php b/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php index f635dbb8..e781f71e 100644 --- a/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php +++ b/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php @@ -10,46 +10,45 @@ class XEEValidatorTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } /** * @dataProvider providerInvalidXML * @expectedException PHPExcel_Reader_Exception */ - public function testInvalidXML($filename) - { + public function testInvalidXML($filename) + { $reader = $this->getMockForAbstractClass('PHPExcel_Reader_Abstract'); $expectedResult = 'FAILURE: Should throw an Exception rather than return a value'; - $result = $reader->securityScanFile($filename); - $this->assertEquals($expectedResult, $result); - } + $result = $reader->securityScanFile($filename); + $this->assertEquals($expectedResult, $result); + } public function providerInvalidXML() { $tests = []; - foreach(glob('rawTestData/Reader/XEETestInvalid*.xml') as $file) { + foreach (glob('rawTestData/Reader/XEETestInvalid*.xml') as $file) { $tests[] = [realpath($file), true]; } return $tests; - } + } /** * @dataProvider providerValidXML */ - public function testValidXML($filename, $expectedResult) - { + public function testValidXML($filename, $expectedResult) + { $reader = $this->getMockForAbstractClass('PHPExcel_Reader_Abstract'); - $result = $reader->securityScanFile($filename); - $this->assertEquals($expectedResult, $result); - } + $result = $reader->securityScanFile($filename); + $this->assertEquals($expectedResult, $result); + } public function providerValidXML() { $tests = []; - foreach(glob('rawTestData/Reader/XEETestValid*.xml') as $file) { + foreach (glob('rawTestData/Reader/XEETestValid*.xml') as $file) { $tests[] = [realpath($file), file_get_contents($file)]; } return $tests; - } - + } } diff --git a/unitTests/Classes/PHPExcel/ReferenceHelperTest.php b/unitTests/Classes/PHPExcel/ReferenceHelperTest.php index f37db692..cf40f73a 100644 --- a/unitTests/Classes/PHPExcel/ReferenceHelperTest.php +++ b/unitTests/Classes/PHPExcel/ReferenceHelperTest.php @@ -10,49 +10,48 @@ class ReferenceHelperTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testColumnSort() - { - $columnBase = $columnExpectedResult = array( - 'A','B','Z', - 'AA','AB','AZ', - 'BA','BB','BZ', - 'ZA','ZB','ZZ', - 'AAA','AAB','AAZ', - 'ABA','ABB','ABZ', - 'AZA','AZB','AZZ', - 'BAA','BAB','BAZ', - 'BBA','BBB','BBZ', - 'BZA','BZB','BZZ' - ); - shuffle($columnBase); - usort($columnBase, array('PHPExcel_ReferenceHelper','columnSort')); - foreach($columnBase as $key => $value) { - $this->assertEquals($columnExpectedResult[$key], $value); - } - } - - public function testColumnReverseSort() - { - $columnBase = $columnExpectedResult = array( - 'A','B','Z', - 'AA','AB','AZ', - 'BA','BB','BZ', - 'ZA','ZB','ZZ', - 'AAA','AAB','AAZ', - 'ABA','ABB','ABZ', - 'AZA','AZB','AZZ', - 'BAA','BAB','BAZ', - 'BBA','BBB','BBZ', - 'BZA','BZB','BZZ' - ); - shuffle($columnBase); - $columnExpectedResult = array_reverse($columnExpectedResult); - usort($columnBase, array('PHPExcel_ReferenceHelper','columnReverseSort')); - foreach($columnBase as $key => $value) { - $this->assertEquals($columnExpectedResult[$key], $value); - } - } + public function testColumnSort() + { + $columnBase = $columnExpectedResult = array( + 'A','B','Z', + 'AA','AB','AZ', + 'BA','BB','BZ', + 'ZA','ZB','ZZ', + 'AAA','AAB','AAZ', + 'ABA','ABB','ABZ', + 'AZA','AZB','AZZ', + 'BAA','BAB','BAZ', + 'BBA','BBB','BBZ', + 'BZA','BZB','BZZ' + ); + shuffle($columnBase); + usort($columnBase, array('PHPExcel_ReferenceHelper','columnSort')); + foreach ($columnBase as $key => $value) { + $this->assertEquals($columnExpectedResult[$key], $value); + } + } + public function testColumnReverseSort() + { + $columnBase = $columnExpectedResult = array( + 'A','B','Z', + 'AA','AB','AZ', + 'BA','BB','BZ', + 'ZA','ZB','ZZ', + 'AAA','AAB','AAZ', + 'ABA','ABB','ABZ', + 'AZA','AZB','AZZ', + 'BAA','BAB','BAZ', + 'BBA','BBB','BBZ', + 'BZA','BZB','BZZ' + ); + shuffle($columnBase); + $columnExpectedResult = array_reverse($columnExpectedResult); + usort($columnBase, array('PHPExcel_ReferenceHelper','columnReverseSort')); + foreach ($columnBase as $key => $value) { + $this->assertEquals($columnExpectedResult[$key], $value); + } + } } diff --git a/unitTests/Classes/PHPExcel/Shared/CodePageTest.php b/unitTests/Classes/PHPExcel/Shared/CodePageTest.php index ae4aeecc..d434694e 100644 --- a/unitTests/Classes/PHPExcel/Shared/CodePageTest.php +++ b/unitTests/Classes/PHPExcel/Shared/CodePageTest.php @@ -12,46 +12,45 @@ class CodePageTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } /** * @dataProvider providerCodePage */ - public function testCodePageNumberToName() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_CodePage','NumberToName'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCodePageNumberToName() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_CodePage','NumberToName'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCodePage() { - return new testDataFileIterator('rawTestData/Shared/CodePage.data'); - } + return new testDataFileIterator('rawTestData/Shared/CodePage.data'); + } public function testNumberToNameWithInvalidCodePage() - { - $invalidCodePage = 12345; - try { - $result = call_user_func(array('PHPExcel_Shared_CodePage','NumberToName'),$invalidCodePage); - } catch (Exception $e) { - $this->assertEquals($e->getMessage(), 'Unknown codepage: 12345'); - return; - } - $this->fail('An expected exception has not been raised.'); - } + { + $invalidCodePage = 12345; + try { + $result = call_user_func(array('PHPExcel_Shared_CodePage','NumberToName'), $invalidCodePage); + } catch (Exception $e) { + $this->assertEquals($e->getMessage(), 'Unknown codepage: 12345'); + return; + } + $this->fail('An expected exception has not been raised.'); + } public function testNumberToNameWithUnsupportedCodePage() - { - $unsupportedCodePage = 720; - try { - $result = call_user_func(array('PHPExcel_Shared_CodePage','NumberToName'),$unsupportedCodePage); - } catch (Exception $e) { - $this->assertEquals($e->getMessage(), 'Code page 720 not supported.'); - return; - } - $this->fail('An expected exception has not been raised.'); - } - + { + $unsupportedCodePage = 720; + try { + $result = call_user_func(array('PHPExcel_Shared_CodePage','NumberToName'), $unsupportedCodePage); + } catch (Exception $e) { + $this->assertEquals($e->getMessage(), 'Code page 720 not supported.'); + return; + } + $this->fail('An expected exception has not been raised.'); + } } diff --git a/unitTests/Classes/PHPExcel/Shared/DateTest.php b/unitTests/Classes/PHPExcel/Shared/DateTest.php index 80b77d3c..f0bf9198 100644 --- a/unitTests/Classes/PHPExcel/Shared/DateTest.php +++ b/unitTests/Classes/PHPExcel/Shared/DateTest.php @@ -12,177 +12,176 @@ class DateTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testSetExcelCalendar() - { - $calendarValues = array( - PHPExcel_Shared_Date::CALENDAR_MAC_1904, - PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900, - ); + public function testSetExcelCalendar() + { + $calendarValues = array( + PHPExcel_Shared_Date::CALENDAR_MAC_1904, + PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900, + ); - foreach($calendarValues as $calendarValue) { - $result = call_user_func(array('PHPExcel_Shared_Date','setExcelCalendar'),$calendarValue); - $this->assertTrue($result); - } - } + foreach ($calendarValues as $calendarValue) { + $result = call_user_func(array('PHPExcel_Shared_Date','setExcelCalendar'), $calendarValue); + $this->assertTrue($result); + } + } public function testSetExcelCalendarWithInvalidValue() - { - $unsupportedCalendar = '2012'; - $result = call_user_func(array('PHPExcel_Shared_Date','setExcelCalendar'),$unsupportedCalendar); - $this->assertFalse($result); - } + { + $unsupportedCalendar = '2012'; + $result = call_user_func(array('PHPExcel_Shared_Date','setExcelCalendar'), $unsupportedCalendar); + $this->assertFalse($result); + } /** * @dataProvider providerDateTimeExcelToPHP1900 */ - public function testDateTimeExcelToPHP1900() - { - $result = call_user_func( - array('PHPExcel_Shared_Date','setExcelCalendar'), - PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 - ); + public function testDateTimeExcelToPHP1900() + { + $result = call_user_func( + array('PHPExcel_Shared_Date','setExcelCalendar'), + PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 + ); - $args = func_get_args(); - $expectedResult = array_pop($args); - if ($args[0] < 1) { - $expectedResult += gmmktime(0,0,0); - } - $result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'),$args); - $this->assertEquals($expectedResult, $result); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + if ($args[0] < 1) { + $expectedResult += gmmktime(0, 0, 0); + } + $result = call_user_func_array(array('PHPExcel_Shared_Date', 'ExcelToPHP'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerDateTimeExcelToPHP1900() { - return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1900.data'); - } + return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1900.data'); + } /** * @dataProvider providerDateTimePHPToExcel1900 */ - public function testDateTimePHPToExcel1900() - { - $result = call_user_func( - array('PHPExcel_Shared_Date','setExcelCalendar'), - PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 - ); + public function testDateTimePHPToExcel1900() + { + $result = call_user_func( + array('PHPExcel_Shared_Date','setExcelCalendar'), + PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 + ); - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_Date','PHPToExcel'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-5); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_Date','PHPToExcel'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-5); + } public function providerDateTimePHPToExcel1900() { - return new testDataFileIterator('rawTestData/Shared/DateTimePHPToExcel1900.data'); - } + return new testDataFileIterator('rawTestData/Shared/DateTimePHPToExcel1900.data'); + } /** * @dataProvider providerDateTimeFormattedPHPToExcel1900 */ - public function testDateTimeFormattedPHPToExcel1900() - { - $result = call_user_func( - array('PHPExcel_Shared_Date','setExcelCalendar'), - PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 - ); + public function testDateTimeFormattedPHPToExcel1900() + { + $result = call_user_func( + array('PHPExcel_Shared_Date','setExcelCalendar'), + PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 + ); - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_Date','FormattedPHPToExcel'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-5); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_Date','FormattedPHPToExcel'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-5); + } public function providerDateTimeFormattedPHPToExcel1900() { - return new testDataFileIterator('rawTestData/Shared/DateTimeFormattedPHPToExcel1900.data'); - } + return new testDataFileIterator('rawTestData/Shared/DateTimeFormattedPHPToExcel1900.data'); + } /** * @dataProvider providerDateTimeExcelToPHP1904 */ - public function testDateTimeExcelToPHP1904() - { - $result = call_user_func( - array('PHPExcel_Shared_Date','setExcelCalendar'), - PHPExcel_Shared_Date::CALENDAR_MAC_1904 - ); + public function testDateTimeExcelToPHP1904() + { + $result = call_user_func( + array('PHPExcel_Shared_Date','setExcelCalendar'), + PHPExcel_Shared_Date::CALENDAR_MAC_1904 + ); - $args = func_get_args(); - $expectedResult = array_pop($args); - if ($args[0] < 1) { - $expectedResult += gmmktime(0,0,0); - } - $result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'),$args); - $this->assertEquals($expectedResult, $result); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + if ($args[0] < 1) { + $expectedResult += gmmktime(0, 0, 0); + } + $result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerDateTimeExcelToPHP1904() { - return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1904.data'); - } + return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1904.data'); + } /** * @dataProvider providerDateTimePHPToExcel1904 */ - public function testDateTimePHPToExcel1904() - { - $result = call_user_func( - array('PHPExcel_Shared_Date','setExcelCalendar'), - PHPExcel_Shared_Date::CALENDAR_MAC_1904 - ); + public function testDateTimePHPToExcel1904() + { + $result = call_user_func( + array('PHPExcel_Shared_Date','setExcelCalendar'), + PHPExcel_Shared_Date::CALENDAR_MAC_1904 + ); - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_Date','PHPToExcel'),$args); - $this->assertEquals($expectedResult, $result, NULL, 1E-5); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_Date','PHPToExcel'), $args); + $this->assertEquals($expectedResult, $result, null, 1E-5); + } public function providerDateTimePHPToExcel1904() { - return new testDataFileIterator('rawTestData/Shared/DateTimePHPToExcel1904.data'); - } + return new testDataFileIterator('rawTestData/Shared/DateTimePHPToExcel1904.data'); + } /** * @dataProvider providerIsDateTimeFormatCode */ - public function testIsDateTimeFormatCode() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_Date','isDateTimeFormatCode'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testIsDateTimeFormatCode() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_Date','isDateTimeFormatCode'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerIsDateTimeFormatCode() { - return new testDataFileIterator('rawTestData/Shared/DateTimeFormatCodes.data'); - } + return new testDataFileIterator('rawTestData/Shared/DateTimeFormatCodes.data'); + } /** * @dataProvider providerDateTimeExcelToPHP1900Timezone */ - public function testDateTimeExcelToPHP1900Timezone() - { - $result = call_user_func( - array('PHPExcel_Shared_Date','setExcelCalendar'), - PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 - ); + public function testDateTimeExcelToPHP1900Timezone() + { + $result = call_user_func( + array('PHPExcel_Shared_Date','setExcelCalendar'), + PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 + ); - $args = func_get_args(); - $expectedResult = array_pop($args); - if ($args[0] < 1) { - $expectedResult += gmmktime(0,0,0); - } - $result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'),$args); - $this->assertEquals($expectedResult, $result); - } + $args = func_get_args(); + $expectedResult = array_pop($args); + if ($args[0] < 1) { + $expectedResult += gmmktime(0, 0, 0); + } + $result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerDateTimeExcelToPHP1900Timezone() { - return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1900Timezone.data'); - } - + return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1900Timezone.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Shared/FileTest.php b/unitTests/Classes/PHPExcel/Shared/FileTest.php index 9deb401d..6f6696c5 100644 --- a/unitTests/Classes/PHPExcel/Shared/FileTest.php +++ b/unitTests/Classes/PHPExcel/Shared/FileTest.php @@ -12,28 +12,28 @@ class FileTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testGetUseUploadTempDirectory() - { - $expectedResult = FALSE; + public function testGetUseUploadTempDirectory() + { + $expectedResult = false; - $result = call_user_func(array('PHPExcel_Shared_File','getUseUploadTempDirectory')); - $this->assertEquals($expectedResult, $result); - } + $result = call_user_func(array('PHPExcel_Shared_File','getUseUploadTempDirectory')); + $this->assertEquals($expectedResult, $result); + } - public function testSetUseUploadTempDirectory() - { - $useUploadTempDirectoryValues = array( - TRUE, - FALSE, - ); + public function testSetUseUploadTempDirectory() + { + $useUploadTempDirectoryValues = array( + true, + false, + ); - foreach($useUploadTempDirectoryValues as $useUploadTempDirectoryValue) { - call_user_func(array('PHPExcel_Shared_File','setUseUploadTempDirectory'),$useUploadTempDirectoryValue); + foreach ($useUploadTempDirectoryValues as $useUploadTempDirectoryValue) { + call_user_func(array('PHPExcel_Shared_File','setUseUploadTempDirectory'), $useUploadTempDirectoryValue); - $result = call_user_func(array('PHPExcel_Shared_File','getUseUploadTempDirectory')); - $this->assertEquals($useUploadTempDirectoryValue, $result); - } - } + $result = call_user_func(array('PHPExcel_Shared_File','getUseUploadTempDirectory')); + $this->assertEquals($useUploadTempDirectoryValue, $result); + } + } } diff --git a/unitTests/Classes/PHPExcel/Shared/FontTest.php b/unitTests/Classes/PHPExcel/Shared/FontTest.php index 6ce5a026..eecd69de 100644 --- a/unitTests/Classes/PHPExcel/Shared/FontTest.php +++ b/unitTests/Classes/PHPExcel/Shared/FontTest.php @@ -12,83 +12,82 @@ class FontTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testGetAutoSizeMethod() - { - $expectedResult = PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX; + public function testGetAutoSizeMethod() + { + $expectedResult = PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX; - $result = call_user_func(array('PHPExcel_Shared_Font','getAutoSizeMethod')); - $this->assertEquals($expectedResult, $result); - } + $result = call_user_func(array('PHPExcel_Shared_Font','getAutoSizeMethod')); + $this->assertEquals($expectedResult, $result); + } - public function testSetAutoSizeMethod() - { - $autosizeMethodValues = array( - PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT, - PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX, - ); + public function testSetAutoSizeMethod() + { + $autosizeMethodValues = array( + PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT, + PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX, + ); - foreach($autosizeMethodValues as $autosizeMethodValue) { - $result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'),$autosizeMethodValue); - $this->assertTrue($result); - } - } + foreach ($autosizeMethodValues as $autosizeMethodValue) { + $result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'), $autosizeMethodValue); + $this->assertTrue($result); + } + } public function testSetAutoSizeMethodWithInvalidValue() - { - $unsupportedAutosizeMethod = 'guess'; + { + $unsupportedAutosizeMethod = 'guess'; - $result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'),$unsupportedAutosizeMethod); - $this->assertFalse($result); - } + $result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'), $unsupportedAutosizeMethod); + $this->assertFalse($result); + } /** * @dataProvider providerFontSizeToPixels */ - public function testFontSizeToPixels() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_Font','fontSizeToPixels'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testFontSizeToPixels() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_Font','fontSizeToPixels'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerFontSizeToPixels() { - return new testDataFileIterator('rawTestData/Shared/FontSizeToPixels.data'); - } + return new testDataFileIterator('rawTestData/Shared/FontSizeToPixels.data'); + } /** * @dataProvider providerInchSizeToPixels */ - public function testInchSizeToPixels() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_Font','inchSizeToPixels'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testInchSizeToPixels() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_Font','inchSizeToPixels'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerInchSizeToPixels() { - return new testDataFileIterator('rawTestData/Shared/InchSizeToPixels.data'); - } + return new testDataFileIterator('rawTestData/Shared/InchSizeToPixels.data'); + } /** * @dataProvider providerCentimeterSizeToPixels */ - public function testCentimeterSizeToPixels() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_Font','centimeterSizeToPixels'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testCentimeterSizeToPixels() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_Font','centimeterSizeToPixels'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerCentimeterSizeToPixels() { - return new testDataFileIterator('rawTestData/Shared/CentimeterSizeToPixels.data'); - } - + return new testDataFileIterator('rawTestData/Shared/CentimeterSizeToPixels.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Shared/PasswordHasherTest.php b/unitTests/Classes/PHPExcel/Shared/PasswordHasherTest.php index 24a26178..620acb98 100644 --- a/unitTests/Classes/PHPExcel/Shared/PasswordHasherTest.php +++ b/unitTests/Classes/PHPExcel/Shared/PasswordHasherTest.php @@ -12,22 +12,21 @@ class PasswordHasherTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } /** * @dataProvider providerHashPassword */ - public function testHashPassword() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Shared_PasswordHasher','hashPassword'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testHashPassword() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Shared_PasswordHasher','hashPassword'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerHashPassword() { - return new testDataFileIterator('rawTestData/Shared/PasswordHashes.data'); - } - + return new testDataFileIterator('rawTestData/Shared/PasswordHashes.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Shared/StringTest.php b/unitTests/Classes/PHPExcel/Shared/StringTest.php index 9a34729d..9955d816 100644 --- a/unitTests/Classes/PHPExcel/Shared/StringTest.php +++ b/unitTests/Classes/PHPExcel/Shared/StringTest.php @@ -12,72 +12,71 @@ class StringTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testGetIsMbStringEnabled() - { - $result = call_user_func(array('PHPExcel_Shared_String','getIsMbstringEnabled')); - $this->assertTrue($result); - } + public function testGetIsMbStringEnabled() + { + $result = call_user_func(array('PHPExcel_Shared_String','getIsMbstringEnabled')); + $this->assertTrue($result); + } - public function testGetIsIconvEnabled() - { - $result = call_user_func(array('PHPExcel_Shared_String','getIsIconvEnabled')); - $this->assertTrue($result); - } + public function testGetIsIconvEnabled() + { + $result = call_user_func(array('PHPExcel_Shared_String','getIsIconvEnabled')); + $this->assertTrue($result); + } - public function testGetDecimalSeparator() - { - $localeconv = localeconv(); + public function testGetDecimalSeparator() + { + $localeconv = localeconv(); - $expectedResult = (!empty($localeconv['decimal_point'])) ? $localeconv['decimal_point'] : ','; - $result = call_user_func(array('PHPExcel_Shared_String','getDecimalSeparator')); - $this->assertEquals($expectedResult, $result); - } + $expectedResult = (!empty($localeconv['decimal_point'])) ? $localeconv['decimal_point'] : ','; + $result = call_user_func(array('PHPExcel_Shared_String','getDecimalSeparator')); + $this->assertEquals($expectedResult, $result); + } - public function testSetDecimalSeparator() - { - $expectedResult = ','; - $result = call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),$expectedResult); + public function testSetDecimalSeparator() + { + $expectedResult = ','; + $result = call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'), $expectedResult); - $result = call_user_func(array('PHPExcel_Shared_String','getDecimalSeparator')); - $this->assertEquals($expectedResult, $result); - } + $result = call_user_func(array('PHPExcel_Shared_String','getDecimalSeparator')); + $this->assertEquals($expectedResult, $result); + } - public function testGetThousandsSeparator() - { - $localeconv = localeconv(); + public function testGetThousandsSeparator() + { + $localeconv = localeconv(); - $expectedResult = (!empty($localeconv['thousands_sep'])) ? $localeconv['thousands_sep'] : ','; - $result = call_user_func(array('PHPExcel_Shared_String','getThousandsSeparator')); - $this->assertEquals($expectedResult, $result); - } + $expectedResult = (!empty($localeconv['thousands_sep'])) ? $localeconv['thousands_sep'] : ','; + $result = call_user_func(array('PHPExcel_Shared_String','getThousandsSeparator')); + $this->assertEquals($expectedResult, $result); + } - public function testSetThousandsSeparator() - { - $expectedResult = ' '; - $result = call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),$expectedResult); + public function testSetThousandsSeparator() + { + $expectedResult = ' '; + $result = call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'), $expectedResult); - $result = call_user_func(array('PHPExcel_Shared_String','getThousandsSeparator')); - $this->assertEquals($expectedResult, $result); - } + $result = call_user_func(array('PHPExcel_Shared_String','getThousandsSeparator')); + $this->assertEquals($expectedResult, $result); + } - public function testGetCurrencyCode() - { - $localeconv = localeconv(); + public function testGetCurrencyCode() + { + $localeconv = localeconv(); - $expectedResult = (!empty($localeconv['currency_symbol'])) ? $localeconv['currency_symbol'] : '$'; - $result = call_user_func(array('PHPExcel_Shared_String','getCurrencyCode')); - $this->assertEquals($expectedResult, $result); - } + $expectedResult = (!empty($localeconv['currency_symbol'])) ? $localeconv['currency_symbol'] : '$'; + $result = call_user_func(array('PHPExcel_Shared_String','getCurrencyCode')); + $this->assertEquals($expectedResult, $result); + } - public function testSetCurrencyCode() - { - $expectedResult = '£'; - $result = call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),$expectedResult); - - $result = call_user_func(array('PHPExcel_Shared_String','getCurrencyCode')); - $this->assertEquals($expectedResult, $result); - } + public function testSetCurrencyCode() + { + $expectedResult = '£'; + $result = call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'), $expectedResult); + $result = call_user_func(array('PHPExcel_Shared_String','getCurrencyCode')); + $this->assertEquals($expectedResult, $result); + } } diff --git a/unitTests/Classes/PHPExcel/Shared/TimeZoneTest.php b/unitTests/Classes/PHPExcel/Shared/TimeZoneTest.php index 0e44ceb6..25484267 100644 --- a/unitTests/Classes/PHPExcel/Shared/TimeZoneTest.php +++ b/unitTests/Classes/PHPExcel/Shared/TimeZoneTest.php @@ -10,30 +10,29 @@ class TimeZoneTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } - public function testSetTimezone() - { - $timezoneValues = array( - 'Europe/Prague', - 'Asia/Tokyo', - 'America/Indiana/Indianapolis', - 'Pacific/Honolulu', - 'Atlantic/St_Helena', - ); + public function testSetTimezone() + { + $timezoneValues = array( + 'Europe/Prague', + 'Asia/Tokyo', + 'America/Indiana/Indianapolis', + 'Pacific/Honolulu', + 'Atlantic/St_Helena', + ); - foreach($timezoneValues as $timezoneValue) { - $result = call_user_func(array('PHPExcel_Shared_TimeZone','setTimezone'),$timezoneValue); - $this->assertTrue($result); - } + foreach ($timezoneValues as $timezoneValue) { + $result = call_user_func(array('PHPExcel_Shared_TimeZone','setTimezone'), $timezoneValue); + $this->assertTrue($result); + } - } + } public function testSetTimezoneWithInvalidValue() - { - $unsupportedTimezone = 'Etc/GMT+10'; - $result = call_user_func(array('PHPExcel_Shared_TimeZone','setTimezone'),$unsupportedTimezone); - $this->assertFalse($result); - } - + { + $unsupportedTimezone = 'Etc/GMT+10'; + $result = call_user_func(array('PHPExcel_Shared_TimeZone','setTimezone'), $unsupportedTimezone); + $this->assertFalse($result); + } } diff --git a/unitTests/Classes/PHPExcel/Style/ColorTest.php b/unitTests/Classes/PHPExcel/Style/ColorTest.php index f157b1a3..2d9188ef 100644 --- a/unitTests/Classes/PHPExcel/Style/ColorTest.php +++ b/unitTests/Classes/PHPExcel/Style/ColorTest.php @@ -12,70 +12,69 @@ class ColorTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + } /** * @dataProvider providerColorGetRed */ - public function testGetRed() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Style_Color','getRed'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testGetRed() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Style_Color','getRed'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerColorGetRed() { - return new testDataFileIterator('rawTestData/Style/ColorGetRed.data'); - } + return new testDataFileIterator('rawTestData/Style/ColorGetRed.data'); + } /** * @dataProvider providerColorGetGreen */ - public function testGetGreen() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Style_Color','getGreen'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testGetGreen() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Style_Color','getGreen'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerColorGetGreen() { - return new testDataFileIterator('rawTestData/Style/ColorGetGreen.data'); - } + return new testDataFileIterator('rawTestData/Style/ColorGetGreen.data'); + } /** * @dataProvider providerColorGetBlue */ - public function testGetBlue() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Style_Color','getBlue'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testGetBlue() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Style_Color','getBlue'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerColorGetBlue() { - return new testDataFileIterator('rawTestData/Style/ColorGetBlue.data'); - } + return new testDataFileIterator('rawTestData/Style/ColorGetBlue.data'); + } /** * @dataProvider providerColorChangeBrightness */ - public function testChangeBrightness() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Style_Color','changeBrightness'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testChangeBrightness() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Style_Color','changeBrightness'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerColorChangeBrightness() { - return new testDataFileIterator('rawTestData/Style/ColorChangeBrightness.data'); - } - + return new testDataFileIterator('rawTestData/Style/ColorChangeBrightness.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Style/NumberFormatTest.php b/unitTests/Classes/PHPExcel/Style/NumberFormatTest.php index 13fc3ede..08c2f024 100644 --- a/unitTests/Classes/PHPExcel/Style/NumberFormatTest.php +++ b/unitTests/Classes/PHPExcel/Style/NumberFormatTest.php @@ -13,24 +13,23 @@ class NumberFormatTest extends PHPUnit_Framework_TestCase } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - PHPExcel_Shared_String::setDecimalSeparator('.'); - PHPExcel_Shared_String::setThousandsSeparator(','); - } + PHPExcel_Shared_String::setDecimalSeparator('.'); + PHPExcel_Shared_String::setThousandsSeparator(','); + } /** * @dataProvider providerNumberFormat */ - public function testFormatValueWithMask() - { - $args = func_get_args(); - $expectedResult = array_pop($args); - $result = call_user_func_array(array('PHPExcel_Style_NumberFormat','toFormattedString'),$args); - $this->assertEquals($expectedResult, $result); - } + public function testFormatValueWithMask() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Style_NumberFormat','toFormattedString'), $args); + $this->assertEquals($expectedResult, $result); + } public function providerNumberFormat() { - return new testDataFileIterator('rawTestData/Style/NumberFormat.data'); - } - + return new testDataFileIterator('rawTestData/Style/NumberFormat.data'); + } } diff --git a/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/Column/RuleTest.php b/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/Column/RuleTest.php index 65d0a85c..0c39c683 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/Column/RuleTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/Column/RuleTest.php @@ -3,9 +3,9 @@ class RuleTest extends PHPUnit_Framework_TestCase { - private $_testAutoFilterRuleObject; + private $_testAutoFilterRuleObject; - private $_mockAutoFilterColumnObject; + private $_mockAutoFilterColumnObject; public function setUp() { @@ -15,95 +15,94 @@ class RuleTest extends PHPUnit_Framework_TestCase require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->_mockAutoFilterColumnObject = $this->getMockBuilder('PHPExcel_Worksheet_AutoFilter_Column') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $this->_mockAutoFilterColumnObject->expects($this->any()) - ->method('testColumnInRange') - ->will($this->returnValue(3)); + ->method('testColumnInRange') + ->will($this->returnValue(3)); - $this->_testAutoFilterRuleObject = new PHPExcel_Worksheet_AutoFilter_Column_Rule( - $this->_mockAutoFilterColumnObject - ); + $this->_testAutoFilterRuleObject = new PHPExcel_Worksheet_AutoFilter_Column_Rule( + $this->_mockAutoFilterColumnObject + ); } - public function testGetRuleType() - { - $result = $this->_testAutoFilterRuleObject->getRuleType(); - $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER, $result); - } + public function testGetRuleType() + { + $result = $this->_testAutoFilterRuleObject->getRuleType(); + $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER, $result); + } - public function testSetRuleType() - { - $expectedResult = PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP; + public function testSetRuleType() + { + $expectedResult = PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP; - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterRuleObject->setRuleType($expectedResult); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterRuleObject->setRuleType($expectedResult); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); - $result = $this->_testAutoFilterRuleObject->getRuleType(); - $this->assertEquals($expectedResult, $result); - } + $result = $this->_testAutoFilterRuleObject->getRuleType(); + $this->assertEquals($expectedResult, $result); + } - public function testSetValue() - { - $expectedResult = 100; + public function testSetValue() + { + $expectedResult = 100; - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterRuleObject->setValue($expectedResult); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterRuleObject->setValue($expectedResult); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); - $result = $this->_testAutoFilterRuleObject->getValue(); - $this->assertEquals($expectedResult, $result); - } + $result = $this->_testAutoFilterRuleObject->getValue(); + $this->assertEquals($expectedResult, $result); + } - public function testGetOperator() - { - $result = $this->_testAutoFilterRuleObject->getOperator(); - $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL, $result); - } + public function testGetOperator() + { + $result = $this->_testAutoFilterRuleObject->getOperator(); + $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL, $result); + } - public function testSetOperator() - { - $expectedResult = PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN; + public function testSetOperator() + { + $expectedResult = PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN; - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterRuleObject->setOperator($expectedResult); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterRuleObject->setOperator($expectedResult); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); - $result = $this->_testAutoFilterRuleObject->getOperator(); - $this->assertEquals($expectedResult, $result); - } + $result = $this->_testAutoFilterRuleObject->getOperator(); + $this->assertEquals($expectedResult, $result); + } - public function testSetGrouping() - { - $expectedResult = PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH; + public function testSetGrouping() + { + $expectedResult = PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH; - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterRuleObject->setGrouping($expectedResult); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterRuleObject->setGrouping($expectedResult); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); - $result = $this->_testAutoFilterRuleObject->getGrouping(); - $this->assertEquals($expectedResult, $result); - } + $result = $this->_testAutoFilterRuleObject->getGrouping(); + $this->assertEquals($expectedResult, $result); + } - public function testGetParent() - { - $result = $this->_testAutoFilterRuleObject->getParent(); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - } + public function testGetParent() + { + $result = $this->_testAutoFilterRuleObject->getParent(); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + } - public function testSetParent() - { - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterRuleObject->setParent($this->_mockAutoFilterColumnObject); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); - } - - public function testClone() - { - $result = clone $this->_testAutoFilterRuleObject; - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); - } + public function testSetParent() + { + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterRuleObject->setParent($this->_mockAutoFilterColumnObject); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); + } + public function testClone() + { + $result = clone $this->_testAutoFilterRuleObject; + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column_Rule', $result); + } } diff --git a/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php b/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php index 3c1821ba..da6eef53 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php @@ -3,11 +3,11 @@ class AutofilterColumnTest extends PHPUnit_Framework_TestCase { - private $_testInitialColumn = 'H'; + private $_testInitialColumn = 'H'; - private $_testAutoFilterColumnObject; + private $_testAutoFilterColumnObject; - private $_mockAutoFilterObject; + private $_mockAutoFilterObject; public function setUp() { @@ -17,157 +17,156 @@ class AutofilterColumnTest extends PHPUnit_Framework_TestCase require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->_mockAutoFilterObject = $this->getMockBuilder('PHPExcel_Worksheet_AutoFilter') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $this->_mockAutoFilterObject->expects($this->any()) - ->method('testColumnInRange') - ->will($this->returnValue(3)); + ->method('testColumnInRange') + ->will($this->returnValue(3)); - $this->_testAutoFilterColumnObject = new PHPExcel_Worksheet_AutoFilter_Column( - $this->_testInitialColumn, - $this->_mockAutoFilterObject - ); + $this->_testAutoFilterColumnObject = new PHPExcel_Worksheet_AutoFilter_Column( + $this->_testInitialColumn, + $this->_mockAutoFilterObject + ); } - public function testGetColumnIndex() - { - $result = $this->_testAutoFilterColumnObject->getColumnIndex(); - $this->assertEquals($this->_testInitialColumn, $result); - } + public function testGetColumnIndex() + { + $result = $this->_testAutoFilterColumnObject->getColumnIndex(); + $this->assertEquals($this->_testInitialColumn, $result); + } - public function testSetColumnIndex() - { - $expectedResult = 'L'; + public function testSetColumnIndex() + { + $expectedResult = 'L'; - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterColumnObject->setColumnIndex($expectedResult); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterColumnObject->setColumnIndex($expectedResult); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - $result = $this->_testAutoFilterColumnObject->getColumnIndex(); - $this->assertEquals($expectedResult, $result); - } + $result = $this->_testAutoFilterColumnObject->getColumnIndex(); + $this->assertEquals($expectedResult, $result); + } - public function testGetParent() - { - $result = $this->_testAutoFilterColumnObject->getParent(); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - } + public function testGetParent() + { + $result = $this->_testAutoFilterColumnObject->getParent(); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + } - public function testSetParent() - { - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterColumnObject->setParent($this->_mockAutoFilterObject); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - } + public function testSetParent() + { + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterColumnObject->setParent($this->_mockAutoFilterObject); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + } - public function testGetFilterType() - { - $result = $this->_testAutoFilterColumnObject->getFilterType(); - $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER, $result); - } + public function testGetFilterType() + { + $result = $this->_testAutoFilterColumnObject->getFilterType(); + $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER, $result); + } - public function testSetFilterType() - { - $result = $this->_testAutoFilterColumnObject->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + public function testSetFilterType() + { + $result = $this->_testAutoFilterColumnObject->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - $result = $this->_testAutoFilterColumnObject->getFilterType(); - $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER, $result); - } + $result = $this->_testAutoFilterColumnObject->getFilterType(); + $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER, $result); + } /** * @expectedException PHPExcel_Exception */ - public function testSetInvalidFilterTypeThrowsException() - { - $expectedResult = 'Unfiltered'; + public function testSetInvalidFilterTypeThrowsException() + { + $expectedResult = 'Unfiltered'; - $result = $this->_testAutoFilterColumnObject->setFilterType($expectedResult); - } + $result = $this->_testAutoFilterColumnObject->setFilterType($expectedResult); + } - public function testGetJoin() - { - $result = $this->_testAutoFilterColumnObject->getJoin(); - $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR, $result); - } + public function testGetJoin() + { + $result = $this->_testAutoFilterColumnObject->getJoin(); + $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR, $result); + } - public function testSetJoin() - { - $result = $this->_testAutoFilterColumnObject->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + public function testSetJoin() + { + $result = $this->_testAutoFilterColumnObject->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - $result = $this->_testAutoFilterColumnObject->getJoin(); - $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND, $result); - } + $result = $this->_testAutoFilterColumnObject->getJoin(); + $this->assertEquals(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND, $result); + } /** * @expectedException PHPExcel_Exception */ - public function testSetInvalidJoinThrowsException() - { - $expectedResult = 'Neither'; + public function testSetInvalidJoinThrowsException() + { + $expectedResult = 'Neither'; - $result = $this->_testAutoFilterColumnObject->setJoin($expectedResult); - } + $result = $this->_testAutoFilterColumnObject->setJoin($expectedResult); + } - public function testSetAttributes() - { - $attributeSet = array( 'val' => 100, - 'maxVal' => 200 - ); + public function testSetAttributes() + { + $attributeSet = array( 'val' => 100, + 'maxVal' => 200 + ); - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterColumnObject->setAttributes($attributeSet); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - } + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterColumnObject->setAttributes($attributeSet); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + } - public function testGetAttributes() - { - $attributeSet = array( 'val' => 100, - 'maxVal' => 200 - ); + public function testGetAttributes() + { + $attributeSet = array( 'val' => 100, + 'maxVal' => 200 + ); - $this->_testAutoFilterColumnObject->setAttributes($attributeSet); + $this->_testAutoFilterColumnObject->setAttributes($attributeSet); - $result = $this->_testAutoFilterColumnObject->getAttributes(); - $this->assertTrue(is_array($result)); - $this->assertEquals(count($attributeSet), count($result)); - } + $result = $this->_testAutoFilterColumnObject->getAttributes(); + $this->assertTrue(is_array($result)); + $this->assertEquals(count($attributeSet), count($result)); + } - public function testSetAttribute() - { - $attributeSet = array( 'val' => 100, - 'maxVal' => 200 - ); + public function testSetAttribute() + { + $attributeSet = array( 'val' => 100, + 'maxVal' => 200 + ); - foreach($attributeSet as $attributeName => $attributeValue) { - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterColumnObject->setAttribute($attributeName,$attributeValue); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - } - } + foreach ($attributeSet as $attributeName => $attributeValue) { + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterColumnObject->setAttribute($attributeName, $attributeValue); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + } + } - public function testGetAttribute() - { - $attributeSet = array( 'val' => 100, - 'maxVal' => 200 - ); + public function testGetAttribute() + { + $attributeSet = array( 'val' => 100, + 'maxVal' => 200 + ); - $this->_testAutoFilterColumnObject->setAttributes($attributeSet); + $this->_testAutoFilterColumnObject->setAttributes($attributeSet); - foreach($attributeSet as $attributeName => $attributeValue) { - $result = $this->_testAutoFilterColumnObject->getAttribute($attributeName); - $this->assertEquals($attributeValue, $result); - } - $result = $this->_testAutoFilterColumnObject->getAttribute('nonExistentAttribute'); - $this->assertNull($result); - } - - public function testClone() - { - $result = clone $this->_testAutoFilterColumnObject; - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - } + foreach ($attributeSet as $attributeName => $attributeValue) { + $result = $this->_testAutoFilterColumnObject->getAttribute($attributeName); + $this->assertEquals($attributeValue, $result); + } + $result = $this->_testAutoFilterColumnObject->getAttribute('nonExistentAttribute'); + $this->assertNull($result); + } + public function testClone() + { + $result = clone $this->_testAutoFilterColumnObject; + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + } } diff --git a/unitTests/Classes/PHPExcel/Worksheet/AutoFilterTest.php b/unitTests/Classes/PHPExcel/Worksheet/AutoFilterTest.php index 9907eabc..519810d3 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/AutoFilterTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/AutoFilterTest.php @@ -3,9 +3,9 @@ class AutoFilterTest extends PHPUnit_Framework_TestCase { - private $_testInitialRange = 'H2:O256'; + private $_testInitialRange = 'H2:O256'; - private $_testAutoFilterObject; + private $_testAutoFilterObject; public function setUp() @@ -16,325 +16,324 @@ class AutoFilterTest extends PHPUnit_Framework_TestCase require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->_mockWorksheetObject = $this->getMockBuilder('PHPExcel_Worksheet') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $this->_mockCacheController = $this->getMockBuilder('PHPExcel_CachedObjectStorage_Memory') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $this->_mockWorksheetObject->expects($this->any()) ->method('getCellCacheController') ->will($this->returnValue($this->_mockCacheController)); - $this->_testAutoFilterObject = new PHPExcel_Worksheet_AutoFilter( - $this->_testInitialRange, - $this->_mockWorksheetObject - ); + $this->_testAutoFilterObject = new PHPExcel_Worksheet_AutoFilter( + $this->_testInitialRange, + $this->_mockWorksheetObject + ); } - public function testToString() - { - $expectedResult = $this->_testInitialRange; + public function testToString() + { + $expectedResult = $this->_testInitialRange; - // magic __toString should return the active autofilter range - $result = $this->_testAutoFilterObject; - $this->assertEquals($expectedResult, $result); - } + // magic __toString should return the active autofilter range + $result = $this->_testAutoFilterObject; + $this->assertEquals($expectedResult, $result); + } - public function testGetParent() - { - $result = $this->_testAutoFilterObject->getParent(); - $this->assertInstanceOf('PHPExcel_Worksheet', $result); - } + public function testGetParent() + { + $result = $this->_testAutoFilterObject->getParent(); + $this->assertInstanceOf('PHPExcel_Worksheet', $result); + } - public function testSetParent() - { - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterObject->setParent($this->_mockWorksheetObject); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - } + public function testSetParent() + { + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterObject->setParent($this->_mockWorksheetObject); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + } - public function testGetRange() - { - $expectedResult = $this->_testInitialRange; + public function testGetRange() + { + $expectedResult = $this->_testInitialRange; - // Result should be the active autofilter range - $result = $this->_testAutoFilterObject->getRange(); - $this->assertEquals($expectedResult, $result); - } + // Result should be the active autofilter range + $result = $this->_testAutoFilterObject->getRange(); + $this->assertEquals($expectedResult, $result); + } - public function testSetRange() - { - $ranges = array('G1:J512' => 'Worksheet1!G1:J512', - 'K1:N20' => 'K1:N20' - ); + public function testSetRange() + { + $ranges = array('G1:J512' => 'Worksheet1!G1:J512', + 'K1:N20' => 'K1:N20' + ); - foreach($ranges as $actualRange => $fullRange) { - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterObject->setRange($fullRange); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + foreach ($ranges as $actualRange => $fullRange) { + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterObject->setRange($fullRange); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - // Result should be the new autofilter range - $result = $this->_testAutoFilterObject->getRange(); - $this->assertEquals($actualRange, $result); - } - } + // Result should be the new autofilter range + $result = $this->_testAutoFilterObject->getRange(); + $this->assertEquals($actualRange, $result); + } + } - public function testClearRange() - { - $expectedResult = ''; + public function testClearRange() + { + $expectedResult = ''; - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterObject->setRange(); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterObject->setRange(); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - // Result should be a clear range - $result = $this->_testAutoFilterObject->getRange(); - $this->assertEquals($expectedResult, $result); - } + // Result should be a clear range + $result = $this->_testAutoFilterObject->getRange(); + $this->assertEquals($expectedResult, $result); + } /** * @expectedException PHPExcel_Exception */ - public function testSetRangeInvalidRange() - { - $expectedResult = 'A1'; + public function testSetRangeInvalidRange() + { + $expectedResult = 'A1'; - $result = $this->_testAutoFilterObject->setRange($expectedResult); - } + $result = $this->_testAutoFilterObject->setRange($expectedResult); + } - public function testGetColumnsEmpty() - { - // There should be no columns yet defined - $result = $this->_testAutoFilterObject->getColumns(); - $this->assertInternalType('array', $result); - $this->assertEquals(0, count($result)); - } + public function testGetColumnsEmpty() + { + // There should be no columns yet defined + $result = $this->_testAutoFilterObject->getColumns(); + $this->assertInternalType('array', $result); + $this->assertEquals(0, count($result)); + } - public function testGetColumnOffset() - { - $columnIndexes = array( 'H' => 0, - 'K' => 3, - 'M' => 5 - ); + public function testGetColumnOffset() + { + $columnIndexes = array( 'H' => 0, + 'K' => 3, + 'M' => 5 + ); - // If we request a specific column by its column ID, we should get an - // integer returned representing the column offset within the range - foreach($columnIndexes as $columnIndex => $columnOffset) { - $result = $this->_testAutoFilterObject->getColumnOffset($columnIndex); - $this->assertEquals($columnOffset, $result); - } - } + // If we request a specific column by its column ID, we should get an + // integer returned representing the column offset within the range + foreach ($columnIndexes as $columnIndex => $columnOffset) { + $result = $this->_testAutoFilterObject->getColumnOffset($columnIndex); + $this->assertEquals($columnOffset, $result); + } + } /** * @expectedException PHPExcel_Exception */ public function testGetInvalidColumnOffset() - { - $invalidColumn = 'G'; + { + $invalidColumn = 'G'; - $result = $this->_testAutoFilterObject->getColumnOffset($invalidColumn); - } + $result = $this->_testAutoFilterObject->getColumnOffset($invalidColumn); + } - public function testSetColumnWithString() - { - $expectedResult = 'L'; + public function testSetColumnWithString() + { + $expectedResult = 'L'; - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterObject->setColumn($expectedResult); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterObject->setColumn($expectedResult); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - $result = $this->_testAutoFilterObject->getColumns(); - // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column - // objects for each column we set indexed by the column ID - $this->assertInternalType('array', $result); - $this->assertEquals(1, count($result)); - $this->assertArrayHasKey($expectedResult,$result); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$expectedResult]); - } + $result = $this->_testAutoFilterObject->getColumns(); + // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column + // objects for each column we set indexed by the column ID + $this->assertInternalType('array', $result); + $this->assertEquals(1, count($result)); + $this->assertArrayHasKey($expectedResult, $result); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$expectedResult]); + } /** * @expectedException PHPExcel_Exception */ public function testSetInvalidColumnWithString() - { - $invalidColumn = 'A'; + { + $invalidColumn = 'A'; - $result = $this->_testAutoFilterObject->setColumn($invalidColumn); - } + $result = $this->_testAutoFilterObject->setColumn($invalidColumn); + } - public function testSetColumnWithColumnObject() - { - $expectedResult = 'M'; - $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($expectedResult); + public function testSetColumnWithColumnObject() + { + $expectedResult = 'M'; + $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($expectedResult); - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterObject->setColumn($columnObject); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterObject->setColumn($columnObject); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - $result = $this->_testAutoFilterObject->getColumns(); - // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column - // objects for each column we set indexed by the column ID - $this->assertInternalType('array', $result); - $this->assertEquals(1, count($result)); - $this->assertArrayHasKey($expectedResult,$result); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$expectedResult]); - } + $result = $this->_testAutoFilterObject->getColumns(); + // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column + // objects for each column we set indexed by the column ID + $this->assertInternalType('array', $result); + $this->assertEquals(1, count($result)); + $this->assertArrayHasKey($expectedResult, $result); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$expectedResult]); + } /** * @expectedException PHPExcel_Exception */ public function testSetInvalidColumnWithObject() - { - $invalidColumn = 'E'; - $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($invalidColumn); + { + $invalidColumn = 'E'; + $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($invalidColumn); - $result = $this->_testAutoFilterObject->setColumn($invalidColumn); - } + $result = $this->_testAutoFilterObject->setColumn($invalidColumn); + } /** * @expectedException PHPExcel_Exception */ public function testSetColumnWithInvalidDataType() - { - $invalidColumn = 123.456; - $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($invalidColumn); + { + $invalidColumn = 123.456; + $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($invalidColumn); - $result = $this->_testAutoFilterObject->setColumn($invalidColumn); - } + $result = $this->_testAutoFilterObject->setColumn($invalidColumn); + } - public function testGetColumns() - { - $columnIndexes = array('L','M'); + public function testGetColumns() + { + $columnIndexes = array('L','M'); - foreach($columnIndexes as $columnIndex) { - $this->_testAutoFilterObject->setColumn($columnIndex); - } + foreach ($columnIndexes as $columnIndex) { + $this->_testAutoFilterObject->setColumn($columnIndex); + } - $result = $this->_testAutoFilterObject->getColumns(); - // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column - // objects for each column we set indexed by the column ID - $this->assertInternalType('array', $result); - $this->assertEquals(count($columnIndexes), count($result)); - foreach($columnIndexes as $columnIndex) { - $this->assertArrayHasKey($columnIndex,$result); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$columnIndex]); - } - } + $result = $this->_testAutoFilterObject->getColumns(); + // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column + // objects for each column we set indexed by the column ID + $this->assertInternalType('array', $result); + $this->assertEquals(count($columnIndexes), count($result)); + foreach ($columnIndexes as $columnIndex) { + $this->assertArrayHasKey($columnIndex, $result); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$columnIndex]); + } + } - public function testGetColumn() - { - $columnIndexes = array('L','M'); + public function testGetColumn() + { + $columnIndexes = array('L','M'); - foreach($columnIndexes as $columnIndex) { - $this->_testAutoFilterObject->setColumn($columnIndex); - } + foreach ($columnIndexes as $columnIndex) { + $this->_testAutoFilterObject->setColumn($columnIndex); + } - // If we request a specific column by its column ID, we should - // get a PHPExcel_Worksheet_AutoFilter_Column object returned - foreach($columnIndexes as $columnIndex) { - $result = $this->_testAutoFilterObject->getColumn($columnIndex); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - } - } + // If we request a specific column by its column ID, we should + // get a PHPExcel_Worksheet_AutoFilter_Column object returned + foreach ($columnIndexes as $columnIndex) { + $result = $this->_testAutoFilterObject->getColumn($columnIndex); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + } + } - public function testGetColumnByOffset() - { - $columnIndexes = array( 0 => 'H', - 3 => 'K', - 5 => 'M' - ); + public function testGetColumnByOffset() + { + $columnIndexes = array( 0 => 'H', + 3 => 'K', + 5 => 'M' + ); - // If we request a specific column by its offset, we should - // get a PHPExcel_Worksheet_AutoFilter_Column object returned - foreach($columnIndexes as $columnIndex => $columnID) { - $result = $this->_testAutoFilterObject->getColumnByOffset($columnIndex); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - $this->assertEquals($result->getColumnIndex(),$columnID); - } - } + // If we request a specific column by its offset, we should + // get a PHPExcel_Worksheet_AutoFilter_Column object returned + foreach ($columnIndexes as $columnIndex => $columnID) { + $result = $this->_testAutoFilterObject->getColumnByOffset($columnIndex); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + $this->assertEquals($result->getColumnIndex(), $columnID); + } + } - public function testGetColumnIfNotSet() - { - // If we request a specific column by its column ID, we should - // get a PHPExcel_Worksheet_AutoFilter_Column object returned - $result = $this->_testAutoFilterObject->getColumn('K'); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); - } + public function testGetColumnIfNotSet() + { + // If we request a specific column by its column ID, we should + // get a PHPExcel_Worksheet_AutoFilter_Column object returned + $result = $this->_testAutoFilterObject->getColumn('K'); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result); + } /** * @expectedException PHPExcel_Exception */ - public function testGetColumnWithoutRangeSet() - { - // Clear the range - $result = $this->_testAutoFilterObject->setRange(); + public function testGetColumnWithoutRangeSet() + { + // Clear the range + $result = $this->_testAutoFilterObject->setRange(); - $result = $this->_testAutoFilterObject->getColumn('A'); - } + $result = $this->_testAutoFilterObject->getColumn('A'); + } - public function testClearRangeWithExistingColumns() - { - $expectedResult = ''; + public function testClearRangeWithExistingColumns() + { + $expectedResult = ''; - $columnIndexes = array('L','M','N'); - foreach($columnIndexes as $columnIndex) { - $this->_testAutoFilterObject->setColumn($columnIndex); - } + $columnIndexes = array('L','M','N'); + foreach ($columnIndexes as $columnIndex) { + $this->_testAutoFilterObject->setColumn($columnIndex); + } - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterObject->setRange(); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterObject->setRange(); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - // Range should be cleared - $result = $this->_testAutoFilterObject->getRange(); - $this->assertEquals($expectedResult, $result); + // Range should be cleared + $result = $this->_testAutoFilterObject->getRange(); + $this->assertEquals($expectedResult, $result); - // Column array should be cleared - $result = $this->_testAutoFilterObject->getColumns(); - $this->assertInternalType('array', $result); - $this->assertEquals(0, count($result)); - } + // Column array should be cleared + $result = $this->_testAutoFilterObject->getColumns(); + $this->assertInternalType('array', $result); + $this->assertEquals(0, count($result)); + } - public function testSetRangeWithExistingColumns() - { - $expectedResult = 'G1:J512'; + public function testSetRangeWithExistingColumns() + { + $expectedResult = 'G1:J512'; - // These columns should be retained - $columnIndexes1 = array('I','J'); - foreach($columnIndexes1 as $columnIndex) { - $this->_testAutoFilterObject->setColumn($columnIndex); - } - // These columns should be discarded - $columnIndexes2 = array('K','L','M'); - foreach($columnIndexes2 as $columnIndex) { - $this->_testAutoFilterObject->setColumn($columnIndex); - } + // These columns should be retained + $columnIndexes1 = array('I','J'); + foreach ($columnIndexes1 as $columnIndex) { + $this->_testAutoFilterObject->setColumn($columnIndex); + } + // These columns should be discarded + $columnIndexes2 = array('K','L','M'); + foreach ($columnIndexes2 as $columnIndex) { + $this->_testAutoFilterObject->setColumn($columnIndex); + } - // Setters return the instance to implement the fluent interface - $result = $this->_testAutoFilterObject->setRange($expectedResult); - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + // Setters return the instance to implement the fluent interface + $result = $this->_testAutoFilterObject->setRange($expectedResult); + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - // Range should be correctly set - $result = $this->_testAutoFilterObject->getRange(); - $this->assertEquals($expectedResult, $result); + // Range should be correctly set + $result = $this->_testAutoFilterObject->getRange(); + $this->assertEquals($expectedResult, $result); - // Only columns that existed in the original range and that - // still fall within the new range should be retained - $result = $this->_testAutoFilterObject->getColumns(); - $this->assertInternalType('array', $result); - $this->assertEquals(count($columnIndexes1), count($result)); - } + // Only columns that existed in the original range and that + // still fall within the new range should be retained + $result = $this->_testAutoFilterObject->getColumns(); + $this->assertInternalType('array', $result); + $this->assertEquals(count($columnIndexes1), count($result)); + } - public function testClone() - { - $columnIndexes = array('L','M'); + public function testClone() + { + $columnIndexes = array('L','M'); - foreach($columnIndexes as $columnIndex) { - $this->_testAutoFilterObject->setColumn($columnIndex); - } - - $result = clone $this->_testAutoFilterObject; - $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); - } + foreach ($columnIndexes as $columnIndex) { + $this->_testAutoFilterObject->setColumn($columnIndex); + } + $result = clone $this->_testAutoFilterObject; + $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result); + } } diff --git a/unitTests/Classes/PHPExcel/Worksheet/CellCollectionTest.php b/unitTests/Classes/PHPExcel/Worksheet/CellCollectionTest.php index c2c130d7..95dd2cec 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/CellCollectionTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/CellCollectionTest.php @@ -3,29 +3,27 @@ class CellCollectionTest extends PHPUnit_Framework_TestCase { - public function setUp() - { - if (!defined('PHPEXCEL_ROOT')) - { - define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); - } - require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); - } + public function setUp() + { + if (!defined('PHPEXCEL_ROOT')) { + define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); + } + require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + } - public function testCacheLastCell() - { - $methods = PHPExcel_CachedObjectStorageFactory::getCacheStorageMethods(); - foreach ($methods as $method) { - PHPExcel_CachedObjectStorageFactory::initialize($method); - $workbook = new PHPExcel(); - $cells = array('A1', 'A2'); - $worksheet = $workbook->getActiveSheet(); - $worksheet->setCellValue('A1', 1); - $worksheet->setCellValue('A2', 2); - $this->assertEquals($cells, $worksheet->getCellCollection(), "Cache method \"$method\"."); - PHPExcel_CachedObjectStorageFactory::finalize(); - } - } - + public function testCacheLastCell() + { + $methods = PHPExcel_CachedObjectStorageFactory::getCacheStorageMethods(); + foreach ($methods as $method) { + PHPExcel_CachedObjectStorageFactory::initialize($method); + $workbook = new PHPExcel(); + $cells = array('A1', 'A2'); + $worksheet = $workbook->getActiveSheet(); + $worksheet->setCellValue('A1', 1); + $worksheet->setCellValue('A2', 2); + $this->assertEquals($cells, $worksheet->getCellCollection(), "Cache method \"$method\"."); + PHPExcel_CachedObjectStorageFactory::finalize(); + } + } } diff --git a/unitTests/Classes/PHPExcel/Worksheet/ColumnCellIteratorTest.php b/unitTests/Classes/PHPExcel/Worksheet/ColumnCellIteratorTest.php index bef500ca..869d086e 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/ColumnCellIteratorTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/ColumnCellIteratorTest.php @@ -5,12 +5,12 @@ class ColumnCellIteratorTest extends PHPUnit_Framework_TestCase public $mockWorksheet; public $mockColumnCell; - public function setUp() - { - if (!defined('PHPEXCEL_ROOT')) { - define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); - } - require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + public function setUp() + { + if (!defined('PHPEXCEL_ROOT')) { + define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); + } + require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->mockCell = $this->getMockBuilder('PHPExcel_Cell') ->disableOriginalConstructor() @@ -29,42 +29,42 @@ class ColumnCellIteratorTest extends PHPUnit_Framework_TestCase } - public function testIteratorFullRange() - { + public function testIteratorFullRange() + { $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A'); $ColumnCellIndexResult = 1; $this->assertEquals($ColumnCellIndexResult, $iterator->key()); - foreach($iterator as $key => $ColumnCell) { + foreach ($iterator as $key => $ColumnCell) { $this->assertEquals($ColumnCellIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Cell', $ColumnCell); } - } + } - public function testIteratorStartEndRange() - { + public function testIteratorStartEndRange() + { $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $ColumnCellIndexResult = 2; $this->assertEquals($ColumnCellIndexResult, $iterator->key()); - foreach($iterator as $key => $ColumnCell) { + foreach ($iterator as $key => $ColumnCell) { $this->assertEquals($ColumnCellIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Cell', $ColumnCell); } - } + } - public function testIteratorSeekAndPrev() - { + public function testIteratorSeekAndPrev() + { $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $columnIndexResult = 4; $iterator->seek(4); $this->assertEquals($columnIndexResult, $iterator->key()); - for($i = 1; $i < $columnIndexResult-1; $i++) { + for ($i = 1; $i < $columnIndexResult-1; $i++) { $iterator->prev(); $this->assertEquals($columnIndexResult - $i, $iterator->key()); } - } + } /** * @expectedException PHPExcel_Exception @@ -83,5 +83,4 @@ class ColumnCellIteratorTest extends PHPUnit_Framework_TestCase $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $iterator->prev(); } - } diff --git a/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php b/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php index 7d78b617..e013210e 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php @@ -5,12 +5,12 @@ class ColumnIteratorTest extends PHPUnit_Framework_TestCase public $mockWorksheet; public $mockColumn; - public function setUp() - { - if (!defined('PHPEXCEL_ROOT')) { - define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); - } - require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + public function setUp() + { + if (!defined('PHPEXCEL_ROOT')) { + define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); + } + require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->mockColumn = $this->getMockBuilder('PHPExcel_Worksheet_Column') ->disableOriginalConstructor() @@ -29,44 +29,44 @@ class ColumnIteratorTest extends PHPUnit_Framework_TestCase } - public function testIteratorFullRange() - { + public function testIteratorFullRange() + { $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet); $columnIndexResult = 'A'; $this->assertEquals($columnIndexResult, $iterator->key()); - foreach($iterator as $key => $column) { + foreach ($iterator as $key => $column) { $this->assertEquals($columnIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); } - } + } - public function testIteratorStartEndRange() - { + public function testIteratorStartEndRange() + { $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D'); $columnIndexResult = 'B'; $this->assertEquals($columnIndexResult, $iterator->key()); - foreach($iterator as $key => $column) { + foreach ($iterator as $key => $column) { $this->assertEquals($columnIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); } - } + } - public function testIteratorSeekAndPrev() - { - $ranges = range('A','E'); + public function testIteratorSeekAndPrev() + { + $ranges = range('A', 'E'); $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D'); $columnIndexResult = 'D'; $iterator->seek('D'); $this->assertEquals($columnIndexResult, $iterator->key()); - for($i = 1; $i < array_search($columnIndexResult, $ranges); $i++) { + for ($i = 1; $i < array_search($columnIndexResult, $ranges); $i++) { $iterator->prev(); $expectedResult = $ranges[array_search($columnIndexResult, $ranges) - $i]; $this->assertEquals($expectedResult, $iterator->key()); } - } + } /** * @expectedException PHPExcel_Exception @@ -85,5 +85,4 @@ class ColumnIteratorTest extends PHPUnit_Framework_TestCase $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D'); $iterator->prev(); } - } diff --git a/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php b/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php index cdd3c84d..ec60e90b 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php @@ -5,12 +5,12 @@ class RowCellIteratorTest extends PHPUnit_Framework_TestCase public $mockWorksheet; public $mockRowCell; - public function setUp() - { - if (!defined('PHPEXCEL_ROOT')) { - define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); - } - require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + public function setUp() + { + if (!defined('PHPEXCEL_ROOT')) { + define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); + } + require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->mockCell = $this->getMockBuilder('PHPExcel_Cell') ->disableOriginalConstructor() @@ -29,44 +29,44 @@ class RowCellIteratorTest extends PHPUnit_Framework_TestCase } - public function testIteratorFullRange() - { + public function testIteratorFullRange() + { $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet); $RowCellIndexResult = 'A'; $this->assertEquals($RowCellIndexResult, $iterator->key()); - foreach($iterator as $key => $RowCell) { + foreach ($iterator as $key => $RowCell) { $this->assertEquals($RowCellIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Cell', $RowCell); } - } + } - public function testIteratorStartEndRange() - { + public function testIteratorStartEndRange() + { $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $RowCellIndexResult = 'B'; $this->assertEquals($RowCellIndexResult, $iterator->key()); - foreach($iterator as $key => $RowCell) { + foreach ($iterator as $key => $RowCell) { $this->assertEquals($RowCellIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Cell', $RowCell); } - } + } - public function testIteratorSeekAndPrev() - { - $ranges = range('A','E'); + public function testIteratorSeekAndPrev() + { + $ranges = range('A', 'E'); $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $RowCellIndexResult = 'D'; $iterator->seek('D'); $this->assertEquals($RowCellIndexResult, $iterator->key()); - for($i = 1; $i < array_search($RowCellIndexResult, $ranges); $i++) { + for ($i = 1; $i < array_search($RowCellIndexResult, $ranges); $i++) { $iterator->prev(); $expectedResult = $ranges[array_search($RowCellIndexResult, $ranges) - $i]; $this->assertEquals($expectedResult, $iterator->key()); } - } + } /** * @expectedException PHPExcel_Exception @@ -85,5 +85,4 @@ class RowCellIteratorTest extends PHPUnit_Framework_TestCase $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $iterator->prev(); } - } diff --git a/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php b/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php index 48d8b6bb..ec0b2796 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php @@ -5,12 +5,12 @@ class RowIteratorTest extends PHPUnit_Framework_TestCase public $mockWorksheet; public $mockRow; - public function setUp() - { - if (!defined('PHPEXCEL_ROOT')) { - define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); - } - require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + public function setUp() + { + if (!defined('PHPEXCEL_ROOT')) { + define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); + } + require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->mockRow = $this->getMockBuilder('PHPExcel_Worksheet_Row') ->disableOriginalConstructor() @@ -29,42 +29,42 @@ class RowIteratorTest extends PHPUnit_Framework_TestCase } - public function testIteratorFullRange() - { + public function testIteratorFullRange() + { $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet); $rowIndexResult = 1; $this->assertEquals($rowIndexResult, $iterator->key()); - foreach($iterator as $key => $row) { + foreach ($iterator as $key => $row) { $this->assertEquals($rowIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); } - } + } - public function testIteratorStartEndRange() - { + public function testIteratorStartEndRange() + { $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); $rowIndexResult = 2; $this->assertEquals($rowIndexResult, $iterator->key()); - foreach($iterator as $key => $row) { + foreach ($iterator as $key => $row) { $this->assertEquals($rowIndexResult++, $key); $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); } - } + } - public function testIteratorSeekAndPrev() - { + public function testIteratorSeekAndPrev() + { $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); $columnIndexResult = 4; $iterator->seek(4); $this->assertEquals($columnIndexResult, $iterator->key()); - for($i = 1; $i < $columnIndexResult-1; $i++) { + for ($i = 1; $i < $columnIndexResult-1; $i++) { $iterator->prev(); $this->assertEquals($columnIndexResult - $i, $iterator->key()); } - } + } /** * @expectedException PHPExcel_Exception @@ -83,5 +83,4 @@ class RowIteratorTest extends PHPUnit_Framework_TestCase $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); $iterator->prev(); } - } diff --git a/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php b/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php index c70c38d3..9e880fb9 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php @@ -5,12 +5,12 @@ class WorksheetColumnTest extends PHPUnit_Framework_TestCase public $mockWorksheet; public $mockColumn; - public function setUp() - { - if (!defined('PHPEXCEL_ROOT')) { - define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); - } - require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + public function setUp() + { + if (!defined('PHPEXCEL_ROOT')) { + define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); + } + require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') ->disableOriginalConstructor() @@ -21,26 +21,26 @@ class WorksheetColumnTest extends PHPUnit_Framework_TestCase } - public function testInstantiateColumnDefault() - { + public function testInstantiateColumnDefault() + { $column = new PHPExcel_Worksheet_Column($this->mockWorksheet); $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); $columnIndex = $column->getColumnIndex(); $this->assertEquals('A', $columnIndex); - } + } - public function testInstantiateColumnSpecified() - { + public function testInstantiateColumnSpecified() + { $column = new PHPExcel_Worksheet_Column($this->mockWorksheet, 'E'); $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); $columnIndex = $column->getColumnIndex(); $this->assertEquals('E', $columnIndex); - } + } - public function testGetCellIterator() - { + public function testGetCellIterator() + { $column = new PHPExcel_Worksheet_Column($this->mockWorksheet); $cellIterator = $column->getCellIterator(); $this->assertInstanceOf('PHPExcel_Worksheet_ColumnCellIterator', $cellIterator); - } + } } diff --git a/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php b/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php index 2761b52b..059d8b20 100644 --- a/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php +++ b/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php @@ -5,12 +5,12 @@ class WorksheetRowTest extends PHPUnit_Framework_TestCase public $mockWorksheet; public $mockRow; - public function setUp() - { - if (!defined('PHPEXCEL_ROOT')) { - define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); - } - require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + public function setUp() + { + if (!defined('PHPEXCEL_ROOT')) { + define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); + } + require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); $this->mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') ->disableOriginalConstructor() @@ -21,26 +21,26 @@ class WorksheetRowTest extends PHPUnit_Framework_TestCase } - public function testInstantiateRowDefault() - { + public function testInstantiateRowDefault() + { $row = new PHPExcel_Worksheet_Row($this->mockWorksheet); $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); $rowIndex = $row->getRowIndex(); $this->assertEquals(1, $rowIndex); - } + } - public function testInstantiateRowSpecified() - { + public function testInstantiateRowSpecified() + { $row = new PHPExcel_Worksheet_Row($this->mockWorksheet, 5); $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); $rowIndex = $row->getRowIndex(); $this->assertEquals(5, $rowIndex); - } + } - public function testGetCellIterator() - { + public function testGetCellIterator() + { $row = new PHPExcel_Worksheet_Row($this->mockWorksheet); $cellIterator = $row->getCellIterator(); $this->assertInstanceOf('PHPExcel_Worksheet_RowCellIterator', $cellIterator); - } + } } diff --git a/unitTests/bootstrap.php b/unitTests/bootstrap.php index 8e8cdb39..d212d58a 100644 --- a/unitTests/bootstrap.php +++ b/unitTests/bootstrap.php @@ -17,21 +17,21 @@ date_default_timezone_set('Europe/London'); // Define path to application directory defined('APPLICATION_PATH') - || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes')); + || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes')); // Define path to application tests directory defined('APPLICATION_TESTS_PATH') - || define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__) )); + || define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__))); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'ci'); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array( - realpath(APPLICATION_PATH . '/../Classes'), - './', - dirname(__FILE__), - get_include_path(), + realpath(APPLICATION_PATH . '/../Classes'), + './', + dirname(__FILE__), + get_include_path(), ))); @@ -41,9 +41,9 @@ set_include_path(implode(PATH_SEPARATOR, array( */ echo "PHPExcel tests beginning\n"; -if(extension_loaded('xdebug')) { - echo "Xdebug extension loaded and running\n"; - xdebug_enable(); +if (extension_loaded('xdebug')) { + echo "Xdebug extension loaded and running\n"; + xdebug_enable(); } else { - echo 'Xdebug not found, you should run the following at the command line: echo "zend_extension=/usr/lib64/php/modules/xdebug.so" > /etc/php.d/xdebug.ini' . "\n"; + echo 'Xdebug not found, you should run the following at the command line: echo "zend_extension=/usr/lib64/php/modules/xdebug.so" > /etc/php.d/xdebug.ini' . "\n"; } diff --git a/unitTests/custom/Complex.php b/unitTests/custom/Complex.php index c827baeb..0b22ddfd 100644 --- a/unitTests/custom/Complex.php +++ b/unitTests/custom/Complex.php @@ -1,114 +1,117 @@ -<?php - -class Complex { - - private $realPart = 0; - private $imaginaryPart = 0; - private $suffix = NULL; - - public static function _parseComplex($complexNumber) - { - // Test for real number, with no imaginary part - if (is_numeric($complexNumber)) - return array( $complexNumber, 0, NULL ); - - // Fix silly human errors - if (strpos($complexNumber,'+-') !== FALSE) - $complexNumber = str_replace('+-','-',$complexNumber); - if (strpos($complexNumber,'++') !== FALSE) - $complexNumber = str_replace('++','+',$complexNumber); - if (strpos($complexNumber,'--') !== FALSE) - $complexNumber = str_replace('--','-',$complexNumber); - - // Basic validation of string, to parse out real and imaginary parts, and any suffix - $validComplex = preg_match('/^([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)?(([\-\+]?)([ij]?))$/ui',$complexNumber,$complexParts); - - if (!$validComplex) { - // Neither real nor imaginary part, so test to see if we actually have a suffix - $validComplex = preg_match('/^([\-\+]?)([ij])$/ui',$complexNumber,$complexParts); - if (!$validComplex) { - throw new Exception('COMPLEX: Invalid complex number'); - } - // We have a suffix, so set the real to 0, the imaginary to either 1 or -1 (as defined by the sign) - $imaginary = 1; - if ($complexParts[1] === '-') { - $imaginary = 0 - $imaginary; - } - return array(0, $imaginary, $complexParts[2]); - } - - // If we don't have an imaginary part, identify whether it should be +1 or -1... - if (($complexParts[4] === '') && ($complexParts[9] !== '')) { - if ($complexParts[7] !== $complexParts[9]) { - $complexParts[4] = 1; - if ($complexParts[8] === '-') { - $complexParts[4] = -1; - } - // ... or if we have only the real and no imaginary part (in which case our real should be the imaginary) - } else { - $complexParts[4] = $complexParts[1]; - $complexParts[1] = 0; - } - } - - // Return real and imaginary parts and suffix as an array, and set a default suffix if user input lazily - return array( $complexParts[1], - $complexParts[4], - !empty($complexParts[9]) ? $complexParts[9] : 'i' - ); - } // function _parseComplex() - - - public function __construct($realPart, $imaginaryPart = null, $suffix = 'i') - { - if ($imaginaryPart === null) { - if (is_array($realPart)) { - // We have an array of (potentially) real and imaginary parts, and any suffix - list ($realPart, $imaginaryPart, $suffix) = array_values($realPart) + array(0.0, 0.0, 'i'); - } elseif((is_string($realPart)) || (is_numeric($realPart))) { - // We've been given a string to parse to extract the real and imaginary parts, and any suffix - list ($realPart, $imaginaryPart, $suffix) = self::_parseComplex($realPart); - } - } - - // Set parsed values in our properties - $this->realPart = (float) $realPart; - $this->imaginaryPart = (float) $imaginaryPart; - $this->suffix = strtolower($suffix); - } - - public function getReal() - { - return $this->realPart; - } - - public function getImaginary() - { - return $this->imaginaryPart; - } - - public function getSuffix() - { - return $this->suffix; - } - - public function __toString() { - $str = ""; - if ($this->imaginaryPart != 0.0) { - if (abs($this->imaginaryPart) != 1.0) { - $str .= $this->imaginaryPart . $this->suffix; - } else { - $str .= (($this->imaginaryPart < 0.0) ? '-' : ''). $this->suffix; - } - } - if ($this->realPart != 0.0) { - if (($str) && ($this->imaginaryPart > 0.0)) - $str = "+" . $str; - $str = $this->realPart . $str; - } - if (!$str) - $str = "0.0"; - return $str; - } - -} +<?php + +class Complex +{ + private $realPart = 0; + private $imaginaryPart = 0; + private $suffix = null; + + public static function _parseComplex($complexNumber) + { + // Test for real number, with no imaginary part + if (is_numeric($complexNumber)) { + return array($complexNumber, 0, null); + } + + // Fix silly human errors + if (strpos($complexNumber, '+-') !== false) { + $complexNumber = str_replace('+-', '-', $complexNumber); + } + if (strpos($complexNumber, '++') !== false) { + $complexNumber = str_replace('++', '+', $complexNumber); + } + if (strpos($complexNumber, '--') !== false) { + $complexNumber = str_replace('--', '-', $complexNumber); + } + + // Basic validation of string, to parse out real and imaginary parts, and any suffix + $validComplex = preg_match('/^([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)?(([\-\+]?)([ij]?))$/ui', $complexNumber, $complexParts); + + if (!$validComplex) { + // Neither real nor imaginary part, so test to see if we actually have a suffix + $validComplex = preg_match('/^([\-\+]?)([ij])$/ui', $complexNumber, $complexParts); + if (!$validComplex) { + throw new Exception('COMPLEX: Invalid complex number'); + } + // We have a suffix, so set the real to 0, the imaginary to either 1 or -1 (as defined by the sign) + $imaginary = 1; + if ($complexParts[1] === '-') { + $imaginary = 0 - $imaginary; + } + return array(0, $imaginary, $complexParts[2]); + } + + // If we don't have an imaginary part, identify whether it should be +1 or -1... + if (($complexParts[4] === '') && ($complexParts[9] !== '')) { + if ($complexParts[7] !== $complexParts[9]) { + $complexParts[4] = 1; + if ($complexParts[8] === '-') { + $complexParts[4] = -1; + } + // ... or if we have only the real and no imaginary part (in which case our real should be the imaginary) + } else { + $complexParts[4] = $complexParts[1]; + $complexParts[1] = 0; + } + } + + // Return real and imaginary parts and suffix as an array, and set a default suffix if user input lazily + return array($complexParts[1], $complexParts[4], !empty($complexParts[9]) ? $complexParts[9] : 'i'); + } // function _parseComplex() + + + public function __construct($realPart, $imaginaryPart = null, $suffix = 'i') + { + if ($imaginaryPart === null) { + if (is_array($realPart)) { + // We have an array of (potentially) real and imaginary parts, and any suffix + list ($realPart, $imaginaryPart, $suffix) = array_values($realPart) + array(0.0, 0.0, 'i'); + } elseif ((is_string($realPart)) || (is_numeric($realPart))) { + // We've been given a string to parse to extract the real and imaginary parts, and any suffix + list ($realPart, $imaginaryPart, $suffix) = self::_parseComplex($realPart); + } + } + + // Set parsed values in our properties + $this->realPart = (float) $realPart; + $this->imaginaryPart = (float) $imaginaryPart; + $this->suffix = strtolower($suffix); + } + + public function getReal() + { + return $this->realPart; + } + + public function getImaginary() + { + return $this->imaginaryPart; + } + + public function getSuffix() + { + return $this->suffix; + } + + public function __toString() + { + $str = ""; + if ($this->imaginaryPart != 0.0) { + if (abs($this->imaginaryPart) != 1.0) { + $str .= $this->imaginaryPart . $this->suffix; + } else { + $str .= (($this->imaginaryPart < 0.0) ? '-' : ''). $this->suffix; + } + } + if ($this->realPart != 0.0) { + if (($str) && ($this->imaginaryPart > 0.0)) { + $str = "+" . $str; + } + $str = $this->realPart . $str; + } + if (!$str) { + $str = "0.0"; + } + return $str; + } +} diff --git a/unitTests/custom/complexAssert.php b/unitTests/custom/complexAssert.php index 5b813d25..f95ca28c 100644 --- a/unitTests/custom/complexAssert.php +++ b/unitTests/custom/complexAssert.php @@ -1,62 +1,55 @@ -<?php - -include_once dirname(__FILE__).'/Complex.php'; - - -class complexAssert { - - private $_errorMessage = ''; - - public function assertComplexEquals($expected, $actual, $delta = 0) - { - if ($expected{0} === '#') { - // Expecting an error, so we do a straight string comparison - if ($expected === $actual) { - return TRUE; - } - $this->_errorMessage = 'Expected Error: ' . - $actual . ' !== ' . $expected; - return FALSE; - } - - $expectedComplex = new Complex($expected); - $actualComplex = new Complex($actual); - - if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) { - if ($actualComplex->getReal() !== $expectedComplex->getReal()) { - $this->_errorMessage = 'Mismatched String: ' . - $actualComplex->getReal() . ' !== ' . $expectedComplex->getReal(); - return FALSE; - } - return TRUE; - } - - if ($actualComplex->getReal() < ($expectedComplex->getReal() - $delta) || - $actualComplex->getReal() > ($expectedComplex->getReal() + $delta)) { - $this->_errorMessage = 'Mismatched Real part: ' . - $actualComplex->getReal() . ' != ' . $expectedComplex->getReal(); - return FALSE; - } - - if ($actualComplex->getImaginary() < ($expectedComplex->getImaginary() - $delta) || - $actualComplex->getImaginary() > ($expectedComplex->getImaginary() + $delta)) { - $this->_errorMessage = 'Mismatched Imaginary part: ' . - $actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary(); - return FALSE; - } - - if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) { - $this->_errorMessage = 'Mismatched Suffix: ' . - $actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix(); - return FALSE; - } - - return TRUE; - } - - - public function getErrorMessage() { - return $this->_errorMessage; - } - -} +<?php + +include_once dirname(__FILE__).'/Complex.php'; + +class complexAssert +{ + private $_errorMessage = ''; + + public function assertComplexEquals($expected, $actual, $delta = 0) + { + if ($expected{0} === '#') { + // Expecting an error, so we do a straight string comparison + if ($expected === $actual) { + return true; + } + $this->_errorMessage = 'Expected Error: ' . $actual . ' !== ' . $expected; + return false; + } + + $expectedComplex = new Complex($expected); + $actualComplex = new Complex($actual); + + if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) { + if ($actualComplex->getReal() !== $expectedComplex->getReal()) { + $this->_errorMessage = 'Mismatched String: ' . $actualComplex->getReal() . ' !== ' . $expectedComplex->getReal(); + return false; + } + return true; + } + + if ($actualComplex->getReal() < ($expectedComplex->getReal() - $delta) || + $actualComplex->getReal() > ($expectedComplex->getReal() + $delta)) { + $this->_errorMessage = 'Mismatched Real part: ' . $actualComplex->getReal() . ' != ' . $expectedComplex->getReal(); + return false; + } + + if ($actualComplex->getImaginary() < ($expectedComplex->getImaginary() - $delta) || + $actualComplex->getImaginary() > ($expectedComplex->getImaginary() + $delta)) { + $this->_errorMessage = 'Mismatched Imaginary part: ' . $actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary(); + return false; + } + + if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) { + $this->_errorMessage = 'Mismatched Suffix: ' . $actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix(); + return false; + } + + return true; + } + + public function getErrorMessage() + { + return $this->_errorMessage; + } +} diff --git a/unitTests/testDataFileIterator.php b/unitTests/testDataFileIterator.php index 9eabe09d..33f64bdb 100644 --- a/unitTests/testDataFileIterator.php +++ b/unitTests/testDataFileIterator.php @@ -1,131 +1,136 @@ -<?php - -class testDataFileIterator implements Iterator -{ - - protected $file; - protected $key = 0; - protected $current; - - public function __construct($file) - { - $this->file = fopen($file, 'r'); - } - - public function __destruct() - { - fclose($this->file); - } - - public function rewind() - { - rewind($this->file); - $this->current = $this->_parseNextDataset(); - $this->key = 0; - } - - public function valid() - { - return !feof($this->file); - } - - public function key() - { - return $this->key; - } - - public function current() - { - return $this->current; - } - - public function next() - { - $this->current = $this->_parseNextDataset(); - $this->key++; - } - - private function _parseNextDataset() - { - // Read a line of test data from the file - do { - // Only take lines that contain test data and that aren't commented out - $testDataRow = trim(fgets($this->file)); - } while (($testDataRow > '') && ($testDataRow{0} === '#')); - - // Discard any comments at the end of the line - list($testData) = explode('//',$testDataRow); - - // Split data into an array of individual values and a result - $dataSet = $this->_getcsv($testData, ',', "'"); - foreach($dataSet as &$dataValue) { - $dataValue = $this->_parseDataValue($dataValue); - } - unset($dataValue); - - return $dataSet; - } - - private function _getcsv($input, $delimiter, $enclosure) - { - if (function_exists('str_getcsv')) { - return str_getcsv($input, $delimiter, $enclosure); - } - - $temp = fopen('php://memory', 'rw'); - fwrite($temp, $input); - rewind($temp); - $data = fgetcsv($temp, strlen($input), $delimiter, $enclosure); - fclose($temp); - - if ($data === false) { - $data = array(null); - } - - return $data; - } - - private function _parseDataValue($dataValue) { - // discard any white space - $dataValue = trim($dataValue); - // test for the required datatype and convert accordingly - if (!is_numeric($dataValue)) { - if($dataValue == '') { - $dataValue = NULL; - } elseif($dataValue == '""') { - $dataValue = ''; - } elseif(($dataValue[0] == '"') && ($dataValue[strlen($dataValue)-1] == '"')) { - $dataValue = substr($dataValue,1,-1); - } elseif(($dataValue[0] == '{') && ($dataValue[strlen($dataValue)-1] == '}')) { - $dataValue = explode(';',substr($dataValue,1,-1)); - foreach($dataValue as &$dataRow) { - if (strpos($dataRow,'|') !== FALSE) { - $dataRow = explode('|',$dataRow); - foreach($dataRow as &$dataCell) { - $dataCell = $this->_parseDataValue($dataCell); - } - unset($dataCell); - } else { - $dataRow = $this->_parseDataValue($dataRow); - } - } - unset($dataRow); - } else { - switch (strtoupper($dataValue)) { - case 'NULL' : $dataValue = NULL; break; - case 'TRUE' : $dataValue = TRUE; break; - case 'FALSE' : $dataValue = FALSE; break; - } - } - } else { - if (strpos($dataValue,'.') !== FALSE) { - $dataValue = (float) $dataValue; - } else { - $dataValue = (int) $dataValue; - } - } - - return $dataValue; - } - -} +<?php + +class testDataFileIterator implements Iterator +{ + protected $file; + protected $key = 0; + protected $current; + + public function __construct($file) + { + $this->file = fopen($file, 'r'); + } + + public function __destruct() + { + fclose($this->file); + } + + public function rewind() + { + rewind($this->file); + $this->current = $this->_parseNextDataset(); + $this->key = 0; + } + + public function valid() + { + return !feof($this->file); + } + + public function key() + { + return $this->key; + } + + public function current() + { + return $this->current; + } + + public function next() + { + $this->current = $this->_parseNextDataset(); + $this->key++; + } + + private function _parseNextDataset() + { + // Read a line of test data from the file + do { + // Only take lines that contain test data and that aren't commented out + $testDataRow = trim(fgets($this->file)); + } while (($testDataRow > '') && ($testDataRow{0} === '#')); + + // Discard any comments at the end of the line + list($testData) = explode('//', $testDataRow); + + // Split data into an array of individual values and a result + $dataSet = $this->_getcsv($testData, ',', "'"); + foreach ($dataSet as &$dataValue) { + $dataValue = $this->_parseDataValue($dataValue); + } + unset($dataValue); + + return $dataSet; + } + + private function _getcsv($input, $delimiter, $enclosure) + { + if (function_exists('str_getcsv')) { + return str_getcsv($input, $delimiter, $enclosure); + } + + $temp = fopen('php://memory', 'rw'); + fwrite($temp, $input); + rewind($temp); + $data = fgetcsv($temp, strlen($input), $delimiter, $enclosure); + fclose($temp); + + if ($data === false) { + $data = array(null); + } + + return $data; + } + + private function _parseDataValue($dataValue) + { + // discard any white space + $dataValue = trim($dataValue); + // test for the required datatype and convert accordingly + if (!is_numeric($dataValue)) { + if ($dataValue == '') { + $dataValue = null; + } elseif ($dataValue == '""') { + $dataValue = ''; + } elseif (($dataValue[0] == '"') && ($dataValue[strlen($dataValue)-1] == '"')) { + $dataValue = substr($dataValue, 1, -1); + } elseif (($dataValue[0] == '{') && ($dataValue[strlen($dataValue)-1] == '}')) { + $dataValue = explode(';', substr($dataValue, 1, -1)); + foreach ($dataValue as &$dataRow) { + if (strpos($dataRow, '|') !== false) { + $dataRow = explode('|', $dataRow); + foreach ($dataRow as &$dataCell) { + $dataCell = $this->_parseDataValue($dataCell); + } + unset($dataCell); + } else { + $dataRow = $this->_parseDataValue($dataRow); + } + } + unset($dataRow); + } else { + switch (strtoupper($dataValue)) { + case 'NULL': + $dataValue = null; + break; + case 'TRUE': + $dataValue = true; + break; + case 'FALSE': + $dataValue = false; + break; + } + } + } else { + if (strpos($dataValue, '.') !== false) { + $dataValue = (float) $dataValue; + } else { + $dataValue = (int) $dataValue; + } + } + + return $dataValue; + } +}