Examples of HSSFRow


Examples of org.apache.poi.hssf.usermodel.HSSFRow

        int rownum = 0; // 0行目はコメント行、最初にインクリメントされて
                        // 1行目から処理する
        for (;;) {
            rownum++;
            HSSFRow row = sheet.getRow(rownum);
            if (isEmpty(row)) {
                break;
            }
            Writable model;
            try {
                model = (Writable) modelClass.newInstance();
            } catch (InstantiationException e) {
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
            for (int col = 0; col < columnInfos.size(); col++) {
                HSSFCell cell = row.getCell(col, Row.CREATE_NULL_AS_BLANK);
                MySqlDataType type = columnInfos.get(col).getDataType();
                ValueOption<?> vo;
                switch (type) {
                case CHAR:
                case VARCHAR:
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

     * @param rownum
     * @param col
     * @return
     */
    private HSSFCell getCell(HSSFSheet sheet, int rownum, int col) {
        HSSFRow row = sheet.getRow(rownum);
        HSSFCell cell = row.getCell(col);
        return cell;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

        dateStyle.cloneStyleFrom(commonStyle);
        dateStyle.setDataFormat(df.getFormat("yyyy-mm-dd"));
    }

    private HSSFCell getCell(HSSFSheet sheet, int rownum, int col) {
        HSSFRow row = sheet.getRow(rownum);
        if (row == null) {
            row = sheet.createRow(rownum);
        }
        HSSFCell cell = row.getCell(col);
        if (cell == null) {
            cell = row.createCell(col);
        }
        cell.setCellStyle(commonStyle);
        return cell;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

     */
    private HSSFSheet createInputDataSheet(String sheetName) throws SQLException {
        HSSFSheet sheet = workbook.createSheet(sheetName);

        // カラム名を設定
        HSSFRow row = sheet.createRow(0);
        for (int i = 0; i < columnInfos.length; i++) {
            HSSFCell cell = row.createCell(i);
            cell.setCellValue(columnInfos[i].getColumnName());
            cell.setCellStyle(titleStyle);
        }

        // DBのデータを設定
        PreparedStatement ps = null;
        ResultSet rs = null;

        String sql =
            "SELECT * FROM "
            + databaseName + "." + tableName
            + " limit 0, " + Constants.MAX_ROWS;
        try {
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            while (rs.next()) {
                row = sheet.createRow(row.getRowNum() + 1);
                for (int i = 0; i < columnInfos.length; i++) {
                    ColumnInfo info = columnInfos[i];
                    HSSFCell cell = row.createCell(i);
                    cell.setCellStyle(commonStyle);
                    switch (info.getDataType()) {
                    case CHAR:
                    case VARCHAR:
                        String str = rs.getString(info.getColumnName());
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

   
   
     for (String s : loggedItems){
           
            // Create a row and put some cells in it. Rows are 0 based.
            HSSFRow row = sheet.createRow(currentRow);
           
            // Create a cell and put a value in it.
            HSSFCell cell = row.createCell((short)0);
            cell.setCellValue(s);

            currentRow++;
     }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

      Range redRange = new Range(aNamedRage.getNameName());

      for (int thisCellinRange = 0; thisCellinRange < crefs.length; thisCellinRange++) {
        HSSFSheet sheet = wb.getSheet(crefs[thisCellinRange]
            .getSheetName());
        HSSFRow r = sheet.getRow(crefs[thisCellinRange].getRow());

        HSSFCell thisExcelCell = null;
        if (r != null) {
          thisExcelCell = r.getCell(crefs[thisCellinRange].getCol());
          // extract the cell contents based on cell type etc.
        }

        // Create our JavaBean representing the cell
        String cellHandle = redRange.getUniqueCellName(thisCellinRange);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

      for (int thisCellinRange = 0; thisCellinRange < crefs.length; thisCellinRange++) {
        HSSFSheet sheet = wb.getSheet(crefs[thisCellinRange]
            .getSheetName());

        HSSFRow r = sheet.getRow(crefs[thisCellinRange].getRow());

        // Get the cell that is referred to
        HSSFCell excelCell = null;
        if (r != null) {
          excelCell = r.getCell(crefs[thisCellinRange].getCol());

          // Check that the range name is on our list
          String cellHandle = Range.getUniqueCellName(aNamedCell
              .getNameName(), thisCellinRange);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

    public void performExport(DataExportModel model, DataExportInstructions instructions, ConnectionHandler connectionHandler) throws DataExportException {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet(model.getTableName());

        if (instructions.createHeader()) {
            HSSFRow headerRow = sheet.createRow(0);

            for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++){
                String columnName = model.getColumnName(columnIndex);

                HSSFCell cell = headerRow.createCell(columnIndex);
                cell.setCellValue(columnName);

                HSSFCellStyle cellStyle = workbook.createCellStyle();
                HSSFFont tableHeadingFont = workbook.createFont();
                tableHeadingFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                cellStyle.setFont(tableHeadingFont);
                cell.setCellStyle(cellStyle);
            }
        }

        CellStyleCache cellStyleCache = new CellStyleCache(workbook, model.getProject());

        for (short rowIndex = 0; rowIndex < model.getRowCount(); rowIndex++) {
            HSSFRow row = sheet.createRow(rowIndex + 1);
            for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++){
                HSSFCell cell = row.createCell(columnIndex);
                Object value = model.getValue(rowIndex, columnIndex);
                if (value != null) {
                    if (value instanceof Number) {
                        Number number = (Number) value;
                        double doubleValue = number.doubleValue();
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

                        for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
                            HSSFSheet sheet = workbook.getSheetAt(i);

                            Iterator rows = sheet.rowIterator();
                            while (rows.hasNext()) {
                                HSSFRow row = (HSSFRow) rows.next();

                                Iterator cells = row.cellIterator();
                                while (cells.hasNext()) {
                                    HSSFCell cell = (HSSFCell) cells.next();
                                    switch (cell.getCellType()) {
                                    case HSSFCell.CELL_TYPE_NUMERIC:
                                        String num = Double.toString(cell.getNumericCellValue()).trim();
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

  public final String readCell(final int row, final int col,
      final String stringFormat) {
    if (readSheet == null) {
      return null;
    }
    HSSFRow excelRow = readSheet.getRow(row);
    if (excelRow != null) {
      return getCellValue(excelRow, col, stringFormat);
    }
    return null;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.