import
java.io.FileNotFoundException;
import
java.io.FileOutputStream;
import
java.io.IOException;
import
org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import
org.apache.poi.hssf.usermodel.HSSFPatriarch;
import
org.apache.poi.hssf.usermodel.HSSFShape;
import
org.apache.poi.hssf.usermodel.HSSFSimpleShape;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook;
import
org.apache.poi.ss.usermodel.Sheet;
import
org.apache.poi.ss.usermodel.Workbook;
public
class
GFG {
public
static
void
main(String args[])
throws
IOException
{
String excelfilename =
"GFG.xls"
;
Workbook workbook =
new
HSSFWorkbook();
Sheet spreadsheet
= workbook.createSheet(
"XLDrawingShape"
);
HSSFPatriarch patriarch
= (HSSFPatriarch)
spreadsheet.createDrawingPatriarch();
HSSFClientAnchor anchor =
new
HSSFClientAnchor(
0
,
0
,
1023
,
255
, (
short
)
1
,
0
, (
short
)
5
,
4
);
HSSFSimpleShape shape
= patriarch.createSimpleShape(anchor);
shape.setShapeType(
HSSFSimpleShape.OBJECT_TYPE_OVAL);
shape.setLineStyleColor(
8
,
8
,
8
);
shape.setFillColor(
100
,
10
,
150
);
shape.setLineWidth(HSSFShape.LINEWIDTH_ONE_PT *
3
);
shape.setLineStyle(HSSFShape.LINESTYLE_DOTSYS);
try
{
FileOutputStream outputfile
=
new
FileOutputStream(excelfilename);
workbook.write(outputfile);
outputfile.close();
System.out.println(excelfilename
+
" is written successfully"
);
}
catch
(FileNotFoundException e) {
System.out.println(
"ERROR!! "
+ e.getMessage());
}
}
}