Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

POI problem-How to avoid green flags while writing number strings to Excel

843838Oct 28 2005
Hi all,
Actully i hv an issue with POI. I am passing the negative numbers as strings to a servlet from jsp. From servlet im writing it into a excel file.Some negative numbers include "1000 seperator" also. But i am getting the numbers in excel sheet as strings only.Also it showing one GREEN FLAG along with each cell. Flag message is that "NUMBER STORED AS TEXT". Before writing into the excel i am converting the strings to double using parseDouble function. But still i am getting the same error.. I have included the code also.

// negative numbers are passing as a string.
/Eg: (123,456,789,56) or (789.56) ..eachElement varible contains each
//string which contains numbers

HSSFCell cell;

if(eachElement.startsWith("("))
{
String temp=eachElement.substring(1,eachElement.indexOf(")"));
//chking the string contains " 1000 seperator" .If i am removing it
//and converting to double and writing it into the cell.
if(temp.indexOf(",")!=-1)
{
StringTokenizer st=new StringTokenizer(temp,",");
String output = new String();
while(st.hasMoreTokens()) {
output=output.concat(st.nextToken());
}
double dvalue=Double.parseDouble(output);
cell.setCellValue(dvalue);
}
else
{
//converting the string which is not having "1000 seperator"
// to double & writing it into cell
double dvalue=Double.parseDouble(temp);
cell.setCellValue(eachElement.trim());
}

THE PROBLEM IS THAT AFTER DOING ALL THESE I AM STILL GETTING THE ERROR ......."A GREEN FLAG WITH EACH CELL ".

HOPE ALL OF YOU GOT MY PROBLEM. PLZ REPLY ME SOON.

Thanks in Advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 25 2005
Added on Oct 28 2005
0 comments
296 views