Created
February 14, 2013 17:58
-
-
Save n5i/4954731 to your computer and use it in GitHub Desktop.
PHPExcel - break links to other sheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace calculated values with static data. From A to H from 1 to 70 | |
function breakExcelLinksInSheet( $sheet ){ | |
$labels = array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' ); | |
foreach( $labels as $label ){ | |
for( $i = 1; $i < 70; $i++ ){ | |
$val = $sheet->getCell( $label.$i ); | |
//for incorrect formulas take old value | |
if( ( substr( $val, 0, 1 ) === '=' ) && ( strlen( $val ) > 1)){ | |
$value = $sheet->getCell( $label.$i )->getOldCalculatedValue(); | |
$sheet->setCellValue( $label.$i, $value ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment