Apache POI percentage format not working

I have a module where I have to take double values from html form and then populate them in an excel using Apache POI.

Excel cells are showing percentage. Module is not working. please see code

CellStyle style = wb.createCellStyle(); style.setDataFormat(wb.createDataFormat().getFormat("##.##%")); sheet.getRow(4).getCell(3).setCellValue(wifimodel.getMobileSubscriberCountToday()); sheet.getRow(4).getCell(3).setCellStyle(style);

Now wifimodel.getMobileSubscriberCountToday() value is 10.0 and in excel it comes as 1000,%

please help

-------------Problems Reply------------

Promoting a comment to an answer

In maths equivalences, and in computers, percentages are stored as relative to 1 not 100. As wikipedia explains, that's because a percentage is a number or ratio expressed as a fraction of 100. As such, 10% is not stored as 10, but instead as 0.10. That means that to store your value of 10%, you need to put it in an Apache POI cell formatted as a percentage, with a numeric value of 0.10.

As you have found, putting in a value of 10 is treated as 10*100 = 1,000 %, which is 100 times what you had in mind!

Category:java Views:8 Time:2018-12-29

Related post

  • Apache POI "addPicture" method not working for me 2012-04-08

    I have a problem with inserting a picture into an Excel Workbook with Apache POI(version 3.7). Here's my code: private static void createAndFillWorkbook() { FileOutputStream out = null; FileInputStream in = null; try { HSSFWorkbook workbook = new HSS

  • Format() not working in Visual Basic (Visual Studio 2005/ Win 7) 2010-08-16

    I am having a problem with Format not working. I have tried several standard formats but it doesn't effect the output at all. Dim tempstring As String = Format(Now(), "M, m") and Dim date As Date = Format(Now(), "M, m") both have a final value of "8/

  • Long date format not working from the Number format menue in excel 2010. 2014-02-21

    My long date format not working from the Number format menu in excel 2010. When I click on the long date in the number section on the home ribbon, it changes to the short date format. It appears that the formatting for this choose is missing. Can any

  • mergefield for date format not working after a computer upgrade 2014-09-07

    I recently had a computer upgrade, Prior to the upgrade when I used the mergefield format for a date field I could use {MERGEFIELD REQUEST_DATE \ @ "MMMM d, yyyy" } and it would show properly as January 1, 2013, now it will only show 01/01/2013. Not

  • Apache poi date format 2012-03-18

    Hi i am reading csv file and getting date in 01-01-2011 but i want it in 01-Jan-2011 format when i write .xlsx file using apache poi library. my code is XSSFDataFormat df = workBook.createDataFormat(); cs.setDataFormat(df.getFormat("dd-MMM-yy")); but

  • DGV Column/CellStyle.format not working 2010-05-31

    I wanted the user to input values in "dd MMM yyyy" format Only, I'm using dataGridView1.Columns["Rel_Date"].DefaultCellStyle.Format = "dd MMM yyyy"; in Form_Load......... But somehow it's not working. --------------Solutions------------- That 'Format

  • exporting jasper report in pdf format working but exporting it into html format not working properly 2010-10-11

    When I am exporting a jasper report in pdf format it is working properly and all the charts are working. In the case of exporting in HTML format, it is not working properly. The lists are shown but the charts are not coming out in the report. It is s

  • OpenLayers - dynamic POI example does not work on my machine 2010-10-29

    OpenLayers has a good example which I would like to reuse: http://openlayers.org/dev/examples/dynamic-text-layer.html But when I download it and run on my machine, it does not work. It also does not work when I download OpenLayers-2.10.zip from openl

  • Simple PHP time format not working! 2011-05-13

    I have the following value: 30/05/2010 @ 09:15:15 I need to convert it to Y-m-d H:i:s. I've tried: $date = "30/05/2010 @ 09:15:15"; $formatteddate = date("Y-m-d H:i:s", time($date)); echo $formatteddate; I end up with a value dated 1970. I've also tr

  • Visual Studio Ctrl K + D (code formatting) not working 2012-03-14

    Ctrl K + D in a Visual Studio 2010 Sharepoint project is not working in some files as they contain paths to some resources (masterpageurl/images/js/css classnames) that get generated at runtime. How do I make VS to "ignore" checking if these resource

  • PHP cookie time format not working 2012-04-11

    I have these two cookies and they do work but only if the cookies expiry is 5 hours and over, nothing under. If I set the cookie expiry to 0 it will also work, but I what I need to a cookie to expire in 2 hours. It works in firefox when I set the coo

  • Conditional Formatting not Working For Text on Subreport 2013-02-19

    Hi, I am trying to create two conditions for conditional formatting, but I am not doing something right. First off, I am trying to set the background of one report field based on the text value of another. The expression I am using in the conditional

  • accde file format not working 2012-04-27

    well i have design a Microsoft access 2010 database where i do need to disable my form ,report etc to be edited the time i convert my database from accdb to accde my user login form not working Dim a, b As Variant a = usernamtxt.Value b = passwd.Valu

  • Standard Format not Working 2012-08-09

    I am using Access 2010 and when I tried to Format a number field on a report using the Standard format option but I don't get the Thousands separator only the decimals. --------------Solutions------------- In the Regional and Language Options control

  • conditional format not working 2013-04-02

    I'm using Excel 2007 and have a parameter set that allows me to display data in 'units' or 'thousands' I have the default format of the data cells set to #,##0.0,_);[Red](#,##0.0,);--_) Unit_Selection is a range that holds 1 to indicate units and 2 t

  • Conditional Formatting - Not working in odd cells where it should be??? 2013-08-29

    Hey, I have a sheet where I'd applied the same rule to different blocks of numbers in the same column (I can't remember why I did it this way, all I can think is that because I'm not very good with conditional formats I did them all separately). Now

  • Conditional Formatting not working properly in 2007 2013-10-15

    Hi, Column M = Scheduled Hours in a software system Column N = Hours that should be in the software system Column O = True or False comparison of the two columns. I have copy, then paste special to "lock" the responses, then I replace "True" with a b

  • Excel 2013 Conditional Formatting not working correctly 2014-03-05

    I have a spreadsheet that colours cells using conditional formatting. The formula is an array =AL51:BJ51<>0 and this is applied to an array of corresponding cells =$L$10:$AJ$10. This works in Excel 2007 and 2010 but is inconsistent in Excel 201

  • Office 365 Word Endnote and Footnote Formatting Not Working 2014-06-15

    Hello All, I'm trying to format my endnote/footnotes but the formatting shortcut does not work. If I hover over the formatting hyperlink it will show the endnote/footnote formatting option window but when I click that nothing happens. If I immediatel

  • Keyboard options for Indian Format not working in Vista 2014-11-06

    Using Keyboard Options for Special characters not working as per Indian Format for Windows Vista. Im using windows vista but unable to use option at symbol above numeric key2? --------------Solutions------------- Hi Valavan Nedumaran, Also, please se

  • calendar advanced view settings conditional formatting not working 2014-11-12

    When customizing the Calendar Viewin MS Outlook 2010 I was under the impression that I could use conditional formatting to change the color of an appoinment/event/meeting. For instance "yellow" for Birthdays. It is not working. I know I can "categori

  • Conditional Formatting not working for exceptions to Recurring Calendar Events 2014-11-20

    I have a conditional formatting rule that basically says, "Make all calendar appointments with (a certain string of text) in the Subject of my calendar events yellow." Most of the time, this works. However, it does NOT work when a particular occurren

  • Conditional Formatting not working in Access 2003 2014-11-27

    I have a mdb which is made in access 2000 and working fine, when the same mdb is used in access 2003 , the conditional formatting is not working. When I bring back to access 2000, it works. This is continious form, and conditional formatting is as be

  • conditional formatting not working, Always worked before. I have made no changes. Please help. 2015-01-09

    I have the formula =mod(row(),2)-0. I format so that every other row is shaded. I copy/paste from another spreadsheet into this one, where all cells are NOT shaded. This has always worked, and all of a sudden today, they are all copying in as not sha

  • Visual Studio Auto Formatting not working on the aspx page 2010-10-14

    I am running Visual Studio 2008. I cannot get the auto format to work on the source code of my aspx page. I have tried it from the edit menu and the ctrl K, D. Nothing works. If I manually fix everything, the next time I open the file the formatting

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.174 (s). 11 q(s)