向工作簿中写入beans，标题默认从第0行开始，0-based

@param workbook   指定工作簿
@param count      指定每一个Sheet写入几个Bean
@param beans      指定写入的Beans(或者泛型为Map)
@param properties 指定写入的bean的属性
@param titles     指定写入的标题
@param dateFormat 日期格式
@return 返回传入的WorkBook
497887
public static <T> Workbook writeWorkBook(Workbook workbook, int count, List<T> beans, List<String> properties,
                                             List<String> titles, String dateFormat) {
        return WriteExcelUtils.writeWorkBook(workbook, 0, count, beans, properties, titles, dateFormat);
    }
161187
void writeSheet(Writer writer) throws WriterException {
        // create sheet
        this.sheet = workbook.createSheet(writer.sheetName());

        // setting styles
        CellStyle headerStyle = Constant.defaultHeaderStyle(workbook);
        CellStyle columnStyle = Constant.defaultColumnStyle(workbook);
        CellStyle titleStyle  = Constant.defaultTitleStyle(workbook);
        if (null != writer.titleStyle()) {
            titleStyle = writer.titleStyle().accept(workbook, titleStyle);
        }
        if (null != writer.headerStyle()) {
            headerStyle = writer.headerStyle().accept(workbook, headerStyle);
        }
        if (null != writer.cellStyle()) {
            columnStyle = writer.cellStyle().accept(workbook, columnStyle);
        }

        if (writer.isRaw()) {
            writer.sheetConsumer().accept(sheet);
        } else {
            // compute the Filed to be written
            Collection<?> rows   = writer.rows();
            Field[]       fields = rows.iterator().next().getClass().getDeclaredFields();

            this.fieldIndexes = new HashMap<>(fields.length);
            this.columns = new ArrayList<>();

            for (Field field : fields) {
                ExcelColumn column = field.getAnnotation(ExcelColumn.class);
                if (null != column) {
                    field.setAccessible(true);
                    fieldIndexes.put(column.index(), field);
                    columns.add(column);
                }
            }

            int colRowIndex = 0;
            // write title
            String title = writer.headerTitle();
            if (StringUtil.isNotEmpty(title)) {
                Integer maxColIndex = columns.stream()
                        .map(ExcelColumn::index)
                        .max(comparingInt(Integer::intValue))
                        .get();

                this.writeHeader(titleStyle, sheet, title, maxColIndex);
                colRowIndex = 1;
            }

            this.rowNum = writer.startRow();
            if (this.rowNum == 0) {
                this.rowNum = colRowIndex + 1;
            }

            try {
                // write column header
                this.writeColumnNames(colRowIndex, headerStyle);

                // write rows
                for (Object row : rows) {
                    this.writeRow(row, columnStyle);
                }
            } catch (Exception e) {
                log.error("write row fail", e);
            }
        }

        // write to OutputStream
        try (OutputStream os = outputStream) {
            workbook.write(os);
        } catch (Exception e) {
            throw new WriterException("workbook write to OutputStream error", e);
        }
    }
434624
public Search counts(String[] countsfields) {
        assert (countsfields.length > 0);
        JsonArray countsJsonArray = new JsonArray();
        for(String countsfield : countsfields) {
            JsonPrimitive element = new JsonPrimitive(countsfield);
            countsJsonArray.add(element);
        }
        databaseHelper.query("counts", countsJsonArray);
        return this;
    }
217468
public static void checkArrayColumns(final Sheet sheet, final Class<?> recordClass,
            final List<RecordHeader> headers, final AnnotationReader reader, final Configuration config) {
        
        List<FieldAccessor> properties = FieldAccessorUtils.getPropertiesWithAnnotation(recordClass, reader, XlsArrayColumns.class);
        
        for(FieldAccessor property : properties) {
            final XlsArrayColumns arrayColumns = property.getAnnotation(XlsArrayColumns.class).get();
            if(arrayColumns.optional()) {
                continue;
            }
            
            final String columnName = arrayColumns.columnName();
            boolean found = headers.stream()
                .filter(info -> Utils.matches(info.getLabel(), columnName, config))
                .findFirst()
                .isPresent();
            
            if(!found) {
                throw new CellNotFoundException(sheet.getSheetName(), columnName);
            }
            
        }
        
    }
1049546
public void normalSheet2Excel(List<NormalSheetWrapper> sheetWrappers, String templatePath, OutputStream os)
            throws Excel4JException {

        try (SheetTemplate sheetTemplate = exportExcelByModuleHandler(templatePath, sheetWrappers)) {
            sheetTemplate.write2Stream(os);
        } catch (IOException e) {
            throw new Excel4JException(e);
        }
    }
330303
@SuppressWarnings("unchecked")
    public Workbook create(Object bean) {
        optionsSheet = sheet.getWorkbook().getSheet("Options");

        for (val field : bean.getClass().getDeclaredFields()) {
            if (Fields.shouldIgnored(field, ExcelColIgnore.class)) continue;
            if (field.getName().endsWith("Tmpl")) continue;

            processExcelCellAnnotation(field, bean);
            processExcelRowsAnnotation(field, bean);
        }

        fixRowsHeight();
        PoiUtil.removeOtherSheets(sheet);


        val wb = sheet.getWorkbook();
        wb.setPrintArea(0, 0, PoiUtil.findMaxCol(sheet), 0, sheet.getLastRowNum());
        return wb;
    }
1025803
private void countPropertyMain(UsageStatistics usageStatistics,
			PropertyIdValue property, int count) {
		addPropertyCounters(usageStatistics, property);
		usageStatistics.propertyCountsMain.put(property,
				usageStatistics.propertyCountsMain.get(property) + count);
	}
1157276
public static void checkColumns(final Sheet sheet, final Class<?> recordClass,
            final List<RecordHeader> headers, final AnnotationReader reader, final Configuration config)
                    throws CellNotFoundException {
        
        List<FieldAccessor> properties = FieldAccessorUtils.getPropertiesWithAnnotation(recordClass, reader, XlsColumn.class);
        
        for(FieldAccessor property : properties) {
            final XlsColumn column = property.getAnnotation(XlsColumn.class).get();
            
            if(column.optional()){
                continue;
            }
            
            String columnName = column.columnName();
            boolean find = false;
            for(RecordHeader info: headers){
                if(Utils.matches(info.getLabel(), columnName, config)){
                    find = true;
                    break;
                }
            }
            if(!find){
                throw new CellNotFoundException(sheet.getSheetName(), columnName);
            }
        }
        
    }
1200871
public void simpleSheet2Excel(List<SimpleSheetWrapper> sheets, boolean isXSSF, OutputStream os)
            throws IOException {

        try (Workbook workbook = exportExcelBySimpleHandler(sheets, isXSSF)) {
            workbook.write(os);
        }
    }
275801
public void processSheet(
            StylesTable styles,
            ReadOnlySharedStringsTable strings,
            SheetContentsHandler sheetHandler,
            InputStream sheetInputStream) throws ReadExcelException {

        DataFormatter formatter = new DataFormatter();
        InputSource sheetSource = new InputSource(sheetInputStream);
        try {
            XMLReader sheetParser = SAXHelper.newXMLReader();
            ContentHandler handler = new XSSFSheetXMLHandlerPlus(
                    styles, null, strings, sheetHandler, formatter, false);
            sheetParser.setContentHandler(handler);
            //开始解析
            sheetParser.parse(sheetSource);
        } catch (ParserConfigurationException e) {
            throw new ReadExcelException("SAX parser appears to be broken - " + e.getMessage());
        } catch (Exception e) {
            throw new ReadExcelException(e.getMessage());
        }
    }
1200710
File appendSheet(final List<WorksheetContent> worksheetContents) throws IOException {
        final ImmutableSet<String> worksheetNames = FluentIterable.from(worksheetContents)
                .transform(new Function<WorksheetContent, String>() {
                    @Nullable @Override public String apply(@Nullable final WorksheetContent worksheetContent) {
                        return worksheetContent.getSpec().getSheetName();
                    }
                }).toSet();
        if(worksheetNames.size() < worksheetContents.size()) {
            throw new IllegalArgumentException("Sheet names must have distinct names");
        }
        for (final String worksheetName : worksheetNames) {
            if(worksheetName.length() > 30) {
                throw new IllegalArgumentException(
                        String.format("Sheet name cannot exceed 30 characters (invalid name: '%s')",
                                worksheetName));
            }
        }

        final XSSFWorkbook workbook = new XSSFWorkbook();
        final File tempFile =
                File.createTempFile(ExcelConverter.class.getName(), UUID.randomUUID().toString() + XLSX_SUFFIX);
        final FileOutputStream fos = new FileOutputStream(tempFile);

        for (WorksheetContent worksheetContent : worksheetContents) {
            final WorksheetSpec spec = worksheetContent.getSpec();
            appendSheet(workbook, worksheetContent.getDomainObjects(), spec.getFactory(), spec.getSheetName());
        }
        workbook.write(fos);
        fos.close();
        return tempFile;
    }
234858
public void createTitleCells(double width, String... strs) {
        for (String s : strs) {
            this.createTitleCell(s, width);
        }
    }
1088988
private static List[] caseMethods(int caseCount,
                                      BeanProperty[] props) {
        List[] cases = new List[caseCount];

        for (int i=0; i<props.length; i++) {
            BeanProperty prop = props[i];
            int hashCode = prop.getName().hashCode();
            int caseValue = (hashCode & 0x7fffffff) % caseCount;
            List matches = cases[caseValue];
            if (matches == null) {
                matches = cases[caseValue] = new ArrayList();
            }
            matches.add(prop);
        }

        return cases;
    }
1180547
def list_to_workbook(data, title='report', header=None, widths=None):
    
    wb = Workbook()
    title = re.sub(r'\W+', '', title)[:30]

    if isinstance(data, dict):
        i = 0
        for sheet_name, sheet_data in data.items():
            if i > 0:
                wb.create_sheet()
            ws = wb.worksheets[i]
            build_sheet(
                sheet_data, ws, sheet_name=sheet_name, header=header)
            i += 1
    else:
        ws = wb.worksheets[0]
        build_sheet(data, ws, header=header, widths=widths)
    return wb
434557
public DelimiterWriterFactory addColumnTitles(final Collection<String> columnTitles) {
        if (columnTitles != null) {
            for (final String columnTitle : columnTitles) {
                addColumnTitle(columnTitle);
            }
        }
        return this;
    }
302723
public static <T> Row writePerRow(Row row, T bean, List<String> properties, String dateFormat,
                                      CellStyle cellStyle) {
        Map<String, Object> mapBean = null;
        if (bean instanceof Map) {
            mapBean = (Map<String, Object>) bean;
        } else {
            mapBean = CommonUtils.toMap(bean);
        }
        if (mapBean == null) {
            return row;
        }
        for (int i = 0; i < properties.size(); i++) {
            if (mapBean.containsKey(properties.get(i))) {
                Cell cell = row.createCell(i);
                cell.setCellStyle(cellStyle);
                WriteExcelUtils.setCellValue(cell, mapBean.get(properties.get(i)), dateFormat);
            }

        }
        return row;
    }
136503
public static List<PersonBean> createExampleData(final int rows, final int documents) {
		List<PersonBean> data = new ArrayList<>(rows);

		Date date1 = DateUtilities.createDate(1, 2, 1973);
		Date date2 = DateUtilities.createDate(2, 3, 1985);
		Date date3 = DateUtilities.createDate(3, 4, 2004);

		for (int i = 1; i <= rows; i++) {
			PersonBean bean = new PersonBean("P" + i, "Joe" + i, "Bloggs" + i, date1);

			List<TravelDoc> docs = new ArrayList<>(documents);
			for (int j = 1; j <= documents; j++) {
				String prefix = i + "-" + j;
				TravelDoc doc = new TravelDoc("DOC" + prefix, "Canada" + prefix, "Ottawa" + prefix,
						date2, date3);
				docs.add(doc);
			}

			bean.setDocuments(docs);

			data.add(bean);
		}

		return data;
	}