(1) The code you're asking for
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
// Creating all needed cellStyles
XSSFCellStyle noBottomGridLine = workbook.createCellStyle();
noBottomGridLine.setBorderBottom(BorderStyle.THIN);
noBottomGridLine.setBottomBorderColor(IndexedColors.WHITE.index);
XSSFCellStyle noTopGridLine = workbook.createCellStyle();
noTopGridLine.setBorderTop(BorderStyle.THIN);
noTopGridLine.setTopBorderColor(IndexedColors.WHITE.index);
XSSFCellStyle noVerticalGridLine = workbook.createCellStyle();
noVerticalGridLine.setBorderTop(BorderStyle.THIN);
noVerticalGridLine.setTopBorderColor(IndexedColors.WHITE.index);
noVerticalGridLine.setBorderBottom(BorderStyle.THIN);
noVerticalGridLine.setBottomBorderColor(IndexedColors.WHITE.index);
XSSFFont hlinkFont = workbook.createFont();
hlinkFont.setUnderline(Font.U_SINGLE);
hlinkFont.setColor(IndexedColors.BLUE.getIndex());
XSSFCellStyle hlinkStyle = workbook.createCellStyle();
hlinkStyle.setFont(hlinkFont);
XSSFCellStyle coloredStyle = workbook.createCellStyle();
coloredStyle.setFillForegroundColor(IndexedColors.RED.index);
coloredStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
XSSFCellStyle alignedText = workbook.createCellStyle();
alignedText.setVerticalAlignment(VerticalAlignment.TOP);
// Creating merged regions for columns one and two
sheet.addMergedRegion(new CellRangeAddress(0, 5, 0, 0));
sheet.addMergedRegion(new CellRangeAddress(0, 5, 1, 1));
// Removing gridlines from columns three four and five
for (int i = 2 ; i < 5 ; ++i) {
for (int j = 0 ; j < 6 ; ++j) {
XSSFRow r = sheet.getRow(j);
if (r == null) r = sheet.createRow(j);
if (j == 0) {
r.createCell(i, CellType.STRING).setCellStyle(noBottomGridLine);
} else if (j == 5){
r.createCell(i, CellType.STRING).setCellStyle(noTopGridLine);
} else {
r.createCell(i, CellType.STRING).setCellStyle(noVerticalGridLine);
}
}
}
// Resizing columns
for (int j = 0 ; j < 6 ; ++j) sheet.setColumnWidth(j, 125*50);
// First column
sheet.getRow(0).createCell(0, CellType.STRING).setCellValue("Name");
sheet.getRow(0).getCell(0).setCellStyle(alignedText);
// Second column
sheet.getRow(0).createCell(1, CellType.NUMERIC).setCellValue("112233");
sheet.getRow(0).getCell(1).setCellStyle(alignedText);
// Third column
XSSFCell hyperlinkCell = sheet.getRow(0).getCell(2);
hyperlinkCell.setCellValue("hyperlink text");
XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.URL);
hyperlink.setAddress("https://www.youtube.com/watch?v=mI_y8h22c_o");
hyperlinkCell.setHyperlink(hyperlink);
hyperlinkCell.setCellStyle(hlinkStyle);
XSSFCell backGroundColoredCell = sheet.getRow(2).getCell(2);
backGroundColoredCell.setCellValue("Colored Cell");
backGroundColoredCell.setCellStyle(coloredStyle);
// Fourth column
sheet.getRow(0).getCell(3).setCellValue("Team");
sheet.getRow(1).getCell(3).setCellValue("Title");
sheet.getRow(2).getCell(3).setCellValue("New Team");
sheet.getRow(3).getCell(3).setCellValue("New Team");
// Fifth column
sheet.getRow(0).getCell(4).setCellValue("Full Team description");
sheet.getRow(1).getCell(4).setCellValue("Full Title Description");
sheet.getRow(2).getCell(4).setCellValue("Origin");
sheet.getRow(3).getCell(4).setCellValue("Code");
// Saving Workbook
FileOutputStream outputStream = new FileOutputStream("D:\\Desktop\\test-excel.xlsx");
workbook.write(outputStream);
workbook.close();
outputStream.close();
Output:


(2) A short guide about XSSFCells customization
- Formatted text inside cells
- Colored text inside cells
- Colored cells' background
- Hyperlinks
- Merging a group of cells into a single one
- Removing cells' gridlines (a little trick)
When using .xlsx excel file (which means using XSSF Apache Poi Objects, have a look at this post for differences between XSSF and HSSF Apache Poi Objects) you can use XSSFRichTextString in order to fill an XSSFCell with some formatted text. With XSSFRichTextString you can both append new text which is associated with a custom XSSFFont and use \n character to start a new line (if you've called CellStyle#setWrapTest(true) on the XSSFCellStyle of your XSSFCell as is discussed here).
Here it is an example:
XSSFRichTextString richValue = new XSSFRichTextString();
XSSFFont italicBoldFont = workbook.createFont();
italicBoldFont.setBold(true);
italicBoldFont.setItalic(true);
XSSFFont onlyBoldFont = workbook.createFont();
onlyBoldFont.setBold(true);
richValue.append("First text", italicBoldFont);
richValue.append("\nSecond text", onlyBoldFont);
XSSFCell cell = workbook.getSheetAt(0).createRow(0).createCell(0, CellType.STRING);
XSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setWrapText(true);
cell.setCellStyle(cellStyle);
cell.setCellValue(richValue);

Using XSSFColor in order to change the text color may be a little more tricky (some useful hints here and here), here it is an example:
XSSFRichTextString richValue = new XSSFRichTextString();
XSSFFont coloredFont = workbook.createFont();
coloredFont.setColor(IndexedColors.BLUE1.index);
richValue.append("Colored text", coloredFont);
workbook.getSheetAt(0).createRow(0).createCell(0, CellType.STRING).setCellValue(richValue);

If you want to change the color background, you can only change the color background of an entire XSSFCell. In order to do that use a custom XSSFCellStyle as it's shown here. Here it is an example:
XSSFCell cell = workbook.getSheetAt(0).createRow(0).createCell(0, CellType.STRING);
XSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(IndexedColors.DARK_RED.index);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(cellStyle);
cell.setCellValue("Some text");

In order to add an hyperlink, the only way is to create a XSSFCell which contains only that hyperlink. You have to use the XSSFHyperlink Java Object and the XSSFCell#setHyperlink(Hyperlink hyperlink) method. Here it is an example:
XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.URL);
hyperlink.setAddress("https://www.youtube.com/watch?v=mI_y8h22c_o");
XSSFCell cell = workbook.getSheetAt(0).createRow(0).createCell(0, CellType.STRING);
cell.setHyperlink(hyperlink);
cell.setCellValue("Click here to open cute video");

If you want an highlighted hyperlink:
XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.URL);
hyperlink.setAddress("https://www.youtube.com/watch?v=mI_y8h22c_o");
XSSFCellStyle hlinkStyle = workbook.createCellStyle();
XSSFFont hlinkFont = workbook.createFont();
hlinkFont.setUnderline(Font.U_SINGLE);
hlinkFont.setColor(IndexedColors.BLUE.getIndex());
hlinkStyle.setFont(hlinkFont);
XSSFCell cell = workbook.getSheetAt(0).createRow(0).createCell(0, CellType.STRING);
cell.setHyperlink(hyperlink);
cell.setCellValue("Click here to open cute video");
cell.setCellStyle(hlinkStyle);

If you want to merge some XSSFCell toghether into a single one, use the method XSSFSheet#addMergedRegion(CellRangeAddress region) as follows
sheet.addMergedRegion(new CellRangeAddress(1, 1, 1, 2));
where CellRangeAddress constructor requires int firstRow, int lastRow, int firstCol, int lastCol.
If you want to remove all gridlines from your XSSFSheet, use XSSFSheet#setDisplayGridlines(boolean show). If you want to remove gridlines from a specific XSSFCell, you have to use a trick like that (take advantage of XSSFCellStyle once again)(this is the only possible way using Apache Poi):
XSSFCellStyle noUpGridlines = workbook.createCellStyle();
noUpGridlines.setBorderTop(BorderStyle.THIN);
noUpGridlines.setTopBorderColor(IndexedColors.WHITE.index);
XSSFCell cell = workbook.getSheetAt(0).createRow(60).createCell(1, CellType.STRING);
cell.setCellStyle(noUpGridlines);
cell.setCellValue("Oh no, where is my top gridline?");
