【问题标题】:How to call getDefaultRowHeightByFont() function correctly in phpspreadsheet如何在 phpspreadsheet 中正确调用 getDefaultRowHeightByFont() 函数
【发布时间】:2019-08-29 04:30:53
【问题描述】:

我正在逐行写入 excel,并在写入每一行后尝试获取当前行高。

我尝试使用 getDefaultRowHeightByFont() 根据字体类型获取默认行高。

$font_type='times new roman';
$sheet->getDefaultRowHeightByFont(\PhpOffice\PhpSpreadsheet\Style\Font.$font_type)

行高应该是我们在 Excel 表中手动检查行高时得到的准确值。但是,我得到了错误

Call to undefined method PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::getDefaultRowHeightByFont()

如何正确调用该函数? 提前致谢。

【问题讨论】:

    标签: phpexcel phpspreadsheet


    【解决方案1】:

    能够让它运行。

    use PhpOffice\PhpSpreadsheet\Shared\Font as SharedFont;
    $default_rowheight=SharedFont::getDefaultRowHeightByFont($spreadsheet->getDefaultStyle()->getFont());
    

    但是,此方法仅显示该工作表中默认字体样式的行高。因此,我们无法找到与默认字体样式不同的行的准确行高。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-27
      • 2021-07-14
      相关资源
      最近更新 更多