Skip to main content

Basic object detection in python using OpenCv and Numpy - by Dustbiin

Styling the excel sheet data like font size, color, font family, and text alignment - by Dustbiin

Apache poi provide very powerful fetcher for data formation and changing the color, size and font family-



Create workspace and sheet-

XSSFWorkbook workBook = new XSSFWorkbook();
Sheet sheet = workBook.createSheet("My sheet");

Create Font object and set font styling-

Font font = workbook.createFont();
font.setBold( true );
font.setFontHeight( (short) ( 25 * 10 ) );
// set font family
font.setFontName("Courier New");
// set font color
font.setColor( IndexedColors.WHITE.getIndex() );

Create CellStyle object and set alignment of data in cell and set font to the data-

CellStyle cellStyle = new CellStyle();
cellStyle.setFont(font);
// use when you want to wrap text in multipal line
cellStyle.setWrapText(true);

Create Row and Cell and set cellStyle for the cell data-

XSSFRow row = sheet.createRow( 1 );
Cell cell = row.createCell(1);
cell.setCellValue("Hello World");
cell.setCellStyle(cellStyle);

Comments