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

null handling #32

Closed
janokary opened this issue Jul 6, 2018 · 10 comments
Closed

null handling #32

janokary opened this issue Jul 6, 2018 · 10 comments
Labels
question Further information is requested

Comments

@janokary
Copy link

janokary commented Jul 6, 2018

If in the first line of the outputted excel there is a null value then all columns are mixed up in the following lines.

Any suggestions?

@rap2hpoutre
Copy link
Owner

Thank you for your contribution. Could you please provide a (small) example of an Excel that produce the bug? I could add it to the unit tests and fix the bug!

@rap2hpoutre rap2hpoutre added the question Further information is requested label Jul 6, 2018
@janokary
Copy link
Author

janokary commented Jul 6, 2018

When there are nulls values the null cells are skipped (or better missing) end the rest of the line is shifted to the left.

file-3.xlsx

@rap2hpoutre
Copy link
Owner

I can not reproduce the problem. I tried this but it's OK (no bugs):

$original_collection = collect([
    ['col1' => 'val1', 'col2' => 'val2'],
    ['col1' => null, 'col2' => 'val2'] // <= the "null" value is here. 
]);

$filename = __DIR__ . '/test2.xlsx';

(new FastExcel($original_collection))->export($filename);
$res = (new FastExcel())->import($filename);

$this->assertEquals($original_collection, $res); // <= My unit test is green, success

unlink($filename);

Could you paste a relevant part of your collection (thank you for your time!)?

@janokary
Copy link
Author

janokary commented Jul 6, 2018

this is my example (full of nulls):
code.txt

@rap2hpoutre
Copy link
Owner

Thank you! Fixed via b8f3fec, available in v0.4.0 (just update your version with composer and it should work!). Let me know if something went wrong!

@rap2hpoutre
Copy link
Owner

Also, I added a unit test with your case, thanks to you:

public function testIssue32()
{
$original_collection = collect([
[
'duration_in_months' => 1,
'expires_at' => '2018-08-06',
],
[
'duration_in_months' => null,
'expires_at' => '1970-01-01',
],
]);
(new FastExcel(clone $original_collection))->export(__DIR__.'/test2.xlsx');
$res = (new FastExcel())->import(__DIR__.'/test2.xlsx');
$this->assertEquals($original_collection[1], $res[1]);
unlink(__DIR__.'/test2.xlsx');
}

@janokary
Copy link
Author

janokary commented Jul 6, 2018

It is fixed. You are super cool.

@rap2hpoutre
Copy link
Owner

Thank you!

@mrwcjoughin
Copy link

@rap2hpoutre I am using the latest nuget package and it seems this issue is happening again?
if a cell is blank then the cell is not being included in the cells enumeration for that row at all?
how has this regressed if there is a test for it?

@cedrictwillie
Copy link

I believe I am experiencing the same issue on version v5.3.0..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants