Package org.apache.poi.hssf.usermodel

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


     */
    public void test48718() throws Exception {
       // Verify the HSSF behaviour
       // Then ensure the same for XSSF
       Workbook[] wbs = new Workbook[] {
             new HSSFWorkbook(),
             new XSSFWorkbook()
       };
       int[] initialFonts = new int[] { 4, 1 };
       for(int i=0; i<wbs.length; i++) {
          Workbook wb = wbs[i];
View Full Code Here


     *  and with the docs on when fetching the wrong
     *  kind of value from a Formula cell
     */
    public void test47815() {
       Workbook[] wbs = new Workbook[] {
             new HSSFWorkbook(),
             new XSSFWorkbook()
       };
       for(Workbook wb : wbs) {
          Sheet s = wb.createSheet();
          Row r = s.createRow(0);
View Full Code Here

                        throw new IOException(e.getMessage());
                    }

                    try {
                        POIFSFileSystem fs = new POIFSFileSystem(in);
                        HSSFWorkbook workbook = new HSSFWorkbook(fs);

                        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();
View Full Code Here

        Resource resource = dataContext.getResource();
        if (!resource.isExists()) {
            if (isXlsxFile(resource)) {
                return new SXSSFWorkbook(1000);
            } else {
                return new HSSFWorkbook();
            }
        }
        return readWorkbook(resource);
    }
View Full Code Here

        // Font color
        final short colorIndex = font.getColor();
        if (font instanceof HSSFFont) {
            if (colorIndex != HSSFFont.COLOR_NORMAL) {
                final HSSFWorkbook wb = (HSSFWorkbook) workbook;
                HSSFColor color = wb.getCustomPalette().getColor(colorIndex);
                if (color != null) {
                    short[] triplet = color.getTriplet();
                    styleBuilder.foreground(triplet);
                }
            }
View Full Code Here

      throws ProTransException {
    try {
      File excelFile = getFile(excelFileName);
      POIFSFileSystem fileSystem = new POIFSFileSystem(
          new FileInputStream(excelFile));
      HSSFWorkbook workbook = new HSSFWorkbook(fileSystem);
      readSheet = workbook.getSheetAt(0);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      throw new ProTransException(e);
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

      throws ProTransException {
    if (directory == null || directory.length() == 0) {
      throw new ProTransException("Katalog ikke satt");
    }
    String infoString = "Genererer excel-fil...rad ";
    HSSFWorkbook wb = new HSSFWorkbook();

    HSSFSheet sheet;

    sheet = getSheet(wb, 10, new int[] { 7000, 1400, 1400, 1200, 1500,
        1500, 1900, 1300, 1000, 3000 });
View Full Code Here

      throws ProTransException {
    if (directory == null || directory.length() == 0) {
      throw new ProTransException("Katalog ikke satt");
    }
    String infoString = "Genererer excel-fil...rad ";
    HSSFWorkbook wb = new HSSFWorkbook();

    HSSFSheet sheet;

    sheet = getSheet(wb, 9, new int[] { 7000, 1400, 1400, 1200, 1500, 1500,
        1900, 1300, 1000 });
View Full Code Here

    // celler
    if (notVisibleColumns != null) {
      notVisibleColumnsSize = notVisibleColumns.size();
    }
    String infoString = "Genererer excel-fil...rad ";
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet;

    sheet = wb.createSheet("sheet");
    int currentRow = 0;
    HSSFRow row;
    HSSFCell cell;

    CellStyle cellStyle = new CellStyle(wb, (short) headFontSize);

    // Overskrift
    if (heading != null && heading.length() != 0) {
      row = sheet.createRow((short) currentRow++);
      createCell(row, cellStyle.getHeadingStyle(), (short) 0, heading);
    }

    // Kolonneoverskrift
    row = sheet.createRow((short) currentRow++);
    int columnCount = table.getColumnCount();
    int rowCount = table.getRowCount();

    // Skriver ut kolonneoverskrift
    createColumnHeadings(row, cellStyle.getHeadingStyle(),
        table.getModel(), 0, columnCount, 0, notVisibleColumns);

    String groupValue = "";
    List<ExcelGroupSum> formulaCells = new ArrayList<ExcelGroupSum>();
    String groupSumValue = "";
    ExcelGroupSum currentExcelGroupSum = null;

    // Data
    int j;
    int k;
    int l = currentRow;
    // G�r gjennom alle rader og kolonner
    for (j = currentRow; j < rowCount + currentRow; j++) {
      // dersom data skal grupperes
      if (groupColumn != null
          && !table.getValueAt(j - currentRow, groupColumn).equals(
              groupValue)) {
        // setter forrige grupperingssum
        if (currentExcelGroupSum != null) {
          currentExcelGroupSum.setToRow((short) (l));
          formulaCells.add(currentExcelGroupSum);
          groupSumValue = "";
          currentExcelGroupSum = null;
        }
        // henter grupperingsverdi og setter ny overskrift for
        // gruppering
        groupValue = (String) table.getValueAt(j - currentRow,
            groupColumn);
        row = sheet.createRow((short) l);
        createCell(row, cellStyle.getGroupStyle(), (short) 0,
            groupValue);
        sheet.addMergedRegion(new Region((short) l, (short) 0,
            (short) l,
            (short) (columnCount - notVisibleColumnsSize - 1)));
        l++;

      }
      setLabelInfo(labelInfo, infoString, j);

      row = sheet.createRow((short) l);
      l++;

      // g�r gjennom alle kolonner for rad
      for (k = 0; k < columnCount; k++) {
        // dersom kolonne skal v�re synlig
        if (notVisibleColumns == null || !notVisibleColumns.contains(k)) {
          // dersom kolonnebredde er satt
          if (colSize != null) {
            Integer columnSize = colSize.get(k);
            if (columnSize != null) {
              sheet.setColumnWidth((short) k, columnSize
                  .shortValue());
            }
          }
          cell = row.createCell((short) k);
          // dersom celle har verdi
          if (table.getValueAt(j - currentRow, k) != null) {

            // dersom det er grupperingssum satt og den er ulik
            // forrige
            if (groupSumValueColumn != null
                && !table.getValueAt(j - currentRow,
                    groupSumValueColumn).equals(
                    groupSumValue)) {
              groupSumValue = (String) table.getValueAt(j
                  - currentRow, groupSumValueColumn);

              short dayColorIndex = DayEnum
                  .getDayColorIndex(groupSumValue);

              if (currentExcelGroupSum != null) {
                currentExcelGroupSum.setToRow((short) (l - 1));
                formulaCells.add(currentExcelGroupSum);
              }
              if (groupResultColumn != null) {
                currentExcelGroupSum = new ExcelGroupSum(
                    (short) l, row
                        .createCell(groupResultColumn
                            .shortValue()),
                    groupSumColumn.shortValue(),
                    dayColorIndex, wb.createCellStyle());
              }

            }
            cell.setCellStyle(cellStyle.createDayStyle(wrapText,
                groupSumValue));
View Full Code Here

  public final void generateDeviationSummary(
      final ExcelReportSetting reportSetting,
      final Map<Object, Object> data) throws ProTransException {
    String excelPath = getExcelPath();
    HSSFWorkbook wb = new HSSFWorkbook();

    HSSFSheet sheet = getSheet(wb, 1, new int[] { 4000 });

    int currentRow = 0;
    HSSFRow row;
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.usermodel.HSSFWorkbook

Copyright © 2018 www.massapicom. 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.