Skip to content

fix(export): type numeric answers as numbers in exports#3368

Open
solracsf wants to merge 1 commit into
mainfrom
fix/numeric-as-numbers
Open

fix(export): type numeric answers as numbers in exports#3368
solracsf wants to merge 1 commit into
mainfrom
fix/numeric-as-numbers

Conversation

@solracsf
Copy link
Copy Markdown
Member

@solracsf solracsf commented May 29, 2026

Radio and other choice-type answers are always PHP strings, even when the option labels are pure numbers like "1"-"5".

setCellValue() wrote every string via setValueExplicit() with the default TYPE_STRING, so numeric answers landed in Text-formatted cells and could not be averaged in the spreadsheet application.

For XLSX/ODS, route purely numeric values through setCellValue() so they are stored with a numeric data type. A value is only treated as numeric when it is is_numeric(), does not start with a formula-trigger character (= + - @), and round-trips exactly ((string)(+$value) === $value).

The round-trip guard keeps leading-zero phone numbers, scientific notation, trailing-zero decimals and oversized ids as text to avoid silent data loss, since all export values arrive as strings from Answer::getText().

The anti-formula string protection and CSV escaping are unchanged.

@solracsf solracsf added bug Something isn't working enhancement New feature or request 3. to review Waiting for reviews labels May 29, 2026
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf force-pushed the fix/numeric-as-numbers branch from 56abba2 to e90d45e Compare May 29, 2026 08:57
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Chartman123
Copy link
Copy Markdown
Collaborator

/backport to stable5.2

@backportbot backportbot Bot added the backport-request Pending backport by the backport-bot label May 29, 2026
@Chartman123 Chartman123 requested review from Koc, pringelmann and susnux May 29, 2026 11:24
@solracsf
Copy link
Copy Markdown
Member Author

@Chartman123 we've manually backported it as codebase is not the same.

@Chartman123
Copy link
Copy Markdown
Collaborator

You're absolutely right, my fault... so please re-open the manual backport :)

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

Labels

3. to review Waiting for reviews backport-request Pending backport by the backport-bot bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants