Example usage for org.apache.poi.hssf.usermodel HSSFWorkbook createSheet

List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook createSheet

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFWorkbook createSheet.

Prototype

@Override
public HSSFSheet createSheet(String sheetname) 

Source Link

Document

Create a new sheet for this Workbook and return the high level representation.

Usage

From source file:edu.wisc.ssec.mcidasv.control.cyclone.StormDisplayState.java

License:Open Source License

/**
 * _more_// www  . ja va  2s .  com
 * 
 * @param wb
 *            _more_
 * @param track
 *            _more_
 * @param sheetNames
 *            _more_
 */
protected void write(HSSFWorkbook wb, StormTrack track, Hashtable sheetNames) {
    int cnt = 0;
    String dateString = track.getStartTime().formattedString("yyyy-MM-dd hhmm", DateUtil.TIMEZONE_GMT);
    String sheetName = track.getWay() + " - " + dateString;
    if (sheetName.length() > 30) {
        sheetName = sheetName.substring(0, 29);
    }
    // The sheet name length is limited
    while (sheetNames.get(sheetName) != null) {
        sheetName = (cnt++) + " " + sheetName;
        if (sheetName.length() > 30) {
            sheetName = sheetName.substring(0, 29);
        }
    }
    sheetNames.put(sheetName, sheetName);
    HSSFSheet sheet = wb.createSheet(sheetName);

    int rowCnt = 0;
    List<StormParam> params = track.getParams();
    HSSFCell cell;
    HSSFRow row;

    for (StormTrackPoint stp : track.getTrackPoints()) {
        if (rowCnt == 0) {
            row = sheet.createRow((short) rowCnt++);
            row.createCell(0).setCellValue(new HSSFRichTextString("Time"));
            row.createCell(1).setCellValue(new HSSFRichTextString("Latitude"));
            row.createCell(2).setCellValue(new HSSFRichTextString("Longitude"));
            for (int colIdx = 0; colIdx < params.size(); colIdx++) {
                row.createCell((colIdx + 3))
                        .setCellValue(new HSSFRichTextString(params.get(colIdx).toString()));
            }
        }
        row = sheet.createRow((short) rowCnt++);
        row.createCell(0).setCellValue(new HSSFRichTextString(stp.getTime().toString()));
        row.createCell(1).setCellValue(stp.getLocation().getLatitude().getValue());
        row.createCell(2).setCellValue(stp.getLocation().getLongitude().getValue());
        for (int colIdx = 0; colIdx < params.size(); colIdx++) {
            Real r = stp.getAttribute(params.get(colIdx));
            cell = row.createCell((colIdx + 3));
            cell.setCellValue(r.getValue());
        }
    }
}

From source file:egovframework.rte.tex.com.web.EgovExcel.java

License:Apache License

/**
 * ??  ?./*from w w  w . j  a v  a 2  s . com*/
 * @param model
 * @param wb
 * @param request
 * @param response
 * @throws Exception
 */
@SuppressWarnings({ "deprecation", "unchecked" })
@Override
protected void buildExcelDocument(Map<String, Object> model, HSSFWorkbook wb, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    HSSFCell cell = null;

    HSSFSheet sheet = wb.createSheet("Goods List");
    sheet.setDefaultColumnWidth((short) 12);

    // put text in first cell
    cell = getCell(sheet, 0, 0);
    setText(cell, "Goods List");

    // set header information
    setText(getCell(sheet, 2, 0), "No.");
    setText(getCell(sheet, 2, 1), "NAME");
    setText(getCell(sheet, 2, 2), "PRICE");
    setText(getCell(sheet, 2, 3), "CATEGORY NAME");
    setText(getCell(sheet, 2, 4), "MAKER");

    List<GoodsVO> goods = (List<GoodsVO>) model.get("goodsList");

    for (int i = 0; i < goods.size(); i++) {
        GoodsVO goodsVO = goods.get(i);

        cell = getCell(sheet, 3 + i, 0);
        setText(cell, Integer.toString(i + 1));

        cell = getCell(sheet, 3 + i, 1);
        setText(cell, goodsVO.getGoodsNm());

        cell = getCell(sheet, 3 + i, 2);
        setText(cell, Integer.toString(goodsVO.getPrice()));

        cell = getCell(sheet, 3 + i, 3);
        setText(cell, goodsVO.getCategoryVO().getCtgryNm());

        cell = getCell(sheet, 3 + i, 4);
        setText(cell, goodsVO.getMakr());
    }
}

From source file:eionet.cr.util.export.XlsExporter.java

License:Mozilla Public License

/**
 * exports custom search to XLS format.//w w w.j av a2s  .c om
 *
 * @param customSearch
 * @return
 * @throws IOException
 * @throws DAOException
 */
protected InputStream doExport() throws IOException, DAOException {
    HSSFWorkbook workbook = new HSSFWorkbook();
    sheet = workbook.createSheet("exported data");

    // some pretty print with headers
    CellStyle headerStyle = workbook.createCellStyle();
    Font headerFont = workbook.createFont();
    headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    headerStyle.setFont(headerFont);

    // output headers
    HSSFRow headers = sheet.createRow(0);
    // store width of each column +1 for Uri or Label column
    columnWidth = new int[getSelectedColumns().size() + 1];
    // output Uri or Label column
    String uriOrLabelColumn = getUriOrLabel();

    columnWidth[0] = uriOrLabelColumn.length();
    HSSFCell uriOrLabelCell = headers.createCell(0);
    XlsUtil.setCellValue(uriOrLabelCell, uriOrLabelColumn);
    uriOrLabelCell.setCellStyle(headerStyle);

    // output rest of the headers
    int columnNumber = 1;
    for (Pair<String, String> columnPair : getSelectedColumns()) {
        // label is already added to the list of elements
        if (Predicates.RDFS_LABEL.equals(columnPair.getLeft()))
            continue;

        String column = columnPair.getRight() != null ? columnPair.getRight() : columnPair.getLeft();
        columnWidth[columnNumber] = column.length();
        HSSFCell cell = headers.createCell(columnNumber++);
        XlsUtil.setCellValue(cell, column);
        cell.setCellStyle(headerStyle);
    }
    sheet.createFreezePane(0, 1);

    // output serarch results
    SubjectExportReader reader = new SubjectExportReader(this);
    doExportQueryAndWriteDataIntoOutput(reader);

    // set column width
    for (int i = 0; i < getSelectedColumns().size() + 1; i++) {
        sheet.setColumnWidth(i, Math.min(256 * columnWidth[i], 256 * 255));
    }

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    workbook.write(output);
    return new ByteArrayInputStream(output.toByteArray());
}

