Example usage for org.apache.poi.xssf.usermodel XSSFCellStyle setFont

List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle setFont

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFCellStyle setFont.

Prototype

@Override
public void setFont(Font font) 

Source Link

Document

Set the font for this style

Usage

From source file:com.sec.ose.osi.report.standard.CoverSheetTemplate.java

License:Open Source License

protected XSSFCellStyle getCellStyle(int border, Font font) {
    XSSFCellStyle style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setWrapText(true); // new line

    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());

    if ((border & BORDER_BOTTOM) > 0)
        style.setBorderBottom(CellStyle.BORDER_DOUBLE);
    else//from w  ww .j  a  v  a  2 s  .  c om
        style.setBorderBottom(CellStyle.BORDER_THIN);

    if ((border & BORDER_LEFT) > 0)
        style.setBorderLeft(CellStyle.BORDER_DOUBLE);
    else
        style.setBorderLeft(CellStyle.BORDER_THIN);

    if ((border & BORDER_RIGHT) > 0)
        style.setBorderRight(CellStyle.BORDER_DOUBLE);
    else
        style.setBorderRight(CellStyle.BORDER_THIN);

    if ((border & BORDER_TOP) > 0)
        style.setBorderTop(CellStyle.BORDER_DOUBLE);
    else
        style.setBorderTop(CellStyle.BORDER_THIN);

    if (font != null)
        style.setFont(font);

    return style;
}

From source file:com.sec.ose.osi.report.standard.ISheetTemplate.java

License:Open Source License

/**
 * @param color//w ww  . ja va  2s  .  c o m
 * @param font
 * @return CellStyle
 */
protected XSSFCellStyle getCellStyle(XSSFColor color, Font font) {
    XSSFCellStyle style = wb.createCellStyle();
    style.setFillForegroundColor(color);
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setWrapText(true); // new line

    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());

    if (font != null)
        style.setFont(font);

    return style;
}

From source file:com.tikal.tallerWeb.servicio.reporte.cliente.AbstractSeccionXLS.java

License:Apache License

public void addHeaderStyle(XSSFCellStyle cellStyle, XSSFWorkbook wb) {
    cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    //        cellStyle.setFillForegroundColor(new XSSFColor(new Color(85, 142, 213)));
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    XSSFFont font = wb.createFont();//from  w  w w .  j  av a  2  s .  co  m
    font.setColor(IndexedColors.WHITE.getIndex());
    font.setBold(true);
    cellStyle.setFont(font);
}

From source file:com.tikal.tallerWeb.servicio.reporte.cliente.CostoHojalateriaReporteCliente.java

License:Apache License

@Override
public BordeSeccion generar(BordeSeccion borde, ContextoSeccion contexto, ReporteCliente datos) {
    Sheet sheet = contexto.getSheet();/*  w  w w  .  ja  va  2s  .co  m*/
    XSSFWorkbook wb = contexto.getWb();
    int initialRow = borde.getUpperRow();
    int initialColumn = borde.getLeftColumn();
    BordeSeccion r = new BordeSeccion();
    r.setLeftColumn(initialColumn);
    r.setUpperRow(initialRow);

    Cell cell;
    Row row = getRow(sheet, initialRow);
    cell = row.createCell(initialColumn);
    cell.setCellValue("Hojalteria y pintura");
    XSSFCellStyle cellStyle = wb.createCellStyle();
    addHeaderStyle(cellStyle, wb);
    addBorders(wb, cellStyle, CellStyle.BORDER_MEDIUM);
    cell.setCellStyle(cellStyle);
    for (int i = 1; i < 3; i++) {
        cell = row.createCell(initialColumn + i);
        cellStyle = wb.createCellStyle();
        addBorders(wb, cellStyle, CellStyle.BORDER_MEDIUM);
        cell.setCellStyle(cellStyle);
    }
    //merge de celdas
    sheet.addMergedRegion(new CellRangeAddress(initialRow, //first row (0-based)
            initialRow, //last row  (0-based)
            initialColumn, //first column (0-based)
            initialColumn + 2 //last column  (0-based)
    ));

    //detalle
    cellStyle = wb.createCellStyle();
    XSSFDataFormat df = wb.createDataFormat();
    cellStyle.setDataFormat(df.getFormat("$#,##0.00"));
    Cell inicio = null;
    Cell fin = null;
    for (RegistroCostoRC x : datos.getRegistroHojalateriaPintura()) {
        initialRow = initialRow + 1;
        row = getRow(sheet, initialRow);
        //tipo
        cell = row.createCell(initialColumn);
        cell.setCellValue(x.getTipo());
        //descripcion
        cell = row.createCell(initialColumn + 1);
        cell.setCellValue(x.getDescripcion());
        //costo
        cell = row.createCell(initialColumn + 2);
        cell.setCellValue(x.getCosto());
        cell.setCellStyle(cellStyle);
        if (inicio == null) {
            inicio = cell;
        }
    }
    if (inicio != null) {
        fin = cell;
    }
    initialRow = initialRow + 1;
    row = getRow(sheet, initialRow);
    cell = row.createCell(initialColumn + 1);
    cell.setCellValue("Total");
    cellStyle = wb.createCellStyle();
    XSSFFont font = wb.createFont();
    font.setBold(true);
    cellStyle.setFont(font);
    cell.setCellStyle(cellStyle);

    cellStyle = wb.createCellStyle();
    cellStyle.setFont(font);
    cellStyle.setDataFormat(df.getFormat("$#,##0.00"));
    cell = row.createCell(initialColumn + 2);
    cell.setCellStyle(cellStyle);
    if (inicio != null) {
        String formula = "SUM(" + getSimpleReference(inicio) + ":" + getSimpleReference(fin) + ")";
        cell.setCellFormula(formula);
        contexto.put("totalHojalateria", cell);
    } else {
        cell.setCellValue(0.0);
    }
    r.setLowerRow(initialRow);
    r.setRightColumn(initialColumn + 2);
    BordeSeccion sinTotal = new BordeSeccion(r);
    sinTotal.setLowerRow(r.getLowerRow() - 1);
    paintBorder(wb, sheet, CellStyle.BORDER_MEDIUM, sinTotal);
    return r;
}

From source file:com.tikal.tallerWeb.servicio.reporte.cliente.CostoMecanicaReporteCliente.java

License:Apache License

@Override
public BordeSeccion generar(BordeSeccion borde, ContextoSeccion contexto, ReporteCliente datos) {
    Sheet sheet = contexto.getSheet();//w  w w.  jav a 2  s . com
    XSSFWorkbook wb = contexto.getWb();
    int initialRow = borde.getUpperRow();
    int initialColumn = borde.getLeftColumn();
    BordeSeccion r = new BordeSeccion();
    r.setLeftColumn(initialColumn);
    r.setUpperRow(initialRow);

    Cell cell;
    Row row = getRow(sheet, initialRow);
    cell = row.createCell(initialColumn);
    cell.setCellValue("Mecanica");
    XSSFCellStyle cellStyle = wb.createCellStyle();
    addHeaderStyle(cellStyle, wb);
    addBorders(wb, cellStyle, CellStyle.BORDER_MEDIUM);
    cell.setCellStyle(cellStyle);
    for (int i = 1; i < 3; i++) {
        cell = row.createCell(initialColumn + i);
        cellStyle = wb.createCellStyle();
        addBorders(wb, cellStyle, CellStyle.BORDER_MEDIUM);
        cell.setCellStyle(cellStyle);
    }
    //merge de celdas
    sheet.addMergedRegion(new CellRangeAddress(initialRow, //first row (0-based)
            initialRow, //last row  (0-based)
            initialColumn, //first column (0-based)
            initialColumn + 2 //last column  (0-based)
    ));

    //detalle
    cellStyle = wb.createCellStyle();
    XSSFDataFormat df = wb.createDataFormat();
    cellStyle.setDataFormat(df.getFormat("$#,##0.00"));
    Cell inicio = null;
    Cell fin = null;
    for (RegistroCostoRC x : datos.getRegistroMecanica()) {
        initialRow = initialRow + 1;
        row = getRow(sheet, initialRow);
        //tipo
        cell = row.createCell(initialColumn);
        cell.setCellValue(x.getTipo());
        //descripcion
        cell = row.createCell(initialColumn + 1);
        cell.setCellValue(x.getDescripcion());
        //costo
        cell = row.createCell(initialColumn + 2);
        cell.setCellValue(x.getCosto());
        cell.setCellStyle(cellStyle);
        if (inicio == null) {
            inicio = cell;
        }
    }
    if (inicio != null) {
        fin = cell;
    }
    initialRow = initialRow + 1;
    row = getRow(sheet, initialRow);
    cell = row.createCell(initialColumn + 1);
    cell.setCellValue("Total");
    cellStyle = wb.createCellStyle();
    XSSFFont font = wb.createFont();
    font.setBold(true);
    cellStyle.setFont(font);
    cell.setCellStyle(cellStyle);

    cellStyle = wb.createCellStyle();
    cellStyle.setFont(font);
    cellStyle.setDataFormat(df.getFormat("$#,##0.00"));
    cell = row.createCell(initialColumn + 2);
    cell.setCellStyle(cellStyle);
    if (inicio != null) {
        String formula = "SUM(" + getSimpleReference(inicio) + ":" + getSimpleReference(fin) + ")";
        cell.setCellFormula(formula);
        contexto.put("totalMecanica", cell);
    } else {
        cell.setCellValue(0.0);
    }
    r.setLowerRow(initialRow);
    r.setRightColumn(initialColumn + 2);
    BordeSeccion sinTotal = new BordeSeccion(r);
    sinTotal.setLowerRow(r.getLowerRow() - 1);
    paintBorder(wb, sheet, CellStyle.BORDER_MEDIUM, sinTotal);
    return r;
}

From source file:contestTabulation.Setup.java

License:Open Source License

