Skip to content

Commit 3c9a2a6

Browse files
igiturandersnm
authored andcommitted
Fix thousands separator (#11)
* Fix thousands separator * Changes after feedback
1 parent fd0b9e4 commit 3c9a2a6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/ExcelNumberFormat/Formatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public static void FormatThousands(string valueString, bool thousandSeparator, b
371371

372372
FormatPlaceholder(token, c, significant, result);
373373

374-
if (significant && thousandSeparator)
374+
if (thousandSeparator && (significant || token.Equals("0")))
375375
FormatThousandSeparator(valueString, digitIndex, culture, result);
376376

377377
digitIndex++;

test/ExcelNumberFormat.Tests/Class1.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ public void TestComma()
423423

424424
}
425425

426+
[TestMethod]
427+
public void TestThousandSeparator()
428+
{
429+
var actual = Format(1469.07, "0,000,000.00", CultureInfo.InvariantCulture);
430+
Assert.AreEqual("0,001,469.07", actual);
431+
}
432+
426433
void TestValid(string format)
427434
{
428435
var to = new NumberFormat(format);

0 commit comments

Comments
 (0)