From source file:es.jamisoft.comun.io.excel.ExcelGenerator.java

License:Apache License

/**
 * Este mtodo se encargara de rellenar las celdas con las columnas identificadas.
 *
 * @param data Coleccin con la que se desea crear  el fichero Excel.
 * @param wb Objeto Excel./* w  ww . j  a va2  s.  co m*/
 * @param columns Mapa con las cabeceras que se mostrarn en el fichero Excel.
 * @param getterMethods Elementos identificados con los que se rellenarn las celdas.
 * @param pageNumber Nmero de pagina que se generar.
 * @throws Exception
 */
private void procesPage(List<?> data, HSSFWorkbook wb, List<Header> columns, Map<String, Method> getterMethods,
        int pageNumber) throws Exception {
    HSSFSheet sheet = wb.createSheet("Sheet " + pageNumber);

    createHeader(sheet, columns);

    for (int i = 1; i <= data.size(); i++) {

        // Create a row and put some cells in it. Rows are 0 based.
        HSSFRow row = sheet.createRow(i);
        Object item = data.get(i - 1);

        // Iterar sobre los elementos y en funcion de los mapeos generar la
        // cell
        for (int j = 0; j < columns.size(); j++) {
            HSSFCell cell = row.createCell(j);
            Method getter = getterMethods.get(columns.get(j).getIdColumn());
            HSSFRichTextString v = new HSSFRichTextString(String.valueOf(getter.invoke(item, (Object[]) null)));

            cell.setCellValue(v);
            cell.setCellStyle(ep.getBodyStyle());
        }

        // Adjust column with the content
        if (ep.isAdjust()) {
            for (int k = 0; k < columns.size(); k++) {
                sheet.autoSizeColumn((short) k);
            }
        }
    }
}

From source file:esd.common.PoiCreateExcel.java

License:Open Source License

/**
 * ???/*from w  ww.j  ava  2s  .  co  m*/
 * 
 * @param FilePath
 * @param jobList
 * @return
 */