@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    HttpTransport httpTransport = new NetHttpTransport();
    JacksonFactory jsonFactory = new JacksonFactory();
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    Entity contestInfo = Retrieve.contestInfo();

    GoogleCredential credential = new GoogleCredential.Builder().setJsonFactory(jsonFactory)
            .setTransport(httpTransport)
            .setClientSecrets((String) contestInfo.getProperty("OAuth2ClientId"),
                    (String) contestInfo.getProperty("OAuth2ClientSecret"))
            .build().setFromTokenResponse(new JacksonFactory().fromString(
                    ((Text) contestInfo.getProperty("OAuth2Token")).getValue(), GoogleTokenResponse.class));

    String docName = null, docLevel = null;
    for (Level level : Level.values()) {
        docName = req.getParameter("doc" + level.getName());
        if (docName != null) {
            docLevel = level.toString();
            break;
        }/*from   w  w  w.j  a v a 2s.c  o m*/
    }

    if (docLevel == null) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
                "Spreadsheet creation request must have paramater document name parameter set");
        return;
    }

    Query query = new Query("registration")
            .setFilter(new FilterPredicate("schoolLevel", FilterOperator.EQUAL, docLevel))
            .addSort("schoolName", SortDirection.ASCENDING);
    List<Entity> registrations = datastore.prepare(query).asList(FetchOptions.Builder.withDefaults());

    Map<String, List<JSONObject>> studentData = new HashMap<String, List<JSONObject>>();
    for (Entity registration : registrations) {
        String regSchoolName = ((String) registration.getProperty("schoolName")).trim();
        String regStudentDataJSON = unescapeHtml4(((Text) registration.getProperty("studentData")).getValue());

        JSONArray regStudentData = null;
        try {
            regStudentData = new JSONArray(regStudentDataJSON);
        } catch (JSONException e) {
            e.printStackTrace();
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
            return;
        }

        for (int i = 0; i < regStudentData.length(); i++) {
            if (!studentData.containsKey(regSchoolName)) {
                studentData.put(regSchoolName, new ArrayList<JSONObject>());
            }
            try {
                studentData.get(regSchoolName).add(regStudentData.getJSONObject(i));
            } catch (JSONException e) {
                resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                e.printStackTrace();
                return;
            }
        }
    }

    for (List<JSONObject> students : studentData.values()) {
        Collections.sort(students, new Comparator<JSONObject>() {
            @Override
            public int compare(JSONObject a, JSONObject b) {
                try {
                    return a.getString("name").compareTo(b.getString("name"));
                } catch (JSONException e) {
                    e.printStackTrace();
                    return 0;
                }
            }
        });
    }

    Workbook workbook = new XSSFWorkbook();

    XSSFCellStyle boldStyle = (XSSFCellStyle) workbook.createCellStyle();
    Font boldFont = workbook.createFont();
    boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    boldStyle.setFont(boldFont);

    Map<Subject, XSSFCellStyle> subjectCellStyles = new HashMap<Subject, XSSFCellStyle>();
    for (Subject subject : Subject.values()) {
        final double ALPHA = .144;
        String colorStr = (String) contestInfo.getProperty("color" + subject.getName());
        byte[] backgroundColor = new byte[] { Integer.valueOf(colorStr.substring(1, 3), 16).byteValue(),
                Integer.valueOf(colorStr.substring(3, 5), 16).byteValue(),
                Integer.valueOf(colorStr.substring(5, 7), 16).byteValue() };
        // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
        byte[] borderColor = new byte[] { (byte) ((backgroundColor[0] & 0xff) * (1 - ALPHA)),
                (byte) ((backgroundColor[1] & 0xff) * (1 - ALPHA)),
                (byte) ((backgroundColor[2] & 0xff) * (1 - ALPHA)) };

        XSSFCellStyle style = (XSSFCellStyle) workbook.createCellStyle();
        style.setFillBackgroundColor(new XSSFColor(backgroundColor));
        style.setFillPattern(CellStyle.ALIGN_FILL);

        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBottomBorderColor(new XSSFColor(borderColor));
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setTopBorderColor(new XSSFColor(borderColor));
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setRightBorderColor(new XSSFColor(borderColor));
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setLeftBorderColor(new XSSFColor(borderColor));
        subjectCellStyles.put(subject, style);
    }

    Entry<String, List<JSONObject>>[] studentDataEntries = studentData.entrySet().toArray(new Entry[] {});
    Arrays.sort(studentDataEntries, Collections.reverseOrder(new Comparator<Entry<String, List<JSONObject>>>() {
        @Override
        public int compare(Entry<String, List<JSONObject>> arg0, Entry<String, List<JSONObject>> arg1) {
            return Integer.compare(arg0.getValue().size(), arg1.getValue().size());
        }
    }));

    for (Entry<String, List<JSONObject>> studentDataEntry : studentDataEntries) {
        Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(studentDataEntry.getKey()));
        Row row = sheet.createRow((short) 0);

        String[] columnNames = { "Name", "Grade", "N", "C", "M", "S" };
        for (int i = 0; i < columnNames.length; i++) {
            String columnName = columnNames[i];
            Cell cell = row.createCell(i);
            cell.setCellValue(columnName);
            cell.setCellStyle(boldStyle);
            CellUtil.setAlignment(cell, workbook, CellStyle.ALIGN_CENTER);
        }

        int longestNameLength = 7;
        int rowNum = 1;
        for (JSONObject student : studentDataEntry.getValue()) {
            try {
                row = sheet.createRow((short) rowNum);
                row.createCell(0).setCellValue(student.getString("name"));
                row.createCell(1).setCellValue(student.getInt("grade"));

                for (Subject subject : Subject.values()) {
                    String value = student.getBoolean(subject.toString()) ? "" : "X";
                    Cell cell = row.createCell(Arrays.asList(columnNames).indexOf(subject.toString()));
                    cell.setCellValue(value);
                    cell.setCellStyle(subjectCellStyles.get(subject));
                }

                if (student.getString("name").length() > longestNameLength) {
                    longestNameLength = student.getString("name").length();
                }

                rowNum++;
            } catch (JSONException e) {
                e.printStackTrace();
                resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
                return;
            }
        }

        sheet.createFreezePane(0, 1, 0, 1);
        // sheet.autoSizeColumn((short) 0); Not supported by App Engine
        sheet.setColumnWidth((short) 0, (int) (256 * longestNameLength * 1.1));
    }

    Drive drive = new Drive.Builder(httpTransport, jsonFactory, credential)
            .setApplicationName("contestTabulation").build();

    File body = new File();
    body.setTitle(docName);
    body.setMimeType("application/vnd.google-apps.spreadsheet");

    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    workbook.write(outStream);
    ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
    InputStreamContent content = new InputStreamContent(
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", inStream);

    drive.files().insert(body, content).execute();
    workbook.close();
}

