You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* This method returns number of cols in active sheet.
*
* @return int - col number of the last col.
*
* @category Sheet manipulations
*/
public function getColCount() {
return count($this->_cSheet->cols->col);
}
CHANGE date format in function formatDataRead() and ADD Currency
private function formatDataRead($style, $data){
// get style tag
if ((string)$style=="")
return (string)$data;
$numFmt = (string)$this->styles->cellXfs->xf[(int)$style]["numFmtId"];
switch ($numFmt){
case "14": // = 'mm-dd-yy';
case "15": // = 'd-mmm-yy';
case "16": // = 'd-mmm';
case "17": // = 'mmm-yy';
case "22": // = 'm/d/yy h:mm';
case "18": // = 'h:mm AM/PM';
case "19": // = 'h:mm:ss AM/PM';
case "20": // = 'h:mm';
case "21": // = 'h:mm:ss';
return $this->getDateTimeString($data);
default:
if ((int)$numFmt>=164){ //look for custom format number
foreach($this->styles->numFmts[0]->numFmt as $o_numFmt){
if ((int)$o_numFmt["numFmtId"]==(int)$numFmt){
$formatCode = (string)$o_numFmt["formatCode"];
// look for date format
if (preg_match("/(([d]{1,2}|[y]{2,4})[-|.|\/|:][m]{1,2}[-|.|\/|:]([y]{2,4}|[d]{1,2}))/i", $formatCode)) { // CHECK THIS OUT!!! it's just a guess!
return $this->getDateTimeString($data);
}
elseif (preg_match("/(€|$)/i", $formatCode)) { //currency $ OR €
return $data;
}
}
}
}
return $data;
break;
}
}
Bugfixes
if (!is_resource($zip))
/** @ignore */
public function unzipToDirectory($zipFilePath, $targetDirName){
if (file_exists($targetDirName)){
self::rmrf($targetDirName);
}
if(!@mkdir($targetDirName, 0777, true)){
throw new eiseXLSX_Exception('Unable to create directory to unpack files');
}
if(!file_exists($zipFilePath))
throw new eiseXLSX_Exception("File not found: {$zipFilePath}");
$zip=zip_open($zipFilePath);
if (!is_resource($zip)) {
throw new eiseXLSX_Exception("Wrong file format: {$zipFilePath}");
}
while($zip_entry=zip_read($zip)) {
$strFileName=$targetDirName. self::DS .str_replace("/", self::DS, zip_entry_name($zip_entry));
$dir = dirname($strFileName);
if (!file_exists($dir)) mkdir($dir, 0777, true);
zip_entry_open($zip, $zip_entry);
$strFile = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
file_put_contents($strFileName, $strFile);
unset($strFile);
zip_entry_close($zip_entry);
}
zip_close($zip);
unset($zip);
}
// preserve line breaks and spaces
$data->t->addAttribute("dump:xml:space", "preserve");
/**********************************************/
// sheet data manipulation
/**********************************************/
/** @ignore */
private function updateSharedString($o_si, $data){
$dom_si = dom_import_simplexml($o_si);
while ($dom_si->hasChildNodes()) {
$dom_si->removeChild($dom_si->firstChild);
}
if (!is_object($data)){
$data = simplexml_load_string("<richText><t>".htmlspecialchars($data)."</t></richText>");
// preserve line breaks and spaces
$data->t->addAttribute("dump:xml:space", "preserve");
}
foreach($data->children() as $childNode){
$domInsert = $dom_si->ownerDocument->importNode(dom_import_simplexml($childNode), true);
$dom_si->appendChild($domInsert);
}
return simplexml_import_dom($o_si);
}
if (!isset($this->_cSheet->mergeCells->mergeCell) || count($this->_cSheet->mergeCells->mergeCell)==0)
/** @ignore */
private function shiftDownMergedCells($yStart, $yOrigin = null){
if (!isset($this->_cSheet->mergeCells->mergeCell) || count($this->_cSheet->mergeCells->mergeCell)==0)
return;
$toAdd = Array();
foreach($this->_cSheet->mergeCells->mergeCell as $mergeCell){
list($cell1, $cell2) = explode(":", $mergeCell["ref"]);
list($x1, $y1) = self::cellAddress($cell1);
list($x2, $y2) = self::cellAddress($cell2);
if (max($y1, $y2)>=$yStart && min($y1, $y2)<$yStart){ // if mergeCells are crossing inserted row
throw new eiseXLSX_Exception("mergeCell {$mergeCell["ref"]} is crossing newly inserted row at {$yStart}");
}
if (min($y1, $y2)>=$yStart){
$mergeCell["ref"] = $this->index2letter($x1).($y1+1).":".$this->index2letter($x2).($y2+1);
}
if ($yOrigin!==null)
if ($y1==$y2 && $y1==$yOrigin){ // if there're merged cells on cloned row we add new <mergeCell>
$toAdd[] = $this->index2letter($x1).($yStart).":".$this->index2letter($x2).($yStart);
}
}
foreach($toAdd as $newMergeCellRange){
$newMC = $this->_cSheet->mergeCells->addChild("mergeCell");
$newMC["ref"] = $newMergeCellRange;
$this->_cSheet->mergeCells["count"] = $this->_cSheet->mergeCells["count"]+1;
}
}
The text was updated successfully, but these errors were encountered:
ADD function getColCount()
CHANGE date format in function formatDataRead() and ADD Currency
Bugfixes
if (!is_resource($zip))
// preserve line breaks and spaces
$data->t->addAttribute("dump:xml:space", "preserve");
if (!isset($this->_cSheet->mergeCells->mergeCell) || count($this->_cSheet->mergeCells->mergeCell)==0)
The text was updated successfully, but these errors were encountered: