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

Duration cell formatting is stripped as color formatting #446

Closed
ivankruchkoff opened this issue Mar 30, 2018 · 1 comment
Closed

Duration cell formatting is stripped as color formatting #446

ivankruchkoff opened this issue Mar 30, 2018 · 1 comment

Comments

@ivankruchkoff
Copy link

This is:

- [X] a bug report

What is the expected behavior?

Cell value is:
12:34
Formatting is:
[mm]:ss

Per: https://support.office.com/en-us/article/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68 this is Elapsed time (minutes and seconds)

What is the current behavior?

[mm] is stripped from formatting here:

$format = preg_replace($color_regex, '', $format);

What are the steps to reproduce?

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';

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

// add code that show the issue here...
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
$value = 0.0087268518518519;
$format = '[mm]:ss';
NumberFormat::toFormattedString( $value, $format )

Which versions of PhpSpreadsheet and PHP are affected?

1.2.0
PHP 7.0.26-2+ubuntu14.04.1+deb.sury.org+2

Sample File

bug-report.xlsx

$spreadsheet = $reader->load('bug-report.xlsx');
$spreadsheet->getActiveSheet()->getCell('A1')->getFormattedValue();
@PowerKiKi
Copy link
Member

This is a duplicate of #342. Please try to contribute over there if this is important to you.

@patrickomeara patrickomeara mentioned this issue Sep 8, 2018
7 tasks
PowerKiKi pushed a commit that referenced this issue Jan 2, 2019
When using format `[h]:mm` it should convert to the "total hours:minutes"

Closes #666
Fixes #664
Fixes #446
Fixes #342
guillaume-ro-fr pushed a commit to guillaume-ro-fr/PhpSpreadsheet that referenced this issue Jun 12, 2019
When using format `[h]:mm` it should convert to the "total hours:minutes"

Closes PHPOffice#666
Fixes PHPOffice#664
Fixes PHPOffice#446
Fixes PHPOffice#342
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

2 participants