Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Generation of CSV by servlet  RSS feed

 
sandeep Kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

Can any one help me regarding the generation of an Excel(CSV) file with the help of a Servlet? I wanted to make the font to bold in the generated csv file for one row.

I have set the contentType of the response object to "text/csv"
and also set the response header 'Content-disposition' to value
"attachment; filename=<myFilename>.csv" . the excel sheet is generated as required. But I wanted to make one of the rows to bold. Can any one please help in in this regard?

Thanks in advance for the response.

Thanks,
Sandeep.
 
Evelin Priyadarsini
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i think you can use similar kind.

HSSFFont boldFont = workBook.createFont();
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
boldFont.setColor(HSSFColor.WHITE.index);

HSSFCellStyle headerStyle = workBook.createCellStyle();
headerStyle.setFont(boldFont);
using setCellStyle(headerStyle); you can set the style
 
Evelin Priyadarsini
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, i think my above reply will not solve your problem.
i thought you want to manipulate data to excel sheet.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CSV just means comma separated values.
There really is no mechanism for formatting the data.

If you need your spreadsheets to have a particular look, you might want to look into some of the third party libraries that can work with real Excel files.

Some of these are listed here.
 
sandeep Kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks Evelin Priyadarsini and Ben Souther. Thanks a lot for giving inputs on this.

Cheers,
Sandeep.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!