Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp Poi filling oval color in excel using jsp

Related Tutorials


 
 

Share on Google+Share on Google+

filling oval color in excel using jsp

Advertisement
In this program we are going create a sheet and then after we create a oval and fill color into oval.

filling oval color in excel using jsp

     

In this program we are going create a sheet  and then after we create a oval and fill color into oval. 

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.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 shift row

setFillColor(Color color):
This method is used to fill the color of the shap.

In this example we are creating the sheet and an oval and at last we fill the color of the oval by using setFillColor().The output display as shown below. 
 The code of the program is given below:

<%page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%page import="org.apache.poi.hssf.usermodel.HSSFPrintSetup"%>
<%page import="org.apache.poi.hssf.usermodel.HSSFPatriarch"%>
<%page import="org.apache.poi.hssf.usermodel.HSSFClientAnchor"%>
<%page import="org.apache.poi.hssf.usermodel.HSSFSimpleShape"%>
<%page contentType="application/vnd.ms-excel" %>
<%page import="java.io.*" %>
<%page import="java.util.*" %>
<%
try{
  HSSFWorkbook hwb = new HSSFWorkbook();
  HSSFSheet sheet = hwb.createSheet("new sheet");
  HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
  HSSFClientAnchor a = new HSSFClientAnchor
001023255(short10(short1);
  HSSFSimpleShape shape1 = patriarch.createSimpleShape(a);
  shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL);
  shape1.setFillColor(90,10,200);
  FileOutputStream fileOut = new FileOutputStream
(
"c:\\excel\\fillColorOval.xls");
  hwb.write(fileOut);
  fileOut.close();  
  out.println("Your excel file has been generated");
  
  catch Exception ex ) {
  
  }%>

The output of the program is given below:

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 25, 2008

Related Tutorials

Discuss: filling oval color in excel using jsp   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com