I need to make a slight change to the PHP Excel Reader library; http://code.google.com/p/php-excel-reader/
I want to add support for vertical-alignment of cells (top, middle, bottom).
Here's how the normal alignment is detected:
$alignbit = ord($data[$pos+10]) & 3;
And here is the excel 2003 format specification:
http://sc.openoffice.org/excelfileformat.pdf
I'm not sure if this is the correct setting:
Does anyone know what bit I need to get (similar to the $alignbit) in order to get the vertical alignment? (1 of 6 possibilities)
Thanks, Wesley
Personally I'd use
$horizontalAlign = (0x07 & ord($data[$pos+10])) >> 0;
rather than
$horizontalAlign = ord($data[$pos+10]) & 3;
because you can then match the mask (0x07) up with the spec definition more obviously
Using the same principle, vertical alignment is bits 6-4, mask 0x70, so
$verticalAlign = (0x70 & ord($data[$pos+10])) >> 4;
switch ($verticalAlign) {
case 0:
// VERTICAL_TOP
break;
case 1:
// VERTICAL_CENTER
break;
case 2:
// VERTICAL_BOTTOM
break;
case 3:
// VERTICAL_JUSTIFY
break;
case 4:
// VERTICAL_DISTRIBUTED
break;
}
PS. Why are you still using Open Office's partial spec, when Microsoft have published the full specification
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.