public static boolean createJobExcel(String FilePath, List<Job> jobList) {
    // Excel Workbook,excel
    HSSFWorkbook wb = new HSSFWorkbook();
    // Excelsheet,exceltab
    HSSFSheet sheet = wb.createSheet("sheet1");
    // excel?
    sheet.setColumnWidth(0, 4000);
    sheet.setColumnWidth(1, 3500);

    // Excel?
    HSSFRow headRow = sheet.createRow(0);
    HSSFCell headell = headRow.createCell(0);
    // ???
    headell = headRow.createCell(0);
    headell.setCellValue("????");
    headell = headRow.createCell(1);
    headell.setCellValue("?");
    headell = headRow.createCell(2);
    headell.setCellValue("");
    headell = headRow.createCell(3);
    headell.setCellValue("");
    headell = headRow.createCell(4);
    headell.setCellValue("???");
    headell = headRow.createCell(5);
    headell.setCellValue("");

    headell = headRow.createCell(6);
    headell.setCellValue("?");
    headell = headRow.createCell(7);
    headell.setCellValue("???");
    headell = headRow.createCell(8);
    headell.setCellValue("?");
    headell = headRow.createCell(9);
    headell.setCellValue("?");
    headell = headRow.createCell(10);
    headell.setCellValue("??");

    headell = headRow.createCell(11);
    headell.setCellValue("?");
    headell = headRow.createCell(12);
    headell.setCellValue("?");
    headell = headRow.createCell(13);
    headell.setCellValue("??");
    headell = headRow.createCell(14);
    headell.setCellValue("");

    headell = headRow.createCell(15);
    headell.setCellValue("? ");
    headell = headRow.createCell(16);
    headell.setCellValue("?");
    headell = headRow.createCell(17);
    headell.setCellValue("");
    headell = headRow.createCell(18);
    headell.setCellValue("????");
    headell = headRow.createCell(19);
    headell.setCellValue("????");

    headell = headRow.createCell(20);
    headell.setCellValue("?/?");
    headell = headRow.createCell(21);
    headell.setCellValue("");
    headell = headRow.createCell(22);
    headell.setCellValue("?");
    headell = headRow.createCell(23);
    headell.setCellValue("??");
    headell = headRow.createCell(24);
    headell.setCellValue("??");

    for (int i = 1; i <= jobList.size(); i++) {
        Job job = jobList.get(i - 1);
        // Excel?
        HSSFRow row = sheet.createRow(i);
        HSSFCell cell = row.createCell(0);
        // ???
        cell = row.createCell(0);
        cell.setCellValue(job.getName());
        cell = row.createCell(1);
        cell.setCellValue(job.getHireNumber());
        cell = row.createCell(2);
        cell.setCellValue(job.getSalary());
        cell = row.createCell(3);
        cell.setCellValue(job.getEducation());
        cell = row.createCell(4);
        cell.setCellValue(job.getExperience());
        cell = row.createCell(5);
        cell.setCellValue(job.getGender());

        cell = row.createCell(6);
        cell.setCellValue(job.getAge());
        cell = row.createCell(7);
        cell.setCellValue(job.getDescription());
        cell = row.createCell(8);
        cell.setCellValue(job.getProvideBenefit());
        cell = row.createCell(9);
        cell.setCellValue(job.getContactPerson());
        cell = row.createCell(10);
        cell.setCellValue(job.getContactTel());

        cell = row.createCell(11);
        cell.setCellValue(job.getContactEmail());
        if (job.getViewCount() != null) {
            cell = row.createCell(12);
            cell.setCellValue(job.getViewCount());
        }
        cell = row.createCell(13);
        cell.setCellValue(job.getNature());
        cell = row.createCell(14);
        cell.setCellValue(job.getEffectiveDays());
        cell = row.createCell(15);
        // cell.setCellValue(job.getIsActiveEffectiveTime());

        if (job.getEffectiveTime() != null) {
            SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // ??
            String effectiveTimeString = dateFm.format(job.getEffectiveTime());
            cell = row.createCell(16);
            cell.setCellValue(effectiveTimeString);
        }

        if (job.getWorkPlace() != null) {
            if (job.getWorkPlace().getCode() != null && !"".equals(job.getWorkPlace().getCode())) {
                cell = row.createCell(17);
                cell.setCellValue(job.getWorkPlace().getName());
            }
        }

        if (job.isBed() == true) {
            cell = row.createCell(18);
            cell.setCellValue("");
        } else if (job.isBed() == false) {
            cell = row.createCell(18);
            cell.setCellValue("?");
        }

        if (job.isLunch() == true) {
            cell = row.createCell(19);
            cell.setCellValue("");
        } else if (job.isLunch() == false) {
            cell = row.createCell(19);
            cell.setCellValue("?");
        }

        cell = row.createCell(20);
        cell.setCellValue(job.getCheckStatus());
        cell = row.createCell(21);
        cell.setCellValue(job.getMark());

        if (job.getCompany() != null) {

            cell = row.createCell(22);
            cell.setCellValue(job.getCompany().getName());
        }
        if (job.getArea() != null) {
            if (job.getArea().getCode() != null && !"".equals(job.getArea().getCode())) {
                cell = row.createCell(23);
                cell.setCellValue(job.getArea().getName());
            }
        }

        if (job.getJobCategory() != null) {
            if (job.getJobCategory().getCode() != null && !"".equals(job.getJobCategory().getCode())) {
                cell = row.createCell(24);
                cell.setCellValue(job.getJobCategory().getName());
            }
        }
    }
    try {
        FileOutputStream os = new FileOutputStream(FilePath);
        wb.write(os);
        os.flush();
        os.close();
        jobList.clear();
        jobList = null;
        os = null;
        wb = null;
        System.gc();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:esd.common.PoiCreateExcel.java

License:Open Source License

/**
 * ???/*from w  ww.j a  v a2 s . co  m*/
 * 
 * @param FilePath
 * @param companyList
 * @return
 */
public static boolean createComapnyExcel(String FilePath, List<Company> companyList) {
    // Excel Workbook,excel
    HSSFWorkbook wb = new HSSFWorkbook();
    // Excelsheet,exceltab
    HSSFSheet sheet = wb.createSheet("sheet1");
    // excel?
    sheet.setColumnWidth(0, 4000);
    sheet.setColumnWidth(1, 3500);

    // Excel?
    HSSFRow headRow = sheet.createRow(0);
    HSSFCell headell = headRow.createCell(0);
    // ???
    headell = headRow.createCell(0);
    headell.setCellValue("???");
    headell = headRow.createCell(1);
    headell.setCellValue("");
    headell = headRow.createCell(2);
    headell.setCellValue("?");
    headell = headRow.createCell(3);
    headell.setCellValue("??");
    headell = headRow.createCell(4);
    headell.setCellValue("?");
    headell = headRow.createCell(5);
    headell.setCellValue("");

    headell = headRow.createCell(6);
    headell.setCellValue("?");
    headell = headRow.createCell(7);
    headell.setCellValue("??");
    headell = headRow.createCell(8);
    headell.setCellValue("?");
    headell = headRow.createCell(9);
    headell.setCellValue("?");
    headell = headRow.createCell(10);
    headell.setCellValue("??");

    headell = headRow.createCell(11);
    headell.setCellValue("?");
    headell = headRow.createCell(12);
    headell.setCellValue("???");
    headell = headRow.createCell(13);
    headell.setCellValue("ID");
    headell = headRow.createCell(14);
    headell.setCellValue("?");
    headell = headRow.createCell(15);
    headell.setCellValue("?");

    headell = headRow.createCell(16);
    headell.setCellValue("?");
    headell = headRow.createCell(17);
    headell.setCellValue(" ?");
    headell = headRow.createCell(18);
    headell.setCellValue("");
    headell = headRow.createCell(19);
    headell.setCellValue("?");
    // headell = headRow.createCell(20);
    // headell.setCellValue("?");

    for (int i = 1; i <= companyList.size(); i++) {
        Company company = companyList.get(i - 1);
        // Excel?
        HSSFRow row = sheet.createRow(i);
        HSSFCell cell = row.createCell(0);
        // ???
        // ???
        cell = row.createCell(0);
        cell.setCellValue(company.getName());
        // 
        cell = row.createCell(1);
        cell.setCellValue(company.getCorporateRepresentative());
        // ?
        cell = row.createCell(2);
        cell.setCellValue(company.getContactPerson());
        // ??
        cell = row.createCell(3);
        cell.setCellValue(company.getTelephone());
        // ?
        cell = row.createCell(4);
        cell.setCellValue(company.getContactDept());
        // 
        cell = row.createCell(5);
        cell.setCellValue(company.getFax());
        // ?
        cell = row.createCell(6);
        cell.setCellValue(company.getEmail());
        // ??
        cell = row.createCell(7);
        cell.setCellValue(company.getAddress());
        // ?
        cell = row.createCell(8);
        cell.setCellValue(company.getIntroduction());
        // ?
        cell = row.createCell(9);
        cell.setCellValue(company.getOrganizationCode());
        // ??
        cell = row.createCell(10);
        cell.setCellValue(company.getCommercialCode());
        // ?
        cell = row.createCell(11);
        cell.setCellValue(company.getTaxCode());
        // ???
        cell = row.createCell(12);
        cell.setCellValue(company.getSocialSecurityCode());
        // ID
        cell = row.createCell(13);
        cell.setCellValue(company.getWebSiteId());
        // ?
        cell = row.createCell(14);
        cell.setCellValue(company.getLaoWangCode());
        // ?
        cell = row.createCell(15);
        cell.setCellValue(company.getScale());
        // ?
        cell = row.createCell(16);
        cell.setCellValue(company.getNature());
        // ?
        cell = row.createCell(17);
        cell.setCellValue(company.getEconomyType());
        // 
        cell = row.createCell(18);
        cell.setCellValue(company.getRemark());
        // ?
        if (company.getViewCount() != null) {
            cell = row.createCell(19);
            cell.setCellValue(company.getViewCount());
        }
        // cell = row.createCell(20);
        // cell.setCellValue(company.getCheckStatus());

    }
    try {
        FileOutputStream os = new FileOutputStream(FilePath);
        wb.write(os);
        os.flush();
        os.close();
        companyList.clear();
        companyList = null;
        os = null;
        wb = null;
        System.gc();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:esd.common.PoiCreateExcel.java

License:Open Source License

/**
 * ?//from ww  w .j a v  a2 s.  c o  m
 * 
 * @param FilePath
 * @param resumeList
 * @return
 */
public static boolean createResumeExcel(String FilePath, List<Resume> resumeList) {
    // Excel Workbook,excel
    HSSFWorkbook wb = new HSSFWorkbook();
    // Excelsheet,exceltab
    HSSFSheet sheet = wb.createSheet("sheet1");
    // excel?
    sheet.setColumnWidth(0, 4000);
    sheet.setColumnWidth(1, 3500);

    // Excel?
    HSSFRow headRow = sheet.createRow(0);
    HSSFCell headell = headRow.createCell(0);
    // ???
    headell = headRow.createCell(0);
    headell.setCellValue("??");
    headell = headRow.createCell(1);
    headell.setCellValue("??");
    headell = headRow.createCell(2);
    headell.setCellValue("");
    headell = headRow.createCell(3);
    headell.setCellValue("");
    headell = headRow.createCell(4);
    headell.setCellValue("??");
    headell = headRow.createCell(5);
    headell.setCellValue("?");

    headell = headRow.createCell(6);
    headell.setCellValue("");
    headell = headRow.createCell(7);
    headell.setCellValue("?");
    headell = headRow.createCell(8);
    headell.setCellValue("??");
    headell = headRow.createCell(9);
    headell.setCellValue("?");
    headell = headRow.createCell(10);
    headell.setCellValue("??");

    headell = headRow.createCell(11);
    headell.setCellValue("?");
    headell = headRow.createCell(12);
    headell.setCellValue("?");
    headell = headRow.createCell(13);
    headell.setCellValue("?");
    headell = headRow.createCell(14);
    headell.setCellValue("QQ??");
    headell = headRow.createCell(15);
    headell.setCellValue("");

    headell = headRow.createCell(16);
    headell.setCellValue("??");
    headell = headRow.createCell(17);
    headell.setCellValue(" ");
    headell = headRow.createCell(18);
    headell.setCellValue("?");
    headell = headRow.createCell(19);
    headell.setCellValue("");
    headell = headRow.createCell(20);
    headell.setCellValue("?");

    headell = headRow.createCell(21);
    headell.setCellValue("?");
    headell = headRow.createCell(22);
    headell.setCellValue("");
    headell = headRow.createCell(23);
    headell.setCellValue(" cm");
    headell = headRow.createCell(24);
    headell.setCellValue("? kg");
    headell = headRow.createCell(25);
    headell.setCellValue("");

    headell = headRow.createCell(26);
    headell.setCellValue("");
    headell = headRow.createCell(27);
    headell.setCellValue("");
    headell = headRow.createCell(28);
    headell.setCellValue("?");
    headell = headRow.createCell(29);
    headell.setCellValue("?");
    headell = headRow.createCell(30);
    headell.setCellValue("? ?");

    headell = headRow.createCell(31);
    headell.setCellValue("");
    headell = headRow.createCell(32);
    headell.setCellValue("");
    headell = headRow.createCell(33);
    headell.setCellValue("?");
    headell = headRow.createCell(34);
    headell.setCellValue("?");
    headell = headRow.createCell(35);
    headell.setCellValue("/?");

    headell = headRow.createCell(36);
    headell.setCellValue("");
    headell = headRow.createCell(37);
    headell.setCellValue("");
    headell = headRow.createCell(38);
    headell.setCellValue("??");
    headell = headRow.createCell(39);
    headell.setCellValue("");
    headell = headRow.createCell(40);
    headell.setCellValue("");

    headell = headRow.createCell(41);
    headell.setCellValue("???");
    headell = headRow.createCell(42);
    headell.setCellValue("????");
    headell = headRow.createCell(43);
    headell.setCellValue("???");
    headell = headRow.createCell(44);
    headell.setCellValue("???");
    headell = headRow.createCell(45);
    headell.setCellValue("");

    headell = headRow.createCell(46);
    headell.setCellValue("???");
    headell = headRow.createCell(47);
    headell.setCellValue("??");
    headell = headRow.createCell(48);
    headell.setCellValue("??");
    headell = headRow.createCell(49);
    headell.setCellValue("");

    headell = headRow.createCell(50);
    headell.setCellValue("?");
    headell = headRow.createCell(51);
    headell.setCellValue("?");
    for (int i = 1; i <= resumeList.size(); i++) {
        Resume resume = resumeList.get(i - 1);
        // Excel?
        HSSFRow row = sheet.createRow(i);
        HSSFCell cell = row.createCell(0);
        // ???
        cell = row.createCell(0);
        cell.setCellValue(resume.getTitle());
        cell = row.createCell(1);
        cell.setCellValue(resume.getName());
        cell = row.createCell(2);
        cell.setCellValue(resume.getGender());
        cell = row.createCell(3);
        cell.setCellValue(resume.getBirth());
        cell = row.createCell(4);
        cell.setCellValue(resume.getIdentityCard());
        cell = row.createCell(5);
        cell.setCellValue(resume.getRace());

        cell = row.createCell(6);
        cell.setCellValue(resume.getMarriage());
        if (resume.getHukou() != null) {
            if (resume.getHukou().getCode() != null && !"".equals(resume.getHukou().getCode())) {
                cell = row.createCell(7);
                cell.setCellValue(resume.getHukou().getName());
            }
        }

        cell = row.createCell(8);
        cell.setCellValue(resume.getHukouAddress());
        cell = row.createCell(9);
        cell.setCellValue(resume.getHukouStatus());
        cell = row.createCell(10);
        cell.setCellValue(resume.getAddress());

        cell = row.createCell(11);
        cell.setCellValue(resume.getZipcode());
        cell = row.createCell(12);
        cell.setCellValue(resume.getPhone());
        cell = row.createCell(13);
        cell.setCellValue(resume.getEmail());
        cell = row.createCell(14);
        cell.setCellValue(resume.getQq());
        cell = row.createCell(15);
        cell.setCellValue(resume.getDisabilityCategory());

        cell = row.createCell(16);
        cell.setCellValue(resume.getDisabilityCard());
        cell = row.createCell(17);
        cell.setCellValue(resume.getDisabilityLevel());
        cell = row.createCell(18);
        cell.setCellValue(resume.getDisabilityPart());
        cell = row.createCell(19);
        cell.setCellValue(resume.getWorkAbility());
        cell = row.createCell(20);
        cell.setCellValue(resume.getHomeTown());

        cell = row.createCell(21);
        cell.setCellValue(resume.getPoliticalStatus());
        cell = row.createCell(22);
        cell.setCellValue(resume.getAge());
        cell = row.createCell(23);
        cell.setCellValue(resume.getHeight());
        cell = row.createCell(24);
        cell.setCellValue(resume.getWeight());
        cell = row.createCell(25);
        cell.setCellValue(resume.getProcessState());

        cell = row.createCell(26);
        cell.setCellValue(resume.getEducation());
        cell = row.createCell(27);
        cell.setCellValue(resume.getMajor());
        cell = row.createCell(28);
        cell.setCellValue(resume.getSchool());
        cell = row.createCell(29);
        cell.setCellValue(resume.getZhiCheng());
        cell = row.createCell(30);
        cell.setCellValue(resume.getShiYeHao());

        cell = row.createCell(31);
        cell.setCellValue(resume.getExperts());
        cell = row.createCell(32);
        cell.setCellValue(resume.getTraining());
        cell = row.createCell(33);
        cell.setCellValue(resume.getExperience());
        cell = row.createCell(34);
        cell.setCellValue(resume.getWorkExperience());
        cell = row.createCell(35);

        cell.setCellValue(resume.getSelfEvaluation());
        cell = row.createCell(36);
        cell.setCellValue(resume.getAttachment());
        cell = row.createCell(37);
        cell.setCellValue(resume.getJobNature());
        if (resume.getDesireJob() != null) {
            if (resume.getDesireJob().getCode() != null && !"".equals(resume.getDesireJob().getCode())) {
                cell = row.createCell(38);
                log.info(resume.getDesireJob().getName() + "********8");
                cell.setCellValue(resume.getDesireJob().getName());
            }
        }

        if (resume.getDesireAddress() != null) {
            if (resume.getDesireAddress().getCode() != null
                    && !"".equals(resume.getDesireAddress().getCode())) {
                cell = row.createCell(39);
                cell.setCellValue(resume.getDesireAddress().getName());
            }
        }

        cell = row.createCell(40);
        cell.setCellValue(resume.getDesireSalary());

        if (resume.isProvideFoodAndRoom() == true) {
            cell = row.createCell(41);
            cell.setCellValue("");
        } else if (resume.isProvideFoodAndRoom() == false) {
            cell = row.createCell(41);
            cell.setCellValue("?");
        }

        if (resume.isProvideRoom() == true) {
            cell = row.createCell(42);
            cell.setCellValue("");
        } else if (resume.isProvideRoom() == false) {
            cell = row.createCell(42);
            cell.setCellValue("?");
        }

        if (resume.isProvideFood() == true) {
            cell = row.createCell(43);
            cell.setCellValue("");
        } else if (resume.isProvideFood() == false) {
            cell = row.createCell(43);
            cell.setCellValue("?");
        }
        if (resume.isProvideInsurance() == true) {
            cell = row.createCell(44);
            cell.setCellValue("");
        } else if (resume.isProvideInsurance() == false) {
            cell = row.createCell(44);
            cell.setCellValue("?");
        }
        cell = row.createCell(45);
        cell.setCellValue(resume.getProvideOther());
        if (resume.isWorkShift() == true) {
            cell = row.createCell(46);
            cell.setCellValue("");
        } else if (resume.isWorkShift() == false) {
            cell = row.createCell(46);
            cell.setCellValue("?");
        }
        cell = row.createCell(47);
        cell.setCellValue(resume.getState());

        if (resume.getIsDefault() == true) {
            cell = row.createCell(48);
            cell.setCellValue("");
        } else if (resume.getIsDefault() == false) {
            cell = row.createCell(48);
            cell.setCellValue("?");
        }

        cell = row.createCell(49);
        cell.setCellValue(resume.getCheckStatus());

        if (resume.getViewCount() != null) {
            cell = row.createCell(50);
            cell.setCellValue(resume.getViewCount());
        }
        cell = row.createCell(51);
        cell.setCellValue(resume.getCareerTest());

    }
    try {
        FileOutputStream os = new FileOutputStream(FilePath);
        wb.write(os);
        os.flush();
        os.close();
        resumeList.clear();
        resumeList = null;
        os = null;
        wb = null;
        System.gc();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:eu.scape_project.pc.tika.cli.MergeReports.java

License:Apache License

private static boolean writeXLS(String outputFilePath) throws Exception {

    int rowCounter = 1; //Start in row 1 (which is the 2nd row). Row 0 holds the description.
    FileOutputStream fileOut = new FileOutputStream(outputFilePath);
    HSSFWorkbook workbook = new HSSFWorkbook();

    HSSFSheet worksheet = workbook.createSheet("Type Report");

    HSSFCellStyle myCellStyle = workbook.createCellStyle();
    myCellStyle.setAlignment(CellStyle.ALIGN_CENTER);

    HSSFCellStyle myCellStylePercent = workbook.createCellStyle();
    HSSFDataFormat df = workbook.createDataFormat();
    myCellStylePercent.setDataFormat(df.getFormat("0.00%"));
    myCellStylePercent.setAlignment(CellStyle.ALIGN_CENTER);

    HSSFRow myHeaderRow = worksheet.createRow(0);
    HSSFCell myHeaderCell0 = myHeaderRow.createCell(0);
    HSSFCell myHeaderCell1 = myHeaderRow.createCell(1);
    HSSFCell myHeaderCell2 = myHeaderRow.createCell(2);

    myHeaderCell0.setCellValue("TYPE");
    myHeaderCell1.setCellValue("COUNT");
    myHeaderCell2.setCellValue("PERCENTAGE");
    myHeaderCell0.setCellStyle(myCellStyle);
    myHeaderCell1.setCellStyle(myCellStyle);
    myHeaderCell2.setCellStyle(myCellStyle);

    Iterator it = myCollection.keySet().iterator();
    while (it.hasNext()) {
        String typeKey = it.next().toString();
        float typeValue = myCollection.get(typeKey);
        float myPerc = typeValue / countAllGoodItems;
        //System.out.println("    ***: " + typeKey + "#" + (int) typeValue + "#" + myPerc);

        HSSFRow myRow = worksheet.createRow(rowCounter);
        HSSFCell myCell0 = myRow.createCell(0);
        HSSFCell myCell1 = myRow.createCell(1);
        HSSFCell myCell2 = myRow.createCell(2);

        myCell0.setCellValue(typeKey);//  w ww .j a  v  a  2  s . c o  m
        myCell1.setCellValue(typeValue);
        myCell2.setCellValue(myPerc);

        myCell1.setCellStyle(myCellStyle);
        myCell2.setCellStyle(myCellStyle);

        myCell2.setCellStyle(myCellStylePercent);

        rowCounter++;

    }

    workbook.write(fileOut);
    fileOut.flush();
    fileOut.close();

    return true;
}

From source file:Excel.InformeArticulos.java

public void GenerarInforme(ArrayList listadoClientes) throws SQLException {
    HSSFWorkbook libro = new HSSFWorkbook();
    HSSFSheet hoja = libro.createSheet("Listado de Articulos");
    ArrayList listadoPorSucursal = new ArrayList();
    Editables edi = new Articulos();

    /*// ww  w .  ja v a  2 s.  c om
     * GENERAR LAS SIGUIENTES HOJAS
     * 1- DETALLE DE MOVIMIENTOS DE CAJA - LEE EN MOVIMIENTOS CAJA INDENTIFICANDO EL TIPO DE MOVIMIENTO, USUARIOS Y 
     * NUMERO DE CAJA
     * 2- DETALLE DE ARTICULOS VENDIDOS: LISTADO DE MOVIEMIENTOS DE ARTICULOS, CON USUARIOS Y CAJA
     * 3- DETALLE DE GASTOS : MOVIMIENTOS DE CAJA DETALLANDO LOS GASTOS
     * 
     */

    String ttx = "celda numero :";
    HSSFRow fila = null;
    HSSFCell celda;
    HSSFCell celda1;
    HSSFCell celda2;
    HSSFCell celda3;
    HSSFCell celda4;
    HSSFCell celda5;
    HSSFCell celda6;
    HSSFCell celda7;
    HSSFCell celda8;
    HSSFCell celda9;
    HSSFCell celda10;
    HSSFCell celda11;
    HSSFFont fuente = libro.createFont();
    //fuente.setFontHeight((short)21);
    fuente.setFontName(fuente.FONT_ARIAL);
    fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    String form = null;

    HSSFCellStyle titulo = libro.createCellStyle();
    Iterator iCli = listadoClientes.listIterator();
    Articulos cliente = new Articulos();
    titulo.setFont(fuente);
    //titulo.setFillBackgroundColor((short)22);
    titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    //for(int a=0;a < 100;a++){
    int col = 0;
    int a = 0;
    if (a == 0) {
        fila = hoja.createRow(a);
        celda = fila.createCell(0);
        celda.setCellStyle(titulo);
        celda.setCellValue("Codigo");
        celda1 = fila.createCell(1);
        celda1.setCellStyle(titulo);
        celda1.setCellValue("Descripcion");
        celda2 = fila.createCell(2);
        celda2.setCellStyle(titulo);
        celda2.setCellValue("Stock");
        celda3 = fila.createCell(3);
        celda3.setCellStyle(titulo);
        celda3.setCellValue("Stock Mnimo");
        celda4 = fila.createCell(4);
        celda4.setCellStyle(titulo);
        celda4.setCellValue("Costo");
        celda5 = fila.createCell(5);
        celda5.setCellStyle(titulo);
        celda5.setCellValue("Precio de Venta");
        celda6 = fila.createCell(6);
        celda6.setCellStyle(titulo);
        celda6.setCellValue("Servicio");
    }
    while (iCli.hasNext()) {
        cliente = (Articulos) iCli.next();
        a++;
        //col=rs.getInt("tipoMovimiento");
        switch (col) {
        case 1:

            break;
        default:

            break;
        }
        fila = hoja.createRow(a);
        celda = fila.createCell(0);
        ttx = ttx;

        celda.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda.setCellValue(cliente.getCodigoAsignado());
        celda1 = fila.createCell(1);
        ttx = ttx;
        celda1.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda1.setCellValue(cliente.getDescripcionArticulo());
        celda2 = fila.createCell(2);
        celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda2.setCellValue(cliente.getStockActual());
        celda3 = fila.createCell(3);
        celda3.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda3.setCellValue(cliente.getStockMinimo());
        celda4 = fila.createCell(4);
        celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda4.setCellValue(cliente.getPrecioDeCosto());

        celda5 = fila.createCell(5);
        //celda5.setCellFormula(rs.getString("observaciones"));
        celda5.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda5.setCellValue(cliente.getPrecioUnitarioNeto());
        //celda5.setCellValue(rs.getDate("fecha"));
        celda6 = fila.createCell(6);
        //celda5.setCellFormula(rs.getString("observaciones"));
        celda6.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda6.setCellValue(cliente.getPrecioServicio());
        listadoPorSucursal = edi.ListarPorSucursal(cliente);
        Iterator il = listadoPorSucursal.listIterator();
        Articulos arr = new Articulos();
        int cont = 0;
        while (il.hasNext()) {
            arr = (Articulos) il.next();
            cont++;
            switch (cont) {

            case 1:
                celda7 = fila.createCell(7);
                celda7.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                celda7.setCellValue(arr.getCantidad());
                break;
            case 2:
                celda8 = fila.createCell(8);
                celda8.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                celda8.setCellValue(arr.getCantidad());
                break;
            case 3:
                celda9 = fila.createCell(9);
                celda9.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                celda9.setCellValue(arr.getCantidad());
                break;
            case 4:
                celda10 = fila.createCell(10);
                celda10.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                celda10.setCellValue(arr.getCantidad());
                break;
            }

        }
    }

    //texto+="\r\n";
    String ruta = "C://Informes//listadoDeArticulos.xls";
    try {
        FileOutputStream elFichero = new FileOutputStream(ruta);
        try {
            libro.write(elFichero);
            elFichero.close();
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + ruta);
        } catch (IOException ex) {
            Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:Excel.InformeDiarioStock.java

public void GenerrarInformeStock() throws SQLException {
    HSSFWorkbook libro = new HSSFWorkbook();
    HSSFSheet hoja = libro.createSheet("Articulos");
    /*/*from   ww w .j  a v a 2s .c  om*/
     * GENERAR LAS SIGUIENTES HOJAS
     * 1- DETALLE DE MOVIMIENTOS DE CAJA - LEE EN MOVIMIENTOS CAJA INDENTIFICANDO EL TIPO DE MOVIMIENTO, USUARIOS Y 
     * NUMERO DE CAJA
     * 2- DETALLE DE ARTICULOS VENDIDOS: LISTADO DE MOVIEMIENTOS DE ARTICULOS, CON USUARIOS Y CAJA
     * 3- DETALLE DE GASTOS : MOVIMIENTOS DE CAJA DETALLANDO LOS GASTOS
     * 
     */
    HSSFSheet hoja1 = libro.createSheet("Movimientos");
    HSSFSheet hoja2 = libro.createSheet("Movimientos Caja");

    String ttx = "celda numero :";
    HSSFRow fila = null;
    HSSFCell celda;
    HSSFCell celda1;
    HSSFCell celda2;
    HSSFCell celda3;
    HSSFCell celda4;
    HSSFCell celda5;
    HSSFCell celda6;
    HSSFCell celda7;
    HSSFCell celda8;
    HSSFCell celda9;
    HSSFCell celda10;
    HSSFFont fuente = libro.createFont();
    //fuente.setFontHeight((short)21);
    fuente.setFontName(fuente.FONT_ARIAL);
    fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    String form = null;
    //String sql="select id,nombre,(select sum(movimientosarticulos.cantidad) from movimientosarticulos where movimientosarticulos.idarticulo=articulos.id and movimientosarticulos.numerodeposito="+Inicio.deposito.getNumero()+")as stock,(select sum(movimientosarticulos.cantidad) from movimientosarticulos where movimientosarticulos.idcaja="+Inicio.caja.getNumero()+" and movimientosarticulos.idarticulo=articulos.id)as cantidadVendida from articulos";
    String sql = "select *,(select articulos.NOMBRE from articulos where articulos.ID=movimientosarticulos.idArticulo)as descripcion from movimientosarticulos where idcaja="
            + Inicio.caja.getNumero();
    System.out.println(sql);
    Transaccionable tra = new ConeccionLocal();
    ResultSet rs = tra.leerConjuntoDeRegistros(sql);
    HSSFCellStyle titulo = libro.createCellStyle();
    titulo.setFont(fuente);
    //titulo.setFillBackgroundColor((short)22);
    titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    //for(int a=0;a < 100;a++){
    int col = 0;
    int a = 0;
    if (a == 0) {
        fila = hoja.createRow(a);
        celda = fila.createCell(0);
        celda.setCellStyle(titulo);
        celda.setCellValue("id");
        celda1 = fila.createCell(1);
        celda1.setCellStyle(titulo);
        celda1.setCellValue("nombre");
        celda2 = fila.createCell(2);
        celda2.setCellStyle(titulo);
        celda2.setCellValue("Unidades Vendidas");
        celda3 = fila.createCell(3);
        celda3.setCellStyle(titulo);
        celda3.setCellValue("Fecha");
    }
    while (rs.next()) {
        a++;
        //col=rs.getInt("tipoMovimiento");
        switch (col) {
        case 1:

            break;
        default:

            break;
        }
        fila = hoja.createRow(a);
        celda = fila.createCell(0);
        ttx = ttx;
        Double anterior = 0.00;
        Double actual = 0.00;
        Double vendido = 0.00;
        celda.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda.setCellValue(rs.getInt("idArticulo"));
        celda1 = fila.createCell(1);
        ttx = ttx;
        celda1.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda1.setCellValue(rs.getString("descripcion"));
        celda2 = fila.createCell(2);
        vendido = (rs.getDouble("cantidad")) * -1;
        //actual=rs.getDouble("stock");
        celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda2.setCellValue(vendido);
        celda3 = fila.createCell(3);
        //vendido=(rs.getDouble("cantidadVendida")) * -1;
        celda3.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda3.setCellValue(rs.getString("fecha"));

    }
    //rs.close();

    // hoja 2

    form = null;
    sql = "SELECT id,cantidad,preciodecosto,preciodeventa,precioservicio,fecha,numerocomprobante,(select listcli.RAZON_SOCI from listcli where listcli.codMmd=movimientosarticulos.numeroCliente limit 0,1)as nombreC,(select articulos.NOMBRE from articulos where articulos.ID=movimientosarticulos.idArticulo limit 0,1)as descA,(select usuarios.nombre from usuarios where usuarios.numero=movimientosarticulos.numeroUsuario limit 0,1) as nombreU FROM movimientosarticulos where tipoMovimiento =1 and idcaja="
            + Inicio.caja.getNumero();
    //System.out.println(sql);
    //tra=new Conecciones();
    rs = tra.leerConjuntoDeRegistros(sql);
    //HSSFCellStyle titulo=libro.createCellStyle();
    titulo.setFont(fuente);
    //titulo.setFillBackgroundColor((short)22);
    titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    //for(int a=0;a < 100;a++){
    col = 0;
    a = 0;
    if (a == 0) {
        fila = hoja1.createRow(a);
        celda = fila.createCell(0);
        celda.setCellStyle(titulo);
        celda.setCellValue("Cajero");
        celda1 = fila.createCell(1);
        celda1.setCellStyle(titulo);
        celda1.setCellValue("Descripcion Articulo");
        celda2 = fila.createCell(2);
        celda2.setCellStyle(titulo);
        celda2.setCellValue("Cantidad");
        celda3 = fila.createCell(3);
        celda3.setCellStyle(titulo);
        celda3.setCellValue("Precio de Costo");
        celda4 = fila.createCell(4);
        celda4.setCellStyle(titulo);
        celda4.setCellValue("Precio de Venta");
        celda5 = fila.createCell(5);
        celda5.setCellStyle(titulo);
        celda5.setCellValue("Fecha");
        celda6 = fila.createCell(6);
        celda6.setCellStyle(titulo);
        celda6.setCellValue("Precio de Servicio");
        celda7 = fila.createCell(7);
        celda7.setCellStyle(titulo);
        celda7.setCellValue("comprobante");

        celda8 = fila.createCell(8);
        celda8.setCellStyle(titulo);
        celda8.setCellValue("Cliente");
        celda9 = fila.createCell(9);
        celda9.setCellStyle(titulo);
        celda9.setCellValue("Total");
        celda10 = fila.createCell(10);
        celda10.setCellStyle(titulo);
        celda10.setCellValue("idMovimiento");

    }
    while (rs.next()) {
        a++;
        //col=rs.getInt("tipoMovimiento");
        switch (col) {
        case 1:

            break;
        default:

            break;
        }
        fila = hoja1.createRow(a);
        celda = fila.createCell(0);
        ttx = ttx;
        celda.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda.setCellValue(rs.getString("nombreU"));
        celda1 = fila.createCell(1);
        ttx = ttx;
        celda1.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda1.setCellValue(rs.getString("descA"));
        celda2 = fila.createCell(2);
        celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda2.setCellValue(rs.getDouble("cantidad"));
        celda3 = fila.createCell(3);
        celda3.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda3.setCellValue(rs.getDouble("precioDeCosto"));
        celda4 = fila.createCell(4);
        celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda4.setCellValue(rs.getDouble("precioDeVenta"));

        celda5 = fila.createCell(5);
        //celda5.setCellFormula(rs.getString("observaciones"));
        celda5.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda5.setCellValue(" " + rs.getDate("fecha"));
        //celda5.setCellValue(rs.getDate("fecha"));
        celda6 = fila.createCell(6);
        celda6.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda6.setCellValue(rs.getDouble("precioServicio"));
        celda7 = fila.createCell(7);
        celda7.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda7.setCellValue(rs.getInt("numeroComprobante"));

        celda8 = fila.createCell(8);
        celda8.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda8.setCellValue(rs.getString("nombreC"));

        celda9 = fila.createCell(9);
        celda9.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        Double tto = 0.00;
        tto = rs.getDouble("precioServicio") + rs.getDouble("precioDeVenta");
        celda9.setCellValue(tto);
        celda10 = fila.createCell(10);
        celda10.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda10.setCellValue(rs.getInt("id"));
    }

    form = null;
    sql = "SELECT *,(select usuarios.nombre from usuarios where usuarios.numero=movimientoscaja.numeroUsuario)as nombreUsuario,(select listcli.RAZON_SOCI from listcli where listcli.id=movimientoscaja.idCliente)as nombreCliente,(select tipocomprobantes.descripcion from tipocomprobantes where tipocomprobantes.numero=movimientoscaja.tipoComprobante)as nombreComprobante,(select tipomovimientos.DESCRIPCION from tipomovimientos where tipomovimientos.ID=movimientoscaja.tipoMovimiento)as nombreMov FROM movimientoscaja where idcaja="
            + Inicio.caja.getNumero() + " order by id";
    //System.out.println(sql);
    //tra=new Conecciones();
    rs = tra.leerConjuntoDeRegistros(sql);
    //HSSFCellStyle titulo=libro.createCellStyle();
    titulo.setFont(fuente);
    //titulo.setFillBackgroundColor((short)22);
    titulo.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    titulo.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    //for(int a=0;a < 100;a++){
    col = 0;
    a = 0;
    if (a == 0) {
        fila = hoja2.createRow(a);
        celda = fila.createCell(0);
        celda.setCellStyle(titulo);
        celda.setCellValue("Cajero");
        celda1 = fila.createCell(1);
        celda1.setCellStyle(titulo);
        celda1.setCellValue("Cliente");
        celda2 = fila.createCell(2);
        celda2.setCellStyle(titulo);
        celda2.setCellValue("Comprobante Numero");
        celda3 = fila.createCell(3);
        celda3.setCellStyle(titulo);
        celda3.setCellValue("Tipo Comprobante");
        celda4 = fila.createCell(4);
        celda4.setCellStyle(titulo);
        celda4.setCellValue("Monto");
        celda5 = fila.createCell(5);
        celda5.setCellStyle(titulo);
        celda5.setCellValue("Fecha");
        celda6 = fila.createCell(6);
        celda6.setCellStyle(titulo);
        celda6.setCellValue("Tipo de Movimiento");
        celda7 = fila.createCell(7);
        celda7.setCellStyle(titulo);
        celda7.setCellValue("Condicion");

        celda8 = fila.createCell(8);
        celda8.setCellStyle(titulo);
        celda8.setCellValue("idMovimiento");

    }
    while (rs.next()) {
        a++;
        //col=rs.getInt("tipoMovimiento");
        switch (col) {
        case 1:

            break;
        default:

            break;
        }
        fila = hoja2.createRow(a);
        celda = fila.createCell(0);
        ttx = ttx;
        celda.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda.setCellValue(rs.getString("nombreUsuario"));
        celda1 = fila.createCell(1);
        ttx = ttx;
        celda1.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda1.setCellValue(rs.getString("nombreCliente"));
        celda2 = fila.createCell(2);
        celda2.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda2.setCellValue(rs.getInt("numeroComprobante"));
        celda3 = fila.createCell(3);
        celda3.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda3.setCellValue(rs.getString("nombreComprobante"));
        celda4 = fila.createCell(4);
        celda4.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda4.setCellValue(rs.getDouble("monto"));

        celda5 = fila.createCell(5);
        //celda5.setCellFormula(rs.getString("observaciones"));
        celda5.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda5.setCellValue(" " + rs.getDate("fecha"));
        //celda5.setCellValue(rs.getDate("fecha"));
        celda6 = fila.createCell(6);
        celda6.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda6.setCellValue(rs.getString("nombreMov"));
        celda7 = fila.createCell(7);
        String pagado = "PAGADO";
        if (rs.getInt("pagado") == 0 && rs.getInt("tipoMovimiento") == 1)
            pagado = "CTA CTE";
        celda7.setCellType(HSSFCell.CELL_TYPE_STRING);
        celda7.setCellValue(pagado);

        celda8 = fila.createCell(8);
        celda8.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        celda8.setCellValue(rs.getInt("id"));
    }

    rs.close();

    //texto+="\r\n";
    String ruta = "C://Informes//" + Inicio.fechaDia + "_" + Inicio.usuario.getNombre()
            + " - informeDeStock.xls";
    String nombree = Inicio.fechaDia + "_" + Inicio.usuario.getNombre() + " - informeDeStock.xls";
    try {
        FileOutputStream elFichero = new FileOutputStream(ruta);
        try {
            libro.write(elFichero);
            elFichero.close();
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + ruta);
            Mail mail = new Mail();
            String mailRecepcion = Propiedades.getCORREOCIERREDECAJA();
            mail.setDetalleListado(nombree);
            mail.setDireccionFile(ruta);
            mail.setAsunto("Informe de cierre de caja " + Inicio.fechaDia + " Sucursal: "
                    + Propiedades.getNOMBRECOMERCIO());
            mail.enviarMailRepartoCargaCompleta(mailRecepcion);
        } catch (IOException ex) {
            Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MessagingException ex) {
            Logger.getLogger(InformeDiarioStock.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, "NO SE HA PODIDO ENVIAR EL MENSAJE MOTIVO :" + ex);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(InformeMensual.class.getName()).log(Level.SEVERE, null, ex);
    }
    sql = "select id,nombre,precio,servicio,(select sum(movimientosarticulos.cantidad) from movimientosarticulos where movimientosarticulos.idcaja="
            + Inicio.caja.getNumero()
            + " and movimientosarticulos.idarticulo=articulos.id)as cantidadVendida from articulos order by cantidadVendida desc";
    rs = tra.leerConjuntoDeRegistros(sql);
    System.out.println(sql);
    Transaccionable tt = new Conecciones();
    String sql1;
    Double cantVend;
    while (rs.next()) {
        cantVend = rs.getDouble("cantidadVendida");
        if (cantVend < 0) {
            //sql1="insert into movimientosarticulosF (tipoMovimiento,idArticulo,cantidad,numeroDeposito,tipoComprobante,numeroCliente,numerousuario,precioDeVenta,precioServicio,idcaja) values (1,"+rs.getInt("id")+",floor("+rs.getDouble("cantidadVendida")+" * 0.1),"+Inicio.deposito.getNumero()+",1,1,"+Inicio.usuario.getNumeroId()+","+rs.getDouble("precio")+","+rs.getDouble("servicio")+","+Inicio.caja.getNumero()+")";
            //System.out.println(sql1);
            //tt.guardarRegistro(sql1);
        }

    }
}