Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
ede96007
Unverified
Commit
ede96007
authored
3 years ago
by
Noah Moss
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Omit thousands separator in XLSX format string if specified in viz setting (#19228)
parent
095ca018
No related branches found
Branches containing commit
Tags
v0.33.1
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/query_processor/streaming/xlsx.clj
+9
-2
9 additions, 2 deletions
src/metabase/query_processor/streaming/xlsx.clj
test/metabase/query_processor/streaming/xlsx_test.clj
+8
-1
8 additions, 1 deletion
test/metabase/query_processor/streaming/xlsx_test.clj
with
17 additions
and
3 deletions
src/metabase/query_processor/streaming/xlsx.clj
+
9
−
2
View file @
ede96007
...
...
@@ -24,6 +24,7 @@
(
def
^
:private
number-setting-keys
"If any of these settings are present, we should format the column as a number."
#
{
::mb.viz/number-style
::mb.viz/number-separators
::mb.viz/currency
::mb.viz/currency-style
::mb.viz/currency-in-header
...
...
@@ -95,6 +96,7 @@
;; Custom number formatting options are not set
(
not
(
seq
(
dissoc
format-settings
::mb.viz/number-style
::mb.viz/number-separators
::mb.viz/scale
::mb.viz/prefix
::mb.viz/suffix
)))))
...
...
@@ -111,10 +113,15 @@
merged-settings
(
if
is-currency?
(
merge-global-settings
format-settings
:type/Currency
)
format-settings
)
base-string
(
if
(
=
(
::mb.viz/number-separators
format-settings
)
"."
)
;; Omit thousands separator if ommitted in the format settings. Otherwise ignore
;; number separator settings, since custom separators are not supported in XLSX.
"###0"
"#,##0"
)
base-strings
(
if
(
default-number-format?
merged-settings
)
;; [int-format, float-format]
[
"#,##0"
,
"#,##0
.##"
]
(
repeat
2
(
apply
str
"#,##0"
(
when
(
>
decimals
0
)
(
apply
str
"."
(
repeat
decimals
"0"
))))))]
[
base-string
(
str
base-string
"
.##"
)
]
(
repeat
2
(
apply
str
base-string
(
when
(
>
decimals
0
)
(
apply
str
"."
(
repeat
decimals
"0"
))))))]
(
condp
=
(
::mb.viz/number-style
merged-settings
)
"percent"
(
map
#
(
str
%
"%"
)
base-strings
)
...
...
This diff is collapsed.
Click to expand it.
test/metabase/query_processor/streaming/xlsx_test.clj
+
8
−
1
View file @
ede96007
...
...
@@ -61,7 +61,14 @@
(
is
(
=
"#,##0E+0"
(
format-string
{
::mb.viz/decimals
-1
,
::mb.viz/number-style
"scientific"
})))
(
is
(
=
"[$$]#,##0"
(
format-string
{
::mb.viz/decimals
-1
,
::mb.viz/currency-in-header
false,
::mb.viz/number-style
"currency"
}))))
::mb.viz/number-style
"currency"
})))
;; Thousands separator can be omitted
(
is
(
=
[
"###0"
"###0.##"
]
(
format-string
{
::mb.viz/number-separators
"."
})))
;; Custom separators are not supported
(
is
(
=
[
"#,##0"
"#,##0.##"
]
(
format-string
{
::mb.viz/number-separators
", "
})))
(
is
(
=
[
"#,##0"
"#,##0.##"
]
(
format-string
{
::mb.viz/number-separators
".,"
})))
(
is
(
=
[
"#,##0"
"#,##0.##"
]
(
format-string
{
::mb.viz/number-separators
".’"
}))))
(
testing
"Scale"
;; Scale should not affect format string since it is applied to the actual data prior to export
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment