|
Posted by trpost on 04/09/07 14:55
I am using a set of functions that seem to be pretty common for using
an associative array to write data to an .XLS file. This work fine for
the most part, however I have problems writting a number to Excel on a
Solaris system, whereas it works fine on a Windows system using the
same PHP version (5.05). I have isolated the code to the following
function:
/**
* Excel worksheet cell insertion
* (single-worksheet supported only)
* @access private
* @param (int) $row worksheet row number
(0...65536)
* @param (int) $col worksheet column number
(0..255)
* @param (mixed) $val worksheet row number
*/
function _xlsWriteCell($row, $col, $val)
{
if (is_float($val) || is_int($val))
{
// doubles, floats, integers
$str = pack(str_repeat($this->bin[$this->endian], 5),
0x203, 14, $row, $col, 0x0);
$str .= pack("d", $val);
}
else
{
// everything else is treated as a string
$l = strlen($val);
$str = pack(str_repeat($this->bin[$this->endian], 6),
0x204, 8 + $l, $row, $col, 0x0, $l);
$str .= $val;
}
fwrite($this->fp, $str);
$this->position += strlen($str);
return strlen($str);
}
Specifically it looks like the problem is happening here:
if (is_float($val) || is_int($val))
{
// doubles, floats, integers
$str = pack(str_repeat($this->bin[$this->endian], 5),
0x203, 14, $row, $col, 0x0);
$str .= pack("d", $val);
}
My guess is that where it is doing pack("d", $val); that a DOUBLE is
treated different on a windows versus solaris system. I tried changing
this "d" to other things such as Long, Float, and others, but it just
prints garbage when I do so...
Any ideas on how to get this to write a number properly on Solaris, or
how to interpret the 2 pack statements above to get an idea what
exactly it is doing?
Thanks
Navigation:
[Reply to this message]
|