OOCalc and number-columns-repeated

Topics: Developer Forum, User Forum
Aug 26, 2011 at 6:07 PM

The OOCalc Reader does not seem to set the data value, just the column ID for parsing, on repeated cells if the cell XML uses attribute 'number-columns-repeated' (which LibreOffice seems to use extensively unlike OpenOffice.org).

So I edited the following in OOCalc.php, and it seems to resolve it -- basically just copy-pasting the cell setter code after $columnID is changed...

 

if (isset($cellDataTableAttributes['number-columns-repeated'])) {
//	echo 'Repeated '.$cellDataTableAttributes['number-columns-repeated'].' times<br />';
	$columnID = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-repeated'] - 2);
	
	if (!is_null($type)) { // new, like above
		$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
		if ($hasCalculatedValue) {
//		echo 'Formula result is '.$dataValue.'<br />';
			$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue);
		}
		if (($cellDataOfficeAttributes['value-type'] == 'date') ||
			($cellDataOfficeAttributes['value-type'] == 'time')) {
			$objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting);
		}
		if (!is_null($hyperlink)) {
			$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink);
		}
	}
}

I hope that some of these OOCalc fixes (doubles, rich text, this one) if OK could appear in the next PHPExcel. :)