• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help in excel data format

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing problem in writing different data formats to excel. Please check the code below:

colorStyleFactors.setDataFormat(df.getFormat("0.0000")); //for fraction data
colorStyleNumber.setDataFormat(df.getFormat("0")); // for numbers
colorStyleRateAreaName.setDataFormat(df.getFormat("TEXT")); // for text/strings

// to write text
rowCell = newRow.createCell((short) 0);
rowCell.setCellStyle(colorStyleRateAreaName);
rowCell.setCellValue(rateFactorForm.getRateAreaName());

//to write number
rowCell=null;
rowCell = newRow.createCell((short) 1);
rowCell.setCellStyle(colorStyleNumber);
rowCell.setCellValue(rateFactorForm.getRateAreaNo());

// to write fractions or decimal values
rowCell=null;
rowCell = newRow.createCell((short) 2);
//rowCell.setCellStyle(colorStyleFactors);
rowCell.setCellValue(rateFactorForm.getSubs());
after executing this, all the excel cells contains data format as TEXT!! i dont know why and even though i set different formats for each cell. And what i actually found is when i change the order like below(order changed for fractions and number format);

colorStyleNumber.setDataFormat(df.getFormat("0")); // for numbers
colorStyleRateAreaName.setDataFormat(df.getFormat("TEXT")); // for text/strings
colorStyleFactors.setDataFormat(df.getFormat("0.0000")); //for fraction data

i got all the cells data format as decimals!!! i mean the last one takes the preference and write to all the cells... why its happening like this??? Please help me with this.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post an SSCCE that demonstrates the problem.

Are you maybe reusing the colorStyle object?
 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, i will continue here only, actually i am working for a client and they are using the same api..





Ulf Dittmer wrote:Please post an SSCCE that demonstrates the problem.

Are you maybe reusing the colorStyle object?

 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using different colorstyle objects for each..


Nagaraj Shivaklara wrote:Okay, i will continue here only, actually i am working for a client and they are using the same api..





Ulf Dittmer wrote:Please post an SSCCE that demonstrates the problem.

Are you maybe reusing the colorStyle object?

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Please post an SSCCE that demonstrates the problem.

 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic