• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

POI Question. Converting column numbers to excel column references.

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for taking the time to read my post.

Is there a way to convert a column number (say 1) to column
reference (A) using POI API's.

In others words, in excel you have column names A, B, C an so on.
I like to convert column numbers to the excel column names.

1 ---> A
2 ---> B
3 ---> C
..
..

Is there some API in POI to this?

I am using poi-2.5.1.

Any help will be really appreciated.

Thanks,
AJ
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do the data conversion in Java code before you pass them to POI.
 
Ajay Reddy
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This worked for me.

String s = String.valueOf((char) (columnCount + 64));
char [] charStr = new char[1];
charStr = s.toCharArray();

columnCount -- I loop through the columns in a for loop.

//strFormulas will be something like SUM(A1:A10)
String strFormulas =
"SUM(" + charStr[0] + "1:" + charStr[0] + rowCount + ")";
cellTotal.setCellFormula(strFormulas);

Hope people with the same problem can make use of this.

Ajay
 
reply
    Bookmark Topic Watch Topic
  • New Topic