PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 4, 2022

[FIXED] How to call getDefaultRowHeightByFont() function correctly in phpspreadsheet

 October 04, 2022     phpexcel, phpspreadsheet     No comments   

Issue

I am writing to excel row by row and try to get current row height after write to each row.

I tried use getDefaultRowHeightByFont() to get default row height based on font type.

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

The row height should be exact value that we get when manually check for row height in excel sheet. But, I got the error

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

How to call that function correctly? Thanks in advance.


Solution

Able to make it run.

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

But, this method only show row height for default font style in that sheet. So, we could not find accurate row height for row with different font style from default.



Answered By - Premlatha
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing