package
GFG_Maven.GFG_MAven;
import
org.testng.annotations.Test;
import
java.io.FileOutputStream;
import
java.io.IOException;
import
org.apache.poi.ss.usermodel.Cell;
import
org.apache.poi.ss.usermodel.FillPatternType;
import
org.apache.poi.ss.usermodel.IndexedColors;
import
org.apache.poi.ss.usermodel.Row;
import
org.apache.poi.ss.usermodel.WorkbookFactory;
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
Geeks {
@Test
public
void
geekforgeeks()
throws
IOException{
XSSFWorkbook workbook=
new
XSSFWorkbook();
XSSFSheet sheet=workbook.createSheet(
"sheet1"
);
XSSFRow row=sheet.createRow(
1
);
XSSFCellStyle style=workbook.createCellStyle();
style.setFillBackgroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
style.setFillPattern(FillPatternType.DIAMONDS);
XSSFCell cell=row.createCell(
1
);
cell.setCellValue(
"welcome"
);
cell.setCellStyle(style);
style=workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
style.setFillPattern(FillPatternType.FINE_DOTS);
cell=row.createCell(
2
);
cell.setCellValue(
"Geeks"
);
cell.setCellStyle(style);
FileOutputStream file =
new
FileOutputStream(
"C:\\Users\\ADMIN\\Desktop\\style.xlsx"
);
workbook.write(file);
file.close();
System.out.println(
"Style Created"
);
}
}