From source file:coverageqc.functions.MyExcelEditor.java

private static XSSFCellStyle getDefaultCellStyle(XSSFRow currentRow) {

    XSSFCellStyle cellStyle = currentRow.getSheet().getWorkbook().createCellStyle();

    cellStyle.setWrapText(true);//  w ww. ja  v  a 2  s .c o m
    cellStyle.setBorderBottom(cellStyle.BORDER_THIN);
    cellStyle.setBorderLeft(cellStyle.BORDER_THIN);
    cellStyle.setBorderRight(cellStyle.BORDER_THIN);
    cellStyle.setBorderTop(cellStyle.BORDER_THIN);
    XSSFFont myFont = currentRow.getSheet().getWorkbook().createFont();
    myFont.setFontHeight(9);
    cellStyle.setFont(myFont);
    cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    cellStyle.setFillForegroundColor(new XSSFColor(Color.white));
    return cellStyle;
}

From source file:coverageqc.functions.MyExcelEditor.java

private static XSSFCellStyle getGrayCellStyle(XSSFRow currentRow) {

    XSSFCellStyle cellStyle = currentRow.getSheet().getWorkbook().createCellStyle();

    cellStyle.setWrapText(true);/* ww w .  java2  s.  co m*/
    cellStyle.setBorderBottom(cellStyle.BORDER_THIN);
    cellStyle.setBorderLeft(cellStyle.BORDER_THIN);
    cellStyle.setBorderRight(cellStyle.BORDER_THIN);
    cellStyle.setBorderTop(cellStyle.BORDER_THIN);
    XSSFFont myFont = currentRow.getSheet().getWorkbook().createFont();
    myFont.setFontHeight(9);
    cellStyle.setFont(myFont);
    cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    cellStyle.setFillForegroundColor(new XSSFColor(Color.gray));
    return cellStyle;
}

From source file:coverageqc.functions.MyExcelGenerator.java

private XSSFCellStyle getDefaultCellStyle(XSSFRow currentRow, Color specifiedColor) {

    XSSFCellStyle cellStyle = currentRow.getSheet().getWorkbook().createCellStyle();

    cellStyle.setWrapText(true);//from ww w.  ja  v  a  2  s.c  o  m
    cellStyle.setBorderBottom(cellStyle.BORDER_THIN);
    cellStyle.setBorderLeft(cellStyle.BORDER_THIN);
    cellStyle.setBorderRight(cellStyle.BORDER_THIN);
    cellStyle.setBorderTop(cellStyle.BORDER_THIN);
    XSSFFont myFont = currentRow.getSheet().getWorkbook().createFont();
    myFont.setFontHeight(9);
    cellStyle.setFont(myFont);
    cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    cellStyle.setFillForegroundColor(new XSSFColor(specifiedColor));
    return cellStyle;
}

