You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2013/07/24 01:37:49 UTC
[Bug 52592] DataFormatter appends asterisk to currency data
https://issues.apache.org/bugzilla/show_bug.cgi?id=52592
Evgeniy <e...@bev.su> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
--- Comment #9 from Evgeniy <e...@bev.su> ---
private String cleanFormatForNumber(String formatStr) {
StringBuffer sb = new StringBuffer(formatStr);
if (emulateCsv) {
// Requested spacers with "_" are replaced by a single space.
// Full-column-width padding "*" are removed.
// Not processing fractions at this time. Replace ? with space.
// This matches CSV output.
for (int i = 0; i < sb.length(); i++) {
char c = sb.charAt(i);
if (c == '_' || c == '*' || c == '?') {
if (i > 0 && sb.charAt((i - 1)) == '\\') {
// It's escaped, don't worry
continue;
}
if (c == '?') {
sb.setCharAt(i, ' ');
} else if (i < sb.length() - 1) {
// Remove the character we're supposed
// to match the space of / pad to the
// column width with
if (c == '_') {
sb.setCharAt(i + 1, ' ');
} else {
sb.deleteCharAt(i + 1);
}
// Remove the character too
sb.deleteCharAt(i);
i--; // !!!!!!!!!!!!!!! LOST !!!!!!!!!!!!!!!!!!
}
}
}
} else {
// If they requested spacers, with "_",
// remove those as we don't do spacing
// If they requested full-column-width
// padding, with "*", remove those too
for (int i = 0; i < sb.length(); i++) {
char c = sb.charAt(i);
if (c == '_' || c == '*') {
if (i > 0 && sb.charAt((i - 1)) == '\\') {
// It's escaped, don't worry
continue;
}
if (i < sb.length() - 1) {
// Remove the character we're supposed
// to match the space of / pad to the
// column width with
sb.deleteCharAt(i + 1);
}
// Remove the _ too
sb.deleteCharAt(i);
i--; // !!!!!!!!!!!!!!! LOST !!!!!!!!!!!!!!!!!!
}
}
}
// Now, handle the other aspects like
// quoting and scientific notation
for(int i = 0; i < sb.length(); i++) {
char c = sb.charAt(i);
// remove quotes and back slashes
if (c == '\\' || c == '"') {
sb.deleteCharAt(i);
i--;
// for scientific/engineering notation
} else if (c == '+' && i > 0 && sb.charAt(i - 1) == 'E') {
sb.deleteCharAt(i);
i--;
}
}
return sb.toString();
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org