java - how to format a string value to double decimal format -
number format nf = numberformat.getnumberinstance(locale.us); decimalformat df = (decimalformat)nf; df.applypattern("$###,###.###"); string format_val=df.format(4596.37); num = new jxl.write.number(i, j,double.parsedouble(format_val),arial10format); here i'm getting numberformatexception :
java.lang.numberformatexception: input string: "$4,596.37" how solve one?
what "think" want (i've not tried this) let cell take care of formatting, example...
numberformat decimalno = new numberformat("$###,###.###"); writablecellformat numberformat = new writablecellformat(decimalno); //write datasheet number numbercell = new number(i, j, 4596.37, numberformat); excelsheet.addcell(numbercell); take @ writablecellformat more details
what you've tried is...
- convert
doublevalue4596.37string, format of$###,###.### - try , convert
$4,596.37double...which failsstringyou've passed not conform requirements ofdouble...
a number has no concept of format, that's formatters for. in case, however, excel cell has it's own internal formatting capabilities can take care of you
Comments
Post a Comment