Apply borders to cells in Excel using Apache POI in JAVA

0

I am using XSSFWorkbook to generate an Excel document (.xlsx), but, I have not managed to apply borders to the cells using:

XSSFCellStyle style3 = workbook.createCellStyle();
style3.setBorderBottom(XSSFCellStyle.BORDER_MEDIUM);
style3.setBorderTop(XSSFCellStyle.BORDER_MEDIUM);
style3.setBorderRight(XSSFCellStyle.BORDER_MEDIUM);
style3.setBorderLeft(XSSFCellStyle.BORDER_MEDIUM);

Error I receive:

  

BORDER_MEDIUM can not be resolved or is not a field

Libraries that I have imported:

import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

.jar's of my project:

  • commons-collections4-4.1
  • poi-3.17
  • poi-ooxml-3.17
  • poi-ooxml-schemas-3.17
  • xmlbeans-2.6.0
  • I'm missing some .jar , what? I have researched and I have not found a solution.

        
    asked by Robert Gomez 21.02.2018 в 03:30
    source

    1 answer

    1

    I think you're using old code with a newer version of poi.

    The api in the url: link Specifies that the method receives the enum BorderStyle

    import org.apache.poi.ss.usermodel.BorderStyle;
    
    style.setBorderBottom(BorderStyle.MEDIUM);
    
        
    answered by 21.02.2018 / 12:42
    source