숫자가 길어질 경우 뒷 자리가 0000 으로 나와 버리는 문제점이 보고 되었는데 format을 사용하여 수정을 하려고 노력 함
$this->format = & $workbook->addformat($text);
$this->format->setNumFormat('0');
등등의 format 셋팅 후
$worksheet->write($i, $j, $val , $this->format);
으로 값을 저장할때 $this->format을 추가해 포맷을 설정해줌 하지만 아무리 해도 통하지 않음
결국 engine을 손을 봐야 했음
Spreadsheet/Excel/Writer/Worksheet.php 를 열어보면 write라는 function이 있다.
function write($row, $col, $token, $format = 0)
{
// Check for a cell reference in A1 notation and substitute row and column
/*if ($_[0] =~ /^\D/) {
@_ = $this->_substituteCellref(@_);
}*/
// Match number
if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/",$token)) {
//return $this->writeNumber($row,$col,$token,$format);
// 바꿔 버림...잘됨
return $this->writeString($row,$col,$token,$format);
}
// Match http or ftp URL
elseif (preg_match("/^[fh]tt?p:\/\//",$token)) {
return $this->writeUrl($row, $col, $token, '', $format);
}
// Match mailto:
elseif (preg_match("/^mailto:/",$token)) {
return $this->writeUrl($row, $col, $token, '', $format);
}
// Match internal or external sheet link
elseif (preg_match("/^(?:in|ex)ternal:/",$token)) {
return $this->writeUrl($row, $col, $token, '', $format);
}
// Match formula
elseif (preg_match("/^=/",$token)) {
return $this->writeFormula($row, $col, $token, $format);
}
// Match formula
elseif (preg_match("/^@/",$token)) {
return $this->writeFormula($row, $col, $token, $format);
}
// Match blank
elseif ($token == '') {
return $this->writeBlank($row,$col,$format);
}
// Default: match string
else {
return $this->writeString($row,$col,$token,$format);
}
}
댓글 없음:
댓글 쓰기