On 13 Jan, 14:56, Sylvain Cuaz <[email protected]> wrote: > Merover a crit : > > > Hi > > Hi, > > > I am using jOpenDocument to retrieve values from a large number of ods > > files. One of the values in each file > > is a part number which in some cases returns as a string and in some > > other cases returns as a float. > > Can you please send your file, this usually means that some of your > cells have the wrong type (i.e. Number instead of String).
Yes, this is exactly the problem. But the files I have is already there (over 1000 of them) and they are what they are. I made a macro in oo however that converted all of the part numbers to string with this oobasic code: -------------- If iCell.Type=com.sun.star.table.CellContentType.VALUE then iCell.String = iCell.getFormula end if ---------- so my problem is gone for now. However, if someone is making a new file and just enter a part number with only digits then the problem will occur again. And there are of course occasions when you need more precision than a float has. I really think that numbers should return as double to prevent the problem. > > > If > > it returns as a float I have problems with the precision. For example, > > if the part number is 60001399 it will return as > > 6.00014E+7 which if I convert it to a string results in 60001400. Any > > ideas what I can do about it? I have tried to > > return it into a double but that's only giving me an cast exception. > > If that's what I think it is, you should just have to tell OpenOffice > to treat your cells as text. Anyway there's a new method in svn to > retrieve the text value of any cell : getTextValue(). > That sounds great. I'm looking forward to the next version. /M > > Thanks for an otherwise great library. This small project of mine > > wouldn't be possible without it. > > > /M > > Thanks > > Cheers, > Sylvain
