Create Excel with Java format text

When I download Excel, I get cells with format Numbers I need format text en all Cells.
try {
            XSSFSheet sheet = workbook.createSheet(eyelash);

            XSSFFont font = workbook.createFont();
            font.setColor(HSSFColor.WHITE.index);
            XSSFCellStyle style = workbook.createCellStyle();
            style.setFont(font);
            style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            style.setFillForegroundColor(HSSFColor.RED.index);


            String[] header = { "name","surname"},
                    "Ceco", "Volumen" };
            XSSFRow rowhead = sheet.createRow((short) 0);
            XSSFCell cell;
            int cellnum = 0;

            for (int i = 0; i < header.length; i++) {
                cell = rowhead.createCell(cellnum);
                cell.setCellValue(header[i]);
                cell.setCellStyle(style);
                cell.setCellType(XSSFCell.CELL_TYPE_STRING);
                cellnum++;
            }

            if (data) {
                int myRowData = 1;
                XSSFRow row = sheet.createRow((short) myRowData);
                ArrayList<GasNomination> list = mlService.selectAllGasNomination();

                for (int i = 0; i < list.size(); i++) {

                    row.createCell(0).setCellValue(list.get(i).name());
                    row.createCell(1).setCellValue(list.get(i).surname());

                    myRowData++;
                    row = sheet.createRow((short) myRowData);
                }
            }

        } catch (Exception ex) {

        }
I tried cell.setCellType(XSSFCell.CELL_TYPE_STRING); But when I open my Excel I see formatcell type numeric ...

Комментарии

Популярные сообщения из этого блога

Unable to construct Application instance [duplicate]

What is considered 'insulting a Muslim'? And is it a sin? If so, is it a minor or major scene?