Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-10 Thread Mark Beardsley
You're welcome. All the best with the project and, if you ever need to extend support to the OOXML based file format (.xlsx), remember us please. Yours Mark B -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Round-to-one-Decimal-place-not-happenning-using-style-setDataFo

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-10 Thread rakesh.dev
Hi Mark, Thank you very much for support have changed the format in JExcelAPI and getting one decimal formatting done. Thanks Rakesh -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Round-to-one-Decimal-place-not-happenning-using-style-setDataFormat-format-getFormat-0-0-

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-08 Thread Mark Beardsley
Is that Andy's (Andy Khan) JExcelAPI you are referring to? If so, then it is possible to create numeric cells there - using the jxl.write.Number class - and I would look to do this as a first step. It will make life a lot easier if the cells type is set correctly when the file is created IMO. That

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-08 Thread rakesh.dev
Hi Mark, We have actually created xls file using jxl API since it doesn't have some options for formatting we have reused the xls in POI API to get the formatting done. Thanks Rakesh -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Round-to-one-Decimal-place-not-happenni

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-08 Thread Mark Beardsley
Had a quick play and the idea of creating a new cell to replace the existing one will not change the cells type successfully, it reamains set as General despite everything I can do in POI code. So, I thought I would try a VBA macro - a macro can do anything the user can and it is a trivial task to

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-08 Thread rakesh.dev
Hi, somehow the cell type is still General even after setting the type to numeric as shownin code below. here i am setting decimal zero for some columns and one for some which is stored in string array. HSSFCellStyle stylezero = wb.createCellStyle(); HSSFDataFormat dfzero = wb.createDat

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-08 Thread Mark Beardsley
There is nothing that you can do about that I am afraid. Setting the cell explcitily to the numeric type in code has to be done so that the formatting object can be applied to it successfully; it is a slight of hand or trick if you will to force the formatting we want on the cell. Excel will still

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-03 Thread Mark Beardsley
Not too sure what you are asking here. Are you asking if it is possible to recover the formatted value from a cell as well as it's raw value using POI? If this is the case then the answer is yes. To make use of this, take a look at the HSSFDataFormatter class - http://poi.apache.org/apidocs/org/apa

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-03 Thread rakesh.dev
Thanks for the reply Mark. You suggestion on this works. Do we have any method in POI which works exactly as Decrease decimal functionality in excel. The cell should show value with decimal point reduced but if we click on the cell the formula bar should show the actual value. Thanks Rakesh -- Vi

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-03 Thread Mark Beardsley
Just for the sake of completness - and to correct an errorneous statement I made yesterday - I have been playing around with the code a little more. This is the minimu that will work successfully it seems; double value = cell.getNumericCellValue(); String strValue = decFormat.format(value); value

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-02 Thread Mark Beardsley
That proved to be a little more entertaining than I thought. Referring back to the code I posted before, this should do the trick; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package workbookprotection; import java.io.*; import java.util.*;

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-02 Thread Mark Beardsley
Have just had a look at your workbook and I think I understand the root of the problem. If you use Excel to open your workbook, click on one of the cells that holds a numeric value and then try to format it, Excel will report that the cell is not a numeric cell but is a General one. General cells

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-02 Thread rakesh.dev
Hi Mark, Thanks for the reply. I used the code for my excel but not getting reduced to one decimal place as given in the code. I am lost for options now. Thanks Rakesh -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Round-to-one-Decimal-place-not-happenning-using-styl

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-02 Thread Mark Beardsley
This morning, I had the opportunity to play with some code - lost my voice and am confined to the office - and both of these approaches works perfectly well for me. I am running Office 2007 under Windows XP and the code was compiled against an early beat release of version 3.8 of POI and using Java

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-02 Thread rakesh.dev
Hi Mark, Thank you for the response. Will remove the multiple set styles from the loop. I am looking for normal rounding behaviour as specified by you . Will attach the excel file for your reference where i am trying to convert column "S1" elements to one decimal place. http://apache-poi.1045710.n

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-02 Thread Mark Beardsley
Firstly, an observation. Do not create the cell styles like that; within the for loop I mean. If you do this, you will be creating multiple cell styles - possibly - all with the same name and properties. Ideally, you should create the style outside of the for loop and then apply it whenever you enc

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-01 Thread rakesh.dev
Hi Nick , please find the code i have written to convert the data in cells to one decimal place. for (int i=14;ihttp://apache-poi.1045710.n5.nabble.com/Round-to-one-Decimal-place-not-happenning-using-style-setDataFormat-format-getFormat-0-0-tp3404980p3406162.html Sent from the POI - User mailing

Re: Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-01 Thread Nick Burch
On Tue, 1 Mar 2011, rakesh.dev wrote: I have been working on rounding data to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); ". It is not working. How do you mean "not working"? Nick ---

Round to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); "

2011-03-01 Thread rakesh.dev
Hi, I have been working on rounding data to one Decimal place not happenning using " style.setDataFormat(format.getFormat("0.0")); ". It is not working. It would be great if someone could suggest me an alternative. Thanks Rakesh -- View this message in context: http://apache-poi.1045710.n5