• 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

How to format a column not a cell in POI hssf

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to format a column not a cell. The only way I can figure out how to format a column is by formating each individual cell; by implementing the code listed below. I would like to format a column instead of a row. I am able format a column in excel. I have hundreds/thousands of rows of data to format. Any suggestions would be very much appreciated.

Thanks, Lisa

HSSFCellStyle cellStyle = wb.createCellStyle();
HSSFDataFormat dataFormat = wb.createDataFormat();
cellStyle.setDataFormat(dataFormat.getFormat("0.00"));

HSSFRow row = sheet.createRow(iRow);
HSSFCell cell = row.createCell((short)1);
cell.setCellStyle(cellStyle);
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a weakness of POI: it offers row-oriented functionality, but nothing that's column-oriented. But applying the same formatting for each cell in a column only takes a simple loop with 3 lines of code, so it shouldn't be too bad.
 
Lisa Zapson
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try to format cells in over 500 rows I get an Excel error and Excel removes some formatting to avoid corrupting the workbook.

If you have any other suggestions I would be very interested.

Thanks, Lisa
 
reply
    Bookmark Topic Watch Topic
  • New Topic