2019-07-11 10:28:17 1855次浏览 1条回答 0 悬赏 30 金钱

有谁用过 PhpSpreadsheet 吗?我用 getValue(),一个单元格里面出了三个对象

object(PhpOffice\PhpSpreadsheet\RichText\RichText)#1713 (1) {
  ["richTextElements":"PhpOffice\PhpSpreadsheet\RichText\RichText":private]=>
  array(3) {
    [0]=>
    object(PhpOffice\PhpSpreadsheet\RichText\TextElement)#124 (1) {
      ["text":"PhpOffice\PhpSpreadsheet\RichText\TextElement":private]=>
      string(2) "AA"
    }
    [1]=>
    object(PhpOffice\PhpSpreadsheet\RichText\Run)#125 (2) {
      ["font":"PhpOffice\PhpSpreadsheet\RichText\Run":private]=>
      object(PhpOffice\PhpSpreadsheet\Style\Font)#122 (13) {
        ["name":protected]=>
        string(6) "宋体"
        ["size":protected]=>
        float(11)
        ["bold":protected]=>
        bool(false)
        ["italic":protected]=>
        bool(false)
        ["superscript":protected]=>
        bool(false)
        ["subscript":protected]=>
        bool(false)
        ["underline":protected]=>
        string(4) "none"
        ["strikethrough":protected]=>
        bool(false)
        ["color":protected]=>
        object(PhpOffice\PhpSpreadsheet\Style\Color)#141 (4) {
          ["argb":protected]=>
          string(8) "FF000000"
          ["isSupervisor":protected]=>
          bool(false)
          ["parent":protected]=>
          NULL
          ["parentPropertyName":protected]=>
          NULL
        }
        ["colorIndex"]=>
        NULL
        ["isSupervisor":protected]=>
        bool(false)
        ["parent":protected]=>
        NULL
        ["parentPropertyName":protected]=>
        NULL
      }
      ["text":"PhpOffice\PhpSpreadsheet\RichText\TextElement":private]=>
      string(6) "已在"
    }
    [2]=>
    object(PhpOffice\PhpSpreadsheet\RichText\Run)#121 (2) {
      ["font":"PhpOffice\PhpSpreadsheet\RichText\Run":private]=>
      object(PhpOffice\PhpSpreadsheet\Style\Font)#144 (13) {
        ["name":protected]=>
        string(7) "Calibri"
        ["size":protected]=>
        float(11)
        ["bold":protected]=>
        bool(false)
        ["italic":protected]=>
        bool(false)
        ["superscript":protected]=>
        bool(false)
        ["subscript":protected]=>
        bool(false)
        ["underline":protected]=>
        string(4) "none"
        ["strikethrough":protected]=>
        bool(false)
        ["color":protected]=>
        object(PhpOffice\PhpSpreadsheet\Style\Color)#143 (4) {
          ["argb":protected]=>
          string(8) "FF000000"
          ["isSupervisor":protected]=>
          bool(false)
          ["parent":protected]=>
          NULL
          ["parentPropertyName":protected]=>
          NULL
        }
        ["colorIndex"]=>
        NULL
        ["isSupervisor":protected]=>
        bool(false)
        ["parent":protected]=>
        NULL
        ["parentPropertyName":protected]=>
        NULL
      }
      ["text":"PhpOffice\PhpSpreadsheet\RichText\TextElement":private]=>
      string(19) " BB(Code=lreadyIn)
"
    }
  }
}

最佳答案

  • 发布于 2019-07-11 17:49 举报

    这不是 三个对象,这是 一个 PhpOffice\PhpSpreadsheet\RichText\RichText 对象
    excel 的一个单元格里 可以放一个 RichText 对象进去,这个对象 有个 getPlainText() 方法,可以让你获得其中的 纯文本

    1 条回复
    回复于 2019-07-12 10:10 回复

    那为什么有时候获得一个字符串 有时候获得RichText对象呢, 同一个单元格里面,我拿出来编辑编辑就不一样了

    觉得很赞
    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
星彩星彩星
助理

星彩星彩星 北京

注册时间:2018-05-23
最后登录:2021-05-24
在线时长:14小时3分
  • 粉丝0
  • 金钱15
  • 威望0
  • 积分155

热门问题