doubi1624 2011-12-05 16:28
浏览 46
已采纳

PHP XLS 2003(Excel)文件 - 检测单元格垂直对齐

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)

enter image description here

enter image description here Thanks, Wesley

  • 写回答

1条回答 默认 最新

  • duancha1065 2011-12-05 16:55
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程