import
java.io.File;
import
java.io.FileOutputStream;
import
org.apache.poi.xssf.usermodel.XSSFCell;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle;
import
org.apache.poi.xssf.usermodel.XSSFRow;
import
org.apache.poi.xssf.usermodel.XSSFSheet;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook;
public
class
workbook {
public
static
void
main(String[] args)
throws
Exception
{
XSSFWorkbook wb =
new
XSSFWorkbook();
XSSFSheet sheet = wb.createSheet(
"sheet1"
);
XSSFRow r1 = sheet.createRow(
0
);
XSSFCell r1c1 = r1.createCell(
0
);
r1c1.setCellValue(
"Name"
);
XSSFCell r1c2 = r1.createCell(
1
);
r1c2.setCellValue(
"Age"
);
XSSFCellStyle style = wb.createCellStyle();
XSSFCellStyle style1 = wb.createCellStyle();
style.setRotation((
short
)
20
);
style1.setRotation((
short
)
30
);
XSSFRow r2 = sheet.createRow(
1
);
XSSFCell r2c1 = r2.createCell(
0
);
r2c1.setCellValue(
"GFG"
);
r2c1.setCellStyle(style);
XSSFCell r2c2 = r2.createCell(
1
);
r2c2.setCellValue(
"10"
);
r2c2.setCellStyle(style1);
FileOutputStream out =
new
FileOutputStream(
new
File(
"D:/sheet.xlsx"
));
wb.write(out);
out.close();
}
}