set font into textbox string using jsp
In this program we are going create a box and
then after we pass the sting in the box. Finally we set the font for that
string.
Code description
The package we need to import is java.io.*,java.util.* ,org.apache.poi.hssf.usermodel.HSSFSheet,
org.apache.poi.hssf.usermodel.
HSSFPrintSetup, org.apache.poi.hssf.usermodel.HSSFTextbox, org.apache.poi.hssf.usermodel.HSSFRichTextString,
org.apache.poi.hssf.usermodel.HSSFPatriarch,
org.apache.poi.hssf.usermodel.HSSFClientAnchor, org.apache. poi.hssf.usermodel.
HSSFSimpleShape and org.apache.poi.hssf.usermodel.
HSSFWorkbook.
The method used in this example:
applyFont(HSSFFont font):
This method is used to sets the font of the entire string.The return type of
the method is void.
applyFont(int startIndex, int endIndex, HSSFFont font):
This method is used to applies a font to the specified range of a string.
applyFont(int startIndex, int endIndex, short fontIndex):
This method is used to applies a font to the specified characters of a string.
applyFont(short fontIndex):
This method is used to applies the specified font to the entire string.
createFont():
This method is used to create a new Font and add the font to the workbook,s font table.
In this example we are creating a sheet then we create the new font and add the
font into workbook's object after that we create an object of
patriarch after that we create textbox and create an object of string .We apply
the font on string and finally add it.
The code of the program is given below:
<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
|
The output of the program is given below: