Пример #1
0
 private void writeData2Excel(HSSFSheet sheet, HSSFCellStyle dataStyle, HSSFCellStyle headerStyle)
     throws ContainerException {
   RowSet searchResult = executeFrm.getSearchResult();
   if (searchResult != null && !searchResult.isEmpty()) {
     List<ReportViewFrm> definedViews = executeFrm.getDefinedViews();
     int fieldCount = definedViews.size();
     int dataCount = searchResult.getSize();
     int xlsRowNum = 0;
     for (int i = 0; i < dataCount; i++) {
       Row row = searchResult.getRow(i);
       xlsRowNum = i;
       if (isFirstFile) {
         xlsRowNum++;
       }
       HSSFRow xlsRow = sheet.createRow(xlsRowNum);
       xlsRow.setHeightInPoints(18);
       for (short j = 0; j < fieldCount; j++) {
         ReportViewFrm viewFrm = definedViews.get(j);
         String fieldName = viewFrm.getFieldName();
         HSSFCell xlsCell = xlsRow.createCell(j);
         xlsCell.setCellStyle(dataStyle);
         HSSFRichTextString richText = new HSSFRichTextString(row.getStrValue(fieldName));
         xlsCell.setCellValue(richText);
       }
     }
   }
 }
Пример #2
0
 private void writeDataHeader(HSSFSheet sheet, HSSFCellStyle headerStyle) throws ReportException {
   try {
     sheet.setDisplayGridlines(false); // 不显示网格线
     HSSFRow xlsRow = sheet.createRow(0);
     xlsRow.setHeightInPoints(18);
     List<ReportViewFrm> definedViews = executeFrm.getDefinedViews();
     int fieldCount = definedViews.size();
     for (short j = 0; j < fieldCount; j++) {
       ReportViewFrm viewFrm = definedViews.get(j);
       HSSFCell xlsCell = xlsRow.createCell(j);
       xlsCell.setCellStyle(headerStyle);
       HSSFRichTextString richText = new HSSFRichTextString(viewFrm.getFieldDesc());
       xlsCell.setCellValue(richText);
     }
   } catch (Throwable ex) {
     Logger.logError(ex);
     throw new ReportException(ex.getMessage());
   }
 }