I do have Euro symbol on mine.The formatting of a cell with Euro Symbol works l with Excel.
Only with these tries iam getting a vague character ... Regards **Hope can be ignited by a spark of encouragement ***** On Mon, Jan 25, 2010 at 8:59 AM, MSB <[email protected]> wrote: > > Cannot think what to say really because this; > > numberStyle.setDataFormat(workbook.createDataFormat().getFormat("0.00\" > €\"")); > > worked fine on my machine, as did this; > > > numberStyle.setDataFormat(workbook.createDataFormat().getFormat("0.00\"€\"")); > > The only apparent difference is the numeric portion of the format - mine is > simpler - but I cannot believe that has any impact; sadly, I did not try it > to see because I wanted to reproduce the problem and reply to your > question, > but I confident that it ought to make no difference at all to the result. > Of > course, these are very similar to one you have already tried with no > success! > > I thought that it may be down to a problem with fonts so I tried changing > that as well and it had not impact other than sometimes leaving the Euro > symbol unaffacted so that you had the odd effect of a number formatted > using > one font and the currency symbol another. > > Is the Euro symbol available on your keyboard? I have to press and hold > down > the AltGr key and then press the number 4 to get the symbol on my keyboard? > Are you able to create a suitable format directly using Excel or is it > likewise unable to display the Euro symbol? Some time ago, I do seem to > remember - getting old now so the memory is dodgy - that the Euro symbol > was > only defined for certain codepages but I cannot see that being the real > problem. > > Yours > > Mark B > > PS Had a quick search and found this, it may help; > http://www.microsoft.com/typography/EuroSymbolFAQ.mspx > > > Princess-4 wrote: > > > > Thanks for the solution...it worked.. > > > > Similarly i wanted € sign along with the values...it shows vague > > characters > > ..These are my tries > > > > > > > **this.styleEuro.setDataFormat(wb.createDataFormat().getFormat("##,##0.00€")); > > > > > **this.styleEuro.setDataFormat(wb.createDataFormat().getFormat("##,##0.00\"€\"")); > > ** > > > this.styleEuro.setDataFormat(wb.createDataFormat().getFormat("##,##0.00\"\u20AC\"")); > > > **this.styleEuro.setDataFormat(wb.createDataFormat().getFormat("##,##0.00\'\u20AC\'")); > > > **this.styleEuro.setDataFormat(wb.createDataFormat().getFormat("##,##0.00\u20AC")); > > > > all these renders me the same output and the without currency symbol . > > > > Where am i going wrong ... > > **Hope can be ignited by a spark of encouragement ***** > > > > > > > > On Sat, Jan 23, 2010 at 10:25 AM, MSB <[email protected]> wrote: > > > >> > >> Turns out it was the single inverted comma that you used to surround the > >> kg > >> symbol with; it should have been speach marks or quotation marks. Try > >> this; > >> > >> public static final void kgFormat(String filename) { > >> File file = null; > >> FileOutputStream fos = null; > >> HSSFWorkbook workbook = null; > >> HSSFSheet sheet = null; > >> HSSFRow row = null; > >> HSSFCell cell = null; > >> HSSFCellStyle numberStyle = null; > >> try { > >> file = new File(filename); > >> workbook = new HSSFWorkbook(); > >> numberStyle = workbook.createCellStyle(); > >> > >> numberStyle.setDataFormat(workbook.createDataFormat().getFormat("0.00\" > >> kg\"")); > >> sheet = workbook.createSheet(); > >> row = sheet.createRow(0); > >> cell = row.createCell(0); > >> cell.setCellValue(10.023); > >> cell.setCellStyle(numberStyle); > >> > >> fos = new FileOutputStream(file); > >> workbook.write(fos); > >> } > >> catch(IOException ioEx) { > >> System.out.println("Caught an: " + > ioEx.getClass().getName()); > >> System.out.println("Message: " + ioEx.getMessage()); > >> System.out.println("Stacktrace follows:............"); > >> ioEx.printStackTrace(System.out); > >> } > >> finally { > >> try { > >> if(fos != null) { > >> fos.close(); > >> } > >> } > >> catch(IOException ioEx) { > >> > >> } > >> } > >> } > >> > >> It works for me using POI version 3.6 and Office 2007. If you do not > want > >> the space between the final digit and the kg symbol, simply change this > >> line; > >> > >> numberStyle.setDataFormat(workbook.createDataFormat().getFormat("0.00\" > >> kg\"")); > >> > >> to this; > >> > >> > >> > numberStyle.setDataFormat(workbook.createDataFormat().getFormat("0.00\"kg\"")); > >> > >> Yours > >> > >> Mark B > >> > >> PS This goes without saying of course, I only made this into a static > >> method > >> so that I could plug the test code into a junk class I use to > >> prototype/test > >> this type of thing. You will want to do something different for your > code > >> I > >> am sure. > >> > >> > >> Princess-4 wrote: > >> > > >> > I have already tried all these combinations.I get error ehen i open > the > >> > file > >> > Hepzibah > >> > **Hope can be ignited by a spark of encouragement ***** > >> > > >> > > >> > > >> > On Fri, Jan 22, 2010 at 3:19 PM, MSB <[email protected]> > wrote: > >> > > >> >> > >> >> Have you tried > >> >> > >> >> this.styleKg.setDataFormat(wb.createDataFormat().getFormat("#,##000 > >> >> \'kg\'")); > >> >> > >> >> or > >> >> > >> >> this.styleKg.setDataFormat(wb.createDataFormat().getFormat("#,##000 > >> >> kg")); > >> >> > >> >> or even > >> >> > >> >> > >> > this.styleKg.setDataFormat(wb.createDataFormat().getFormat("#,##000kg")); > >> >> > >> >> just to see if the problem has to do with the single inverted commas > >> >> surrounding the units symbol? Have no idea if this will help at all, > >> >> sorry. > >> >> > >> >> Yours > >> >> > >> >> Mark B > >> >> > >> >> > >> >> Princess-4 wrote: > >> >> > > >> >> > this.styleKg.setDataFormat(wb.createDataFormat().getFormat("#,##000 > >> >> > 'kg'")); > >> >> > > >> >> > > >> >> > is not setting the format in the cell with POI 2.5 .basically i > want > >> >> 1000 > >> >> > Kg > >> >> > to be written in the cell > >> >> > along with the unit. > >> >> > > >> >> > The same user defined format works in Excel.. > >> >> > > >> >> > But to display % > >> >> > > >> this.stylePer.setDataFormat(wb.createDataFormat().getFormat("0.00%")); > >> >> is > >> >> > working > >> >> > > >> >> > thanks > >> >> > > >> >> > > >> >> > >> >> -- > >> >> View this message in context: > >> >> > >> > http://old.nabble.com/Units-to-be-set-through-getFormat%28%29-tp27271302p27273826.html > >> >> Sent from the POI - User mailing list archive at Nabble.com. > >> >> > >> >> > >> >> --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: [email protected] > >> >> For additional commands, e-mail: [email protected] > >> >> > >> >> > >> > > >> > > >> > >> -- > >> View this message in context: > >> > http://old.nabble.com/Units-to-be-set-through-getFormat%28%29-tp27271302p27284589.html > >> Sent from the POI - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > > > > -- > View this message in context: > http://old.nabble.com/Units-to-be-set-through-getFormat%28%29-tp27271302p27303179.html > Sent from the POI - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