From source file:Dao.XlsBillDao.java

public void GenFullXLS(String pono, String relpath) {
    try {//w w  w. ja  va 2s .  c  o  m
        //0.Declare Variables for Sheet
        //DB Variable
        //            pono = "WO/2015/2005";
        //XLS Variable
        XSSFSheet spreadsheet;
        XSSFWorkbook workbook;
        XSSFRow row;
        XSSFCell cell;
        XSSFFont xfont = null;
        XSSFCellStyle xstyle = null;

        //1.Get Connection and Fetch Data
        ArrayList<WorkItemBean> wi1 = new ArrayList<WorkItemBean>();
        WorkDao wdao1 = new WorkDao();
        wi1 = wdao1.getWOItem(pono);

        //2.Create WorkBook and Sheet
        workbook = new XSSFWorkbook();
        spreadsheet = workbook.createSheet("WorkOrder Detail");

        //   spreadsheet.protectSheet("kandarpCBA");
        //        spreadsheet.setColumnWidth(0, 255);
        //set header style
        xfont = workbook.createFont();
        xfont.setFontHeight(11);
        xfont.setFontName("Calibri");
        xfont.setBold(true);
        //Set font into style

        CellStyle borderStyle = workbook.createCellStyle();
        borderStyle.setAlignment(CellStyle.ALIGN_CENTER);
        borderStyle.setFont(xfont);

        xstyle = workbook.createCellStyle();
        xstyle.setFont(xfont);

        //header
        row = spreadsheet.createRow(0);
        cell = row.createCell(0);
        cell.setCellValue("WORK ORDER NO : " + pono);
        cell.setCellStyle(borderStyle);
        spreadsheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 5));

        //3.Get First Row and Set Headers
        row = spreadsheet.createRow(1);
        cell = row.createCell(0);
        cell.setCellValue("LINE_NO");
        cell.setCellStyle(xstyle);
        cell = row.createCell(1);
        cell.setCellValue("ITEM_ID");
        cell.setCellStyle(xstyle);
        cell = row.createCell(2);
        cell.setCellValue("DESCRIPTION");
        cell.setCellStyle(xstyle);
        cell = row.createCell(3);
        cell.setCellValue("UOM");
        cell.setCellStyle(xstyle);
        cell = row.createCell(4);
        cell.setCellValue("QTY");
        cell.setCellStyle(xstyle);
        cell = row.createCell(5);
        cell.setCellValue("RATE");
        cell.setCellStyle(xstyle);
        cell = row.createCell(6);
        cell.setCellValue("NOTE");
        cell.setCellStyle(xstyle);

        int i = 2;
        for (WorkItemBean w : wi1) {
            row = spreadsheet.createRow(i);
            cell = row.createCell(0);
            cell.setCellValue(w.getLINE_NO());
            cell = row.createCell(1);
            cell.setCellValue(w.getITEM_ID());
            cell = row.createCell(2);
            cell.setCellValue(w.getITEM_DESC());
            cell = row.createCell(3);
            cell.setCellValue(w.getUOM());
            cell = row.createCell(4);
            cell.setCellValue(w.getQTY());
            cell = row.createCell(5);
            cell.setCellValue(w.getRATE());
            cell = row.createCell(6);
            cell.setCellValue(w.getCMT());
            i++;
        }

        //Export to Excel
        //            FileOutputStream out = new FileOutputStream(new File("D://" + pono.replace("/", "-") + "_Items" + ".xlsx"));
        FileOutputStream out = new FileOutputStream(
                new File(relpath + "uxls//" + pono.replace("/", "-") + "_Items" + ".xlsx"));
        workbook.write(out);
        out.close();
        Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "DONE|!");
        Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "{0}uxls//{1}" + "_Items" + ".xlsx",
                new Object[] { relpath, pono.replace("/", "-") });
    } catch (FileNotFoundException ex) {
        Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex);
    } catch (IOException ex) {
        Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex);
    }
}