Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A non well formed numeric value encountered in src/PhpSpreadsheet/Worksheet/ColumnDimension.php on line 77 #2145

Closed
rsimonru opened this issue Jun 7, 2021 · 4 comments

Comments

@rsimonru
Copy link

rsimonru commented Jun 7, 2021

This is:

- [X ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

No error

What is the current behavior?

An error for every with "width" property in percent

What are the steps to reproduce?

Generate Excel from HTML table with "width property" in tags in percent.

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// $vcTable is an string with a simple table in HTML with any <td width="xx%">
$vcTable='
<table>
<tr>
<td width="15%">A</td>
<td>B</td>
<td>C</td>
</tr>
</table>
';
$tmpfile = tempnam(sys_get_temp_dir(), 'html');
file_put_contents($tmpfile, $vcTable);

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$reader = new PhpOffice\PhpSpreadsheet\Reader\Html();


// add code that show the issue here...
$reader->loadIntoExisting($tmpfile, $spreadsheet);

Which versions of PhpSpreadsheet and PHP are affected?

Checked in last version (1.18.0)

@oleibman
Copy link
Collaborator

oleibman commented Jun 9, 2021

Better support for units for column width and row height when reading html is probably doable. However, it is particularly difficult to figure out what should be done when the measurement is specified as a percentage. Would it be acceptable to you if PhpSpreadsheet merely ignored the width indication if it is specified as a percentage? That would satisfy your "no error" expected behavior. If not, what do you think it should be doing when it sees a percentage rather than a fixed unit?

@MarkBaker
Copy link
Member

I have a half-written update to the column width management for the Html Reader, but it's pretty arbitrary with all the css "relative" UoMs - em, ex, ch and rem are all character-based, so it simply bases the width on the arbitrary default column width of 8.54 for 10 Calibri 11pt characters; % is the percentage of 8.54; and vw, vh, vmin and vmax all simply set the width to 8.54. "Absolute" units like pt, px, pc, cm, mm and in are more straightforward; based on 96dpi, and then adjusted to Microsoft's awkward values based on Calibri 11pt;

@rsimonru
Copy link
Author

Lot of thanks for the response.

At this moment, for us, is enought if the library ignore the width configuration when is set in "%". When it write lots of messages, Excel sheet is not generated, and that is the real problem.

@MarkBaker
Copy link
Member

PR #2152 merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants