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
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:
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.
This method is used to applies the specified font to the entire string.
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:
The output of the program is given below:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: May 19, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles