/*
final public static Method TO_EXCEL = new Method("toExcel", Types.EXCEL, new
Type[]{Types.OBJECT});
764488
@Override
    public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException {
	// Caster.toDecimal(null);
	GeneratorAdapter adapter = bc.getAdapter();
	char first = lcType.charAt(0);
	Type rtn;
	switch (first) {
	case 'a':
	    if ("array".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.ARRAY)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_ARRAY);
		return Types.ARRAY;
	    }
	    break;
	case 'b':
	    if ("base64".equals(lcType)) {
		expr.writeOut(bc, MODE_REF);
		adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_BASE64);
		return Types.STRING;
	    }
	    if ("binary".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.BYTE_VALUE_ARRAY)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_BINARY);
		return Types.BYTE_VALUE_ARRAY;
	    }
	    if ("byte".equals(type)) {
		rtn = expr.writeOutAsType(bc, MODE_VALUE);
		if (!rtn.equals(Types.BYTE_VALUE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_BYTE_VALUE[Types.getType(rtn)]);
		return Types.BYTE_VALUE;
	    }
	    if ("byte".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.BYTE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_BYTE[Types.getType(rtn)]);
		return Types.BYTE;
	    }
	    if ("boolean".equals(lcType)) {
		return ((ExpressionBase) bc.getFactory().toExprBoolean(expr)).writeOutAsType(bc, MODE_REF);
	    }
	    break;
	case 'c':
	    if ("char".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_VALUE);
		if (!rtn.equals(Types.CHAR)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_CHAR_VALUE[Types.getType(rtn)]);
		return Types.CHAR;
	    }
	    if ("character".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.CHARACTER)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_CHARACTER[Types.getType(rtn)]);
		return Types.CHARACTER;
	    }
	    if ("collection".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.COLLECTION)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_COLLECTION);
		return Types.COLLECTION;
	    }
	    if ("component".equals(lcType) || "class".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.COMPONENT)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_COMPONENT);
		return Types.COMPONENT;
	    }
	    break;
	case 'd':
	    if ("double".equals(lcType)) {
		return ((ExpressionBase) bc.getFactory().toExprDouble(expr)).writeOutAsType(bc, MODE_REF);
	    }
	    if ("date".equals(lcType) || "datetime".equals(lcType)) {
		// First Arg
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (rtn.equals(Types.DATE_TIME)) return Types.DATE_TIME;

		int type = Types.getType(rtn);

		// Second Arg
		adapter.loadArg(0);
		// adapter.invokeVirtual(Types.PAGE_CONTEXT,GET_CONFIG);
		// adapter.invokeInterface(Types.CONFIG_WEB,GET_TIMEZONE);
		adapter.invokeVirtual(Types.PAGE_CONTEXT, GET_TIMEZONE);

		adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_DATE[type]);
		return Types.DATE_TIME;
	    }
	    if ("decimal".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_DECIMAL[Types.getType(rtn)]);
		return Types.STRING;
	    }
	    break;
	case 'e':
	    /*
	     * if("excel".equals(type)) { expr.writeOut(bc,MODE_REF);
	     * adapter.invokeStatic(Types.EXCEL_UTIL,TO_EXCEL); return Types.EXCEL; }
	     */
	    break;
	case 'f':
	    if ("file".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.FILE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_FILE);
		return Types.FILE;
	    }
	    if ("float".equals(type)) {
		rtn = expr.writeOutAsType(bc, MODE_VALUE);
		if (!rtn.equals(Types.FLOAT_VALUE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_FLOAT_VALUE[Types.getType(rtn)]);
		return Types.FLOAT_VALUE;
	    }
	    if ("float".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.FLOAT)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_FLOAT[Types.getType(rtn)]);
		return Types.FLOAT;
	    }
	    break;
	case 'i':
	    if ("int".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_VALUE);
		if (!rtn.equals(Types.INT_VALUE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_INT_VALUE[Types.getType(rtn)]);
		return Types.INT_VALUE;
	    }
	    if ("integer".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.INTEGER)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_INTEGER[Types.getType(rtn)]);
		return Types.INTEGER;
	    }
	    /*
	     * ext.img if("image".equals(lcType)) { rtn=expr.writeOut(bc,MODE_REF); Type it =
	     * ImageUtil.getImageType(); if(!rtn.equals(it)) { adapter.loadArg(0);
	     * adapter.invokeStatic(it,Methods_Caster.TO_IMAGE); } return it; }
	     */
	    break;
	case 'j':

	    if ("java.lang.boolean".equals(lcType)) {
		return ((ExpressionBase) bc.getFactory().toExprBoolean(expr)).writeOutAsType(bc, MODE_REF);
	    }
	    if ("java.lang.double".equals(lcType)) {
		return ((ExpressionBase) bc.getFactory().toExprDouble(expr)).writeOutAsType(bc, MODE_REF);
	    }
	    if ("java.lang.string".equals(lcType)) {
		return ((ExpressionBase) bc.getFactory().toExprString(expr)).writeOutAsType(bc, MODE_REF);
	    }
	    if ("java.lang.stringbuffer".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.STRING_BUFFER)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_STRING_BUFFER);
		return Types.STRING_BUFFER;
	    }
	    if ("java.lang.byte".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.BYTE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_BYTE[Types.getType(rtn)]);
		return Types.BYTE;
	    }
	    if ("java.lang.character".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.CHARACTER)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_CHARACTER[Types.getType(rtn)]);
		return Types.CHARACTER;
	    }
	    if ("java.lang.short".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.SHORT)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_SHORT[Types.getType(rtn)]);
		return Types.SHORT;
	    }
	    if ("java.lang.integer".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.INTEGER)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_INTEGER[Types.getType(rtn)]);
		return Types.INTEGER;
	    }
	    if ("java.lang.long".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.LONG)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_LONG[Types.getType(rtn)]);
		return Types.LONG;
	    }
	    if ("java.lang.float".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.FLOAT)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_FLOAT[Types.getType(rtn)]);
		return Types.FLOAT;
	    }
	    if ("java.io.file".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.FILE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_FILE);
		return Types.FILE;
	    }
	    if ("java.lang.object".equals(lcType)) {
		return expr.writeOutAsType(bc, MODE_REF);
	    }
	    else if ("java.util.date".equals(lcType)) {
		// First Arg
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (rtn.equals(Types.DATE)) return Types.DATE;
		if (rtn.equals(Types.DATE_TIME)) return Types.DATE_TIME;

		// Second Arg
		adapter.loadArg(0);
		// adapter.invokeVirtual(Types.PAGE_CONTEXT,GET_CONFIG);
		// adapter.invokeVirtual(Types.CONFIG_WEB,GET_TIMEZONE);
		adapter.invokeVirtual(Types.PAGE_CONTEXT, GET_TIMEZONE);

		adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_DATE[Types.getType(rtn)]);
		return Types.DATE_TIME;
	    }
	    break;
	case 'l':
	    if ("long".equals(type)) {
		rtn = expr.writeOutAsType(bc, MODE_VALUE);
		if (!rtn.equals(Types.LONG_VALUE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_LONG_VALUE[Types.getType(rtn)]);
		return Types.LONG_VALUE;
	    }
	    else if ("long".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.LONG)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_LONG[Types.getType(rtn)]);
		return Types.LONG;
	    }
	    else if ("locale".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_LOCALE);
		return Types.LOCALE;
	    }
	    break;
	case 'n':
	    if ("node".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.NODE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_NODE);
		return Types.NODE;
	    }
	    else if ("null".equals(lcType)) {
		expr.writeOut(bc, MODE_REF);
		adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_NULL);
		// TODO gibt es einen null typ?
		return Types.OBJECT;
	    }
	    break;
	case 'o':
	    if ("object".equals(lcType) || "other".equals(lcType)) {
		expr.writeOut(bc, MODE_REF);
		return Types.OBJECT;
	    }
	    break;
	case 't':
	    if ("timezone".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_TIMEZONE);
		return Types.TIMEZONE;
	    }
	    else if ("timespan".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.TIMESPAN)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_TIMESPAN);
		return Types.TIMESPAN;
	    }
	    break;
	case 's':
	    if ("struct".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.STRUCT)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_STRUCT);
		return Types.STRUCT;
	    }
	    if ("short".equals(type)) {
		rtn = expr.writeOutAsType(bc, MODE_VALUE);
		if (!rtn.equals(Types.SHORT_VALUE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_SHORT_VALUE[Types.getType(rtn)]);
		return Types.SHORT_VALUE;
	    }
	    if ("short".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.SHORT)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_SHORT[Types.getType(rtn)]);
		return Types.SHORT;
	    }
	    if ("stringbuffer".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.STRING_BUFFER)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_STRING_BUFFER);
		return Types.STRING_BUFFER;
	    }
	    break;

	case 'x':
	    if ("xml".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.NODE)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_NODE);
		return Types.NODE;
	    }
	    break;
	default:
	    if ("query".equals(lcType)) {
		rtn = expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.QUERY)) adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_QUERY);
		return Types.QUERY;
	    }
	    if ("querycolumn".equals(lcType)) {
		rtn = (expr instanceof Variable) ? ((VariableImpl) expr).writeOutCollectionAsType(bc, mode) : expr.writeOutAsType(bc, MODE_REF);
		if (!rtn.equals(Types.QUERY_COLUMN)) {

		    adapter.loadArg(0);
		    adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_QUERY_COLUMN);
		}
		return Types.QUERY_COLUMN;
	    }
	}
	Type t = getType(type);

	expr.writeOut(bc, MODE_REF);
	adapter.checkCast(t);
	return t;
    }
1169569
static IDataModel toDataModel(final Workbook book, final ICellAddress address) {
        if (book == null || address == null) { return null; }
        if (address instanceof A1RangeAddress) { throw new CalculationEngineException("A1RangeAddress is not supported, only one cell can be converted to DataModel."); }
        
        Sheet s = book.getSheetAt(0); /* TODO: only one sheet is supported */
        Row r = s.getRow(address.a1Address().row());
        if (r == null) { return null; }
        Cell c = r.getCell(address.a1Address().column());
        if (c == null || CELL_TYPE_FORMULA != c.getCellType()) { return null; }

        return createDataModelFromCell(s, create((XSSFWorkbook) book), fromRowColumn(c.getRowIndex(), c.getColumnIndex()));
    }
526898
function () {
		
		var columns = this.columns,
			xColumns = [],
			type,
			options = this.options,
			series,
			data,
			i,
			j,
			r,
			seriesIndex,
			chartOptions,
			allSeriesBuilders = [],
			builder,
			freeIndexes,
			typeCol,
			index;

		xColumns.length = columns.length;
		if (options.complete || options.afterComplete) {

			// Get the names and shift the top row
			for (i = 0; i < columns.length; i++) {
				if (this.firstRowAsNames) {
					columns[i].name = columns[i].shift();
				}
			}
			
			// Use the next columns for series
			series = [];
			freeIndexes = this.getFreeIndexes(columns.length, this.valueCount.seriesBuilders);

			// Populate defined series
			for (seriesIndex = 0; seriesIndex < this.valueCount.seriesBuilders.length; seriesIndex++) {
				builder = this.valueCount.seriesBuilders[seriesIndex];

				// If the builder can be populated with remaining columns, then add it to allBuilders
				if (builder.populateColumns(freeIndexes)) {
					allSeriesBuilders.push(builder);
				}
			}

			// Populate dynamic series
			while (freeIndexes.length > 0) {
				builder = new SeriesBuilder();
				builder.addColumnReader(0, 'x');
				
				// Mark index as used (not free)
				index = inArray(0, freeIndexes);
				if (index !== -1) {
					freeIndexes.splice(index, 1);
				}

				for (i = 0; i < this.valueCount.global; i++) {
					// Create and add a column reader for the next free column index
					builder.addColumnReader(undefined, this.valueCount.globalPointArrayMap[i]);
				}

				// If the builder can be populated with remaining columns, then add it to allBuilders
				if (builder.populateColumns(freeIndexes)) {
					allSeriesBuilders.push(builder);
				}
			}

			// Get the data-type from the first series x column
			if (allSeriesBuilders.length > 0 && allSeriesBuilders[0].readers.length > 0) {
				typeCol = columns[allSeriesBuilders[0].readers[0].columnIndex];
				if (typeCol !== undefined) {
					if (typeCol.isDatetime) {
						type = 'datetime';
					} else if (!typeCol.isNumeric) {
						type = 'category';
					}
				}
			}
			// Axis type is category, then the "x" column should be called "name"
			if (type === 'category') {
				for (seriesIndex = 0; seriesIndex < allSeriesBuilders.length; seriesIndex++) {
					builder = allSeriesBuilders[seriesIndex];
					for (r = 0; r < builder.readers.length; r++) {
						if (builder.readers[r].configName === 'x') {
							builder.readers[r].configName = 'name';
						}
					}
				}
			}

			// Read data for all builders
			for (seriesIndex = 0; seriesIndex < allSeriesBuilders.length; seriesIndex++) {
				builder = allSeriesBuilders[seriesIndex];

				// Iterate down the cells of each column and add data to the series
				data = [];
				for (j = 0; j < columns[0].length; j++) { // TODO: which column's length should we use here
					data[j] = builder.read(columns, j);
				}

				// Add the series
				series[seriesIndex] = {
					data: data
				};
				if (builder.name) {
					series[seriesIndex].name = builder.name;
				}
				if (type === 'category') {
					series[seriesIndex].turboThreshold = 0;
				}
			}



			// Do the callback
			chartOptions = {
				series: series
			};
			if (type) {
				chartOptions.xAxis = {
					type: type
				};
			}
			
			if (options.complete) {
				options.complete(chartOptions);
			}

			// The afterComplete hook is used internally to avoid conflict with the externally
			// available complete option.
			if (options.afterComplete) {
				options.afterComplete(chartOptions);
			}
		}
	}
