Bug 62075 - XSSFCellStyle.BORDER_xxx not working
Summary: XSSFCellStyle.BORDER_xxx not working
Status: RESOLVED DUPLICATE of bug 61898
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.17-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: APIBug
Depends on:
Blocks:
 
Reported: 2018-02-04 16:38 UTC by si3012
Modified: 2018-02-12 06:09 UTC (History)
1 user (show)



Attachments
the code in Netbeans (122.06 KB, image/png)
2018-02-04 16:38 UTC, si3012
Details

Note You need to log in before you can comment on or make changes to this bug.
Description si3012 2018-02-04 16:38:40 UTC
Created attachment 35714 [details]
the code in Netbeans

HI, I am new in Java and I am using POI for the first time I get Problem with XSSFCellStyle.BORDER_XXX wich give me in The editor (Netbeans) cannot found the Symbol
please check the Attachement for more details.
PS : I am usisng tutorial from Busy' Developer's Guide to HSSF and XSSF Features

////////////////the Code/////////////////////////
package ExcelTo;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.sl.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import static org.apache.poi.ss.usermodel.FillPatternType.BIG_SPOTS;
import static org.apache.poi.ss.usermodel.FillPatternType.SOLID_FOREGROUND;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.WorkbookUtil;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
/**
 *
 * @author Jabida
 */
public class Depart {
    public static void main(String[] args) throws FileNotFoundException, IOException{
    Workbook wb = new XSSFWorkbook();
    org.apache.poi.ss.usermodel.Sheet sheet = wb.createSheet("Depart congé");
    // Create a row and put some cells in it. Rows are 0 based.
    Row row = sheet.createRow(1);
    // Create a cell and put a value in it.
    Cell cell = row.createCell(1);
    cell.setCellValue(4);
    // Style the cell with borders all around.
    CellStyle style = wb.createCellStyle();
    style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setLeftBorderColor(IndexedColors.GREEN.getIndex());
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setRightBorderColor(IndexedColors.BLUE.getIndex());
    style.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    cell.setCellStyle(style);
        try ( // Write the output to a file
                FileOutputStream fileOut = new FileOutputStream("workbook.xlsx")) {
            wb.write(fileOut);
            fileOut.close();
        }
        
    }
    
}
Comment 1 Alain Fagot Bearez 2018-02-04 19:44:47 UTC
The tutorial author should have taken the time to check the code is effectively compiling. This leaves serious doubts about the quality of the rest of the tutorial... 


The following line 

    style.setBorderBottom(XSSFCellStyle.BORDER_THIN);

should have been 

    style.setBorderBottom(CellStyle.BORDER_THIN);
Comment 2 Javen O'Neal 2018-02-05 01:30:52 UTC

*** This bug has been marked as a duplicate of bug 61898 ***
Comment 3 Javen O'Neal 2018-02-12 06:09:18 UTC
This was fixed in the Spreadsheet Quick Guide 8 weeks ago (13 Dec 2017) [1] and published 6 weeks ago (28 Dec 2017) [2]

[1] https://svn.apache.org/viewvc?view=revision&revision=1818054
[2] https://svn.apache.org/viewvc?view=revision&revision=1819416