In this program we are going to make an excel sheet and
set the fonts of text values, set its size. We can also set the name of the
font.
The packages we need to import are java.io.*,java.util.* ,org.apache.poi.hssf.usermodel.HSSFSheet,org.apache.poi.
hssf. usermodel. HSSFCellStyle, org.apache.poi.usermodel.HSSFRow, org.apache.poi.usermodel.HSSFCell
, org.apache.poi.hssf.usermodel. HSSFWorkbook and org.apache.poi.hssf.usermodel.HSSFFont.
org.apache.poi.hssf.usermodel.HSSFFont class
extends java.lang.Object and is used to represent a font used in workbook.
This also provides various methods to set various font properties on
text.
In this example we are using following key points:
setFontHeightInPoints((short)value):
This method is used to set the height of the text.
setFontName("Courier New"):
This method is used to set the font name.
setItalic(true):
This method is used the to set text as Italic.
setStrikeout(true):
This method is used to set strikeout on text.
setFont(font):
This method is used to set font on cell style sheet.
The code of the program is given below:
<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
|
The output of the program is given below:


If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Working With Fonts View All Comments
Post your Comment