mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-16 23:30:52 +00:00
check for NaN
This commit is contained in:
parent
58d1804a97
commit
a76861f3ae
@ -119,18 +119,19 @@ class Cell implements Comparable<Cell>, Value
|
|||||||
case VALUE:
|
case VALUE:
|
||||||
if (hasValue ())
|
if (hasValue ())
|
||||||
{
|
{
|
||||||
|
Double value = getValue ();
|
||||||
|
if (Double.isNaN (value))
|
||||||
|
return justify ("", colWidth);
|
||||||
|
|
||||||
char format = cellFormat != ' ' ? cellFormat : defaultFormat;
|
char format = cellFormat != ' ' ? cellFormat : defaultFormat;
|
||||||
if (format == 'I')
|
if (format == 'I')
|
||||||
{
|
{
|
||||||
String integerFormat = String.format ("%%%d.0f", colWidth);
|
String integerFormat = String.format ("%%%d.0f", colWidth);
|
||||||
return String.format (integerFormat, getValue ());
|
return String.format (integerFormat, value);
|
||||||
}
|
}
|
||||||
else if (format == '$')
|
else if (format == '$')
|
||||||
{
|
{
|
||||||
String currencyFormat = String.format ("%%%d.%ds", colWidth, colWidth);
|
String currencyFormat = String.format ("%%%d.%ds", colWidth, colWidth);
|
||||||
Double value = getValue ();
|
|
||||||
if (Double.isNaN (value))
|
|
||||||
return justify ("", colWidth);
|
|
||||||
return String.format (currencyFormat, nf.format (value));
|
return String.format (currencyFormat, nf.format (value));
|
||||||
}
|
}
|
||||||
else if (format == '*')
|
else if (format == '*')
|
||||||
@ -143,7 +144,7 @@ class Cell implements Comparable<Cell>, Value
|
|||||||
{
|
{
|
||||||
// this could be improved
|
// this could be improved
|
||||||
String numberFormat = String.format ("%%%d.3f", colWidth + 4);
|
String numberFormat = String.format ("%%%d.3f", colWidth + 4);
|
||||||
String val = String.format (numberFormat, getValue ());
|
String val = String.format (numberFormat, value);
|
||||||
while (val.endsWith ("0"))
|
while (val.endsWith ("0"))
|
||||||
val = ' ' + val.substring (0, val.length () - 1);
|
val = ' ' + val.substring (0, val.length () - 1);
|
||||||
if (val.endsWith ("."))
|
if (val.endsWith ("."))
|
||||||
|
@ -183,7 +183,7 @@ public class Sheet implements Iterable<Cell>
|
|||||||
switch (line.charAt (1))
|
switch (line.charAt (1))
|
||||||
{
|
{
|
||||||
case 'W':
|
case 'W':
|
||||||
System.out.printf ("Skipping [%s]%n", line);
|
// System.out.printf ("Skipping [%s]%n", line);
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
switch (line.charAt (2))
|
switch (line.charAt (2))
|
||||||
@ -195,7 +195,7 @@ public class Sheet implements Iterable<Cell>
|
|||||||
recalculationOrder = line.charAt (3);
|
recalculationOrder = line.charAt (3);
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
System.out.printf ("Skipping [%s]%n", line);
|
// System.out.printf ("Skipping [%s]%n", line);
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
columnWidth = Integer.parseInt (line.substring (3));
|
columnWidth = Integer.parseInt (line.substring (3));
|
||||||
@ -209,7 +209,7 @@ public class Sheet implements Iterable<Cell>
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
System.out.printf ("Skipping [%s]%n", line);
|
// System.out.printf ("Skipping [%s]%n", line);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.printf ("Skipping [%s]%n", line);
|
System.out.printf ("Skipping [%s]%n", line);
|
||||||
@ -342,7 +342,7 @@ public class Sheet implements Iterable<Cell>
|
|||||||
String underline = "---------------------------------------------------------"
|
String underline = "---------------------------------------------------------"
|
||||||
+ "-----------------------------------------------------------------";
|
+ "-----------------------------------------------------------------";
|
||||||
|
|
||||||
int lastRow = -1;
|
int lastRow = 0;
|
||||||
int lastColumn = 0;
|
int lastColumn = 0;
|
||||||
|
|
||||||
StringBuilder heading = new StringBuilder (" ");
|
StringBuilder heading = new StringBuilder (" ");
|
||||||
@ -365,7 +365,10 @@ public class Sheet implements Iterable<Cell>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
{
|
||||||
text.append (heading);
|
text.append (heading);
|
||||||
|
text.append ("\n001:");
|
||||||
|
}
|
||||||
|
|
||||||
for (Cell cell : sheet.values ())
|
for (Cell cell : sheet.values ())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user