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

Problem with JSON convert #56

Open
PYovchevski opened this issue Feb 13, 2020 · 1 comment
Open

Problem with JSON convert #56

PYovchevski opened this issue Feb 13, 2020 · 1 comment

Comments

@PYovchevski
Copy link

Is there some option to show the empty fields in JSON string as empty string.
The problem is that $excel->toString('JSON') skip the empty fields and if I try to get the content of column X, the content type doesn't match with other rows column X content.

For example

image

The output array is:

array(3) {
[0]=> string(?) "Title"
[1]=> string(?) "Quantity"
[2]=> string(?) "Price"
}
array(3) {
[0]=> string(?) "BMW"
[1]=> string(?) "5"
[2]=> string(?) "$192.000"
}
array(2) {
[0]=> string(?) "Mercedes"
[1]=> string(?) "$204.000"
}
array(3) {
[0]=> string(?) "Audi"
[1]=> string(?) "10"
[2]=> string(?) "$150.000"
}

So, when I'm trying to get all quantites result is:

5, $204.000, 10

@davidjeddy
Copy link
Contributor

Looking at the JSON parser class it does not appear there is currently a way to include empty cells. However, it should not be terrible difficualt to add said functioanlity to the parser class. Take a look here https://github.com/faisalman/simple-excel-php/blob/master/src/SimpleExcel/Parser/JSONParser.php . My hunch would be to add a boolean, default to false as to not break backward compatibility, that would include empty cells in the JSON output.

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

No branches or pull requests

2 participants