944086
public static CellValue fromObject(final Object o) {
		if (o == null)
			return new VoidValue();
		else if (o instanceof String)
			return new StringValue((String) o);
		else if (o instanceof Number) // BigDecimal, Byte, Short, Integer,
										// Long, Float, Double
			return new FloatValue((Number) o);
		else if (o instanceof Boolean)
			return new BooleanValue((Boolean) o);
		else if (o instanceof Date) // java.util.Date & java.sql.Date,
									// java.sql.Time, java.sql.Timestamp
			return new DateValue((Date) o);
		else if (o instanceof Calendar)
			return new DateValue(((Calendar) o).getTime());
		else // Byte[], ...
			return new StringValue(o.toString());
	}
376182
@Override
	public String convert(ObjectType sourceObject)
	{
		if(sourceObject == null)
			return null;
		
		String methodName = null;
		Object value =null;
		StringBuilder csv = new StringBuilder();
		Object[] args = {};
		Method m;

		
		for (Entry<String,Method> entry : this.methods.entrySet())
		{
			m = entry.getValue();
			methodName = m.getName();
			
			if(methodName.equals("getClass"))
				continue;
			
			try
			{
				value = m.invoke(sourceObject, args);
				
				if(csv.length() != 0)
					csv.append(SEPARATOR);
				
				csv.append(QUOTE).append(format(value)).append(QUOTE);
				
			}
			catch (IllegalAccessException|IllegalArgumentException|InvocationTargetException e)
			{
				throw new RuntimeException("Unable to get property for method:"+methodName+" error:"+e.getMessage(),e);
			}
		}
		
		csv.append(NEWLINE);
		
		return csv.toString();
		
	}
1072583
public Cell createCell(double value) {

        Cell cell = this.getNextCell(CellType.NUMERIC);
        cell.setCellValue(value);
        cell.setCellStyle(this.style.getNumberCs());
        return cell;
    }
256118
public Workbook writeToExcel(List<? extends Object> datas, boolean hasTitle, Workbook workbook,
                                 boolean transverse) {
        if (CollectionUtil.safeIsEmpty(datas)) {
            log.warn("给定数据集合为空");
            return workbook;
        }
        datas = datas.parallelStream().filter(data -> data != null).collect(Collectors.toList());
        if (datas.isEmpty()) {
            log.warn("给定数据集合里的数据全是空");
            return workbook;
        }
        //获取所有字段（包括父类的）
        Field[] fields = ReflectUtil.getAllFields(datas.get(0).getClass());

        log.info("获取可写入excel的字段");
        List<Field> writeFields = new ArrayList<>();
        for (Field field : fields) {
            String name = field.getName();
            log.debug("检查字段[{}]是否可以写入", name);
            Class<?> type = field.getType();

            List<ExcelDataWriter<?>> data = writers.values().stream()
                .filter(excelData -> excelData.writeable(type)).collect(Collectors.toList());
            if (data.isEmpty()) {
                log.info("字段[{}]不能写入", name);
            } else {
                log.info("字段[{}]可以写入excel");
                ExcelColumn column = field.getAnnotation(ExcelColumn.class);

                if (column == null || !column.ignore()) {
                    writeFields.add(field);
                }
            }
        }
        log.debug("可写入excel的字段集合为：[{}]", writeFields);
        log.debug("对可写入excel的字段集合排序");

        Collections.sort(writeFields, COMPARATOR);

        log.debug("可写入excel的字段集合排序完毕，构建标题列表");

        List<Writer<?>> titles = null;
        if (hasTitle) {
            log.info("当前需要标题列表，构建...");
            titles = new ArrayList<>(writeFields.size());
            for (int i = 0; i < writeFields.size(); i++) {
                Field field = writeFields.get(i);
                ExcelColumn column = field.getAnnotation(ExcelColumn.class);
                if (column == null || StringUtils.isEmpty(column.value())) {
                    titles.add(build(field.getName()));
                } else {
                    titles.add(build(column.value()));
                }
            }
        }

        log.debug("构建单元格数据");
        List<List<Writer<?>>> writeDatas = new ArrayList<>(datas.size());
        for (int i = 0; i < datas.size(); i++) {
            Object dataValue = datas.get(i);
            //构建一行数据
            List<Writer<?>> columnDatas = new ArrayList<>(writeFields.size());
            //加入
            writeDatas.add(columnDatas);
            for (int j = 0; j < writeFields.size(); j++) {
                Field field = writeFields.get(j);
                try {
                    log.debug("获取[{}]中字段[{}]的值", dataValue, field.getName());
                    Object value = field.get(dataValue);
                    columnDatas.add(build(value));
                } catch (IllegalAccessException e) {
                    log.warn("[{}]中字段[{}]不能读取", dataValue, field.getName(), e);
                    columnDatas.add(null);
                }
            }
        }

        log.debug("要写入的数据为：[{}]", writeDatas);
        log.info("准备写入数据");
        writeToExcel(titles, writeDatas, hasTitle, workbook, transverse);
        log.info("标题列表为：[{}]", titles);
        return workbook;
    }
602528
static <T extends FunctionMeta> Map<T, IDataModel> toMetaFunctions(Workbook book, Class<T> metaClass) {
        Map<T, IDataModel> map = new HashMap<>();

        book.addToolPack(Functions.getUdfFinder());
        final FormulaParsingWorkbook parsingBook = create((XSSFWorkbook) book);
        
        Sheet s = book.getSheetAt(0); /* TODO: only one sheet is supported */
        for (Row r : s) {
            for (Cell c : r) {
                if (c == null || CELL_TYPE_FORMULA != c.getCellType()) { continue; }
                
                try {
                    String formula = c.getCellFormula();
                    String keyword = metaClass.getAnnotation(FunctionMeta.MetaFunctionKeyword.class).value();

                    if (!formula.startsWith(keyword)) { continue; }

                    IDataModel dataModel = createDataModelFromCell(s, parsingBook, fromRowColumn(c.getRowIndex(), c.getColumnIndex()));
                    T meta = createAttributeFunctionMeta(metaClass, formula, dataModel);
                    
                    map.put(meta, dataModel);
                }
                catch (Exception e) { log.debug("Warning while parsing custom excel formula. It is OK.", e); }
            }
        }
        
        return map;
    }
958890
protected ConversionException newNotFoundCellConverterExpcetion(final Class<?> targetType) {
        return new ConversionException(
                MessageBuilder.create("cellConverter.notFound")
                    .varWithClass("classType", targetType)
                    .format(),
                targetType);
    }
281891
public void writeExcelFile() throws IOException, WriteException {
        WritableWorkbook excelWrkBook = null;
        int curDsPointer = 0;

        try {
            final String[] columnNames = ds.getColumns();
            final List<String> exportOnlyColumnsList = getExportOnlyColumns() != null ? Arrays.asList(exportOnlyColumns) : null;
            final List<String> excludeFromExportColumnsList = getExcludeFromExportColumns() != null ? Arrays.asList(excludeFromExportColumns) : null;
            final List<String> numericColumnList = getNumericColumns() != null ? Arrays.asList(getNumericColumns()) : new ArrayList<>();
            // get the current position of the DataSet. We have to go to the top
            // to do this write,
            // and we will put the pionter back where it was after we are done
            curDsPointer = ds.getIndex();
            ds.goTop();

            excelWrkBook = Workbook.createWorkbook(xlsFile);
            final WritableSheet wrkSheet = excelWrkBook.createSheet("results", 0);

            final WritableFont times10ptBold = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD);
            final WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10, WritableFont.NO_BOLD);
            // write the column headings in the spreadsheet
            WritableCellFormat cellFormat = new WritableCellFormat(times10ptBold);
            int colOffset = 0;
            for (int i = 0; i < columnNames.length; i++) {
                if (exportOnlyColumnsList != null && !exportOnlyColumnsList.contains(columnNames[i])
                        || excludeFromExportColumnsList != null && excludeFromExportColumnsList.contains(columnNames[i])) {
                    colOffset++;
                    continue;
                }

                final Label xlsTextLbl = new Label(i - colOffset, 0, columnNames[i], cellFormat);
                wrkSheet.addCell(xlsTextLbl);
            }

            cellFormat = new WritableCellFormat(times10pt);
            int row = 1;
            while (ds.next()) {
                if (!ds.isRecordID(FPConstants.DETAIL_ID)) {
                    continue;
                }

                colOffset = 0;
                for (int i = 0; i < columnNames.length; i++) {
                    if (exportOnlyColumnsList != null && !exportOnlyColumnsList.contains(columnNames[i])
                            || excludeFromExportColumnsList != null && excludeFromExportColumnsList.contains(columnNames[i])) {
                        colOffset++;
                        continue;
                    }

                    WritableCell wc = null;
                    if (numericColumnList.contains(columnNames[i])) {
                        wc = new Number(i - colOffset, row, ds.getDouble(columnNames[i]), cellFormat);
                    } else {
                        wc = new Label(i - colOffset, row, ds.getString(columnNames[i]), cellFormat);
                    }

                    wrkSheet.addCell(wc);
                }

                row++;
            }

            excelWrkBook.write();

        } finally {
            if (curDsPointer > -1) {
                ds.absolute(curDsPointer);
            }
            if (excelWrkBook != null) {
                excelWrkBook.close();
            }
        }

    }
79285
function cellToCellOffset(row, col) {
		var colCnt = t.getColCnt();

		// rtl variables. wish we could pre-populate these. but where?
		var dis = isRTL ? -1 : 1;
		var dit = isRTL ? colCnt - 1 : 0;

		if (typeof row == 'object') {
			col = row.col;
			row = row.row;
		}
		var cellOffset = row * colCnt + (col * dis + dit); // column, adjusted for RTL (dis & dit)

		return cellOffset;
	}
732989
public static void writeWorkBookToExcel(Workbook workbook, OutputStream os) throws WriteExcelException {
        try {
            workbook.write(os);
        } catch (IOException e) {
            throw new WriteExcelException(e.getMessage());
        }
    }
160260
static OutputStream toXlsxFile(final IDataSet dataSet, final InputStream formatting) {
        ByteArrayOutputStream xlsx = new ByteArrayOutputStream();
        
        try { toWorkbook(dataSet, ConverterUtils.newWorkbook(formatting)).write(xlsx); }
        catch (IOException e) { throw new CalculationEngineException(e); }
        
        return xlsx;
    }
1185627
public Workbook writeToExcel(List<? extends Object> datas, boolean hasTitle,
                                 Workbook workbook) {
        return writeToExcel(datas, hasTitle, workbook, false);
    }
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);
        }
    }
3996
public static <T> T[] toArray(Collection<T> col, Class<T> cls)
    {
        T[] arr = (T[]) Array.newInstance(cls, col.size());
        return col.toArray(arr);
    }
99765
static OutputStream toXlsxFile(final IDataModel dataModel) {
        ByteArrayOutputStream xlsx = new ByteArrayOutputStream();
        
        try { toWorkbook(dataModel, (Workbook) null).write(xlsx); }
        catch (IOException e) { throw new CalculationEngineException(e); }
        
        return xlsx;
    }