I am comparing the values of two columns cell by cell and then in the 3rd column writing the value if there was a change then change else no Change.
I am able to do that perfectly.
But my problem arises when i try to fetch the formulated value. It gives me 0
as output for all the values.
My Code to fetch is as follows:
<?php
/** Error reporting */
error_reporting(E_ALL);
include 'PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel1 = new PHPExcel();
require_once 'PHPExcel/IOFactory.php';
$directory = 'C:\Users\user\Desktop\Google-Competitors\\';
$target_file_path = $directory . "domain-page-size.xlsx";
$change_size_url = $directory . "url-list-with-change-in-page-size.xlsx";
$objPHPExcel = PHPExcel_IOFactory::load($target_file_path); //Load file
$objWorksheet = $objPHPExcel->getActiveSheet(); //get active sheet
$highestRow = $objWorksheet->getHighestRow(); //get total rows
$highestColumn = $objWorksheet->getHighestColumn(); //get total columns
$objPHPExcel1 = PHPExcel_IOFactory::load($change_size_url);
$objWorksheet1 = $objPHPExcel1->getActiveSheet();
$highestColumn = $objWorksheet1->getHighestColumn();
$timestamp = date('M Y');
$objPHPExcel1->setActiveSheetIndex(0)->setTitle($timestamp);
$i= 1;
for ($row = 2; $row <= 547; ++$row)
{
$cell = "E".$row;
// $val = $objWorksheet->getCell($cell)->getCalculatedValue();
$val = $objWorksheet->getCell($cell)->getOldCalculatedValue();
echo $val;
if($val=="Change")
{
$url_cell = "B".$row;
$url_val = $objWorksheet->getCell($url_cell);
$strvar = (string) $url_val;
$objPHPExcel1->setActiveSheetIndex()->setCellValue('A'.$i, $strvar);
$i++;
}
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel1, 'Excel2007');
$objWriter->save($change_size_url);
?>
and in echo i get output which is meant as No Change i guess
0
0
0
0
0
0
0
0
0
0
I referred enter link description here and enter link description here
Can please any one tell me where am i going wrong in the code
Thanks
EDIT
After using formula Debugging tool i got output as follows
11:34:13 Create new PHPExcel object
11:34:13 Add some data
11:34:14 Rename worksheet
Formula Value is=IF(ABS(C6-D6)>10,"Change", "No Change")
Expected Value is 0
Parser Stack :-
Array
(
[0] => Array
(
[type] => Cell Reference
[value] => C6
[reference] => C6
)
[1] => Array
(
[type] => Cell Reference
[value] => D6
[reference] => D6
)
[2] => Array
(
[type] => Binary Operator
[value] => -
[reference] =>
)
[3] => Array
(
[type] => Operand Count for Function ABS()
[value] => 1
[reference] =>
)
[4] => Array
(
[type] => Function
[value] => ABS(
[reference] =>
)
[5] => Array
(
[type] => Value
[value] => 10
[reference] =>
)
[6] => Array
(
[type] => Binary Operator
[value] => >
[reference] =>
)
[7] => Array
(
[type] => Value
[value] => "Change"
[reference] =>
)
[8] => Array
(
[type] => Value
[value] => "No Change"
[reference] =>
)
[9] => Array
(
[type] => Operand Count for Function IF()
[value] => 3
[reference] =>
)
[10] => Array
(
[type] => Function
[value] => IF(
[reference] =>
)
)
Calculated Value is No Change
Evaluation Log:
Array
(
[0] => Testing cache value for cell Simple!E6
[1] => Simple!E6 => Evaluating Cell C6 in current worksheet
[2] => Simple!E6 => Evaluation Result for cell Simple!C6 is a floating point number with a value of 34738
[3] => Simple!E6 => Evaluating Cell D6 in current worksheet
[4] => Simple!E6 => Evaluation Result for cell Simple!D6 is a floating point number with a value of 34742
[5] => Simple!E6 => Evaluating 34738 - 34742
[6] => Simple!E6 => Evaluation Result is a floating point number with a value of -4
[7] => Simple!E6 => Evaluating Function ABS() with 1 argument
[8] => Simple!E6 => Evaluating ABS( -4 )
[9] => Simple!E6 => Evaluation Result for ABS() function call is a floating point number with a value of 4
[10] => Simple!E6 => Evaluating 4 > 10
[11] => Simple!E6 => Evaluation Result is a boolean with a value of FALSE
[12] => Simple!E6 => Evaluating Function IF() with 3 arguments
[13] => Simple!E6 => Evaluating IF( FALSE, "Change", "No Change" )
[14] => Simple!E6 => Evaluation Result for IF() function call is a string with a value of "No Change"
)