读取整个Excel文件,并把读取的数据放入beanMap中,全部返回

@param file  Excel文件
@param scale 指定若数值中含有小数则保留几位小数，四舍五入,null或者&lt;=0表示不四舍五入
@return 返回所有封装好的beanMap数据
@throws ReadExcelException
12026
public static List<Map<String, Object>> readExcelToMapList(File file, Integer scale) throws ReadExcelException {
        return XLSReader.readExcel(file, scale).getDatas();
    }
949528
public static boolean list2Xls(ExcelConfig config, List<?> list, OutputStream outputStream) throws Exception {
        try {
            String[] header = config.getHeaders();
            String[] names = config.getNames();
            String[] values;
            WritableWorkbook wb = Workbook.createWorkbook(outputStream);
            String sheetName = (config.getSheet() != null && !config.getSheet().equals("")) ? config.getSheet() : ("sheet" + config.getSheetNum());
            WritableSheet sheet = wb.createSheet(sheetName, 0);

            int row = 0;
            int column = 0;
            int rowadd = 0;
            //写入标题
            if (config.getHeader()) {
                for (column = 0; column < header.length; column++) {
                    sheet.addCell(new Label(column, row + rowadd, header[column]));
                    if (config.getColumn(column).getWidth() != null) {
                        sheet.setColumnView(column, config.getColumn(column).getWidth() / 7);
                    }
                }
                rowadd++;
            }
            //写入内容//行
            for (row = 0; row < list.size(); row++) {
                Object rowData = list.get(row);
                values = getObjValues(rowData, names);
                //列
                for (column = 0; column < values.length; column++) {
                    sheet.addCell(new Label(column, row + rowadd, values[column]));
                }
            }
            wb.write();
            wb.close();
        } catch (Exception e1) {
            return false;
        }
        return true;
    }
39399
private void importFromCsv(File importFile){

        final AtomicInteger imported= new AtomicInteger();
        final AtomicInteger failed= new AtomicInteger();
        FileReader fileReader = null;
        try {
            fileReader = new FileReader(importFile);
            CSVReader reader = new CSVReader(fileReader);
            String[] nextLine = reader.readNext();
            while ((nextLine = reader.readNext()) != null) {
                // nextLine[] is an array of values from the line
                try {
                    String lat = nextLine[0];
                    String lon = nextLine[1];
                    String description = nextLine[2];
                    String title = nextLine[3];
                    Marker m = new Marker(getmMapView());
                    m.setTitle(title);
                    m.setSubDescription(description);
                    m.setPosition(new GeoPoint(Double.parseDouble(lat), Double.parseDouble(lon)));
                    datastore.addBookmark(m);
                    getmMapView().getOverlayManager().add(m);
                    imported.getAndIncrement();
                }catch (Exception ex) {
                    ex.printStackTrace();
                    failed.getAndIncrement();
                }
            }
        }catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            if (fileReader!=null)
                try {
                    fileReader.close();
                }catch (Exception ex) {}
        }

        final Activity act = getActivity();
        if (act!=null) {
            act.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(act,"Import Complete: " + imported.get() + "/" + failed.get() + "(imported/failed)", Toast.LENGTH_LONG).show();
                }
            });
        }
    }
118375
public static List<Map<String, Object>> readExcelToMapList(File file) throws ReadExcelException {
        return XLSReader.readExcelToMapList(file, null);
    }
1057701
public static String readFile( File file ) throws IOException {
        if (!file.exists()) {
            throw new FileNotFoundException("The required projection file is not available: " + file.getAbsolutePath());
        }
        try (BufferedReader br = new BufferedReader(new FileReader(file))) {
            StringBuilder sb = new StringBuilder(200);
            String line;
            while( (line = br.readLine()) != null ) {
                sb.append(line);
                sb.append("\n"); //$NON-NLS-1$
            }
            return sb.toString();
        }
    }
659455
public static void updateMetadata(final File file, final PropertyMap map, final boolean calcChecksums) throws FrameworkException {

		final java.io.File fileOnDisk = file.getFileOnDisk(false);

		if (fileOnDisk != null && fileOnDisk.exists()) {

			try {

				final PropertyKey<Long> fileModificationDateKey = StructrApp.key(File.class, "fileModificationDate");
				final PropertyKey<String> contentTypeKey        = StructrApp.key(File.class, "contentType");
				final PropertyKey<Long> sizeKey                 = StructrApp.key(File.class, "size");

				String contentType = file.getContentType();

				// Don't overwrite existing MIME type
				if (StringUtils.isBlank(contentType)) {

					try {

						contentType = getContentMimeType(file);
						map.put(contentTypeKey, contentType);

					} catch (IOException ex) {
						logger.debug("Unable to detect content MIME type", ex);
					}
				}

				map.put(fileModificationDateKey, fileOnDisk.lastModified());

				if (calcChecksums) {
					map.putAll(getChecksums(file, fileOnDisk));
				}

				if (contentType != null) {

					// modify type when image type is detected AND the type is "File"
					if (contentType.startsWith("image/") && Boolean.FALSE.equals(Image.class.isAssignableFrom(file.getClass())) && File.class.getSimpleName().equals(file.getClass().getSimpleName())) {
						map.put(AbstractNode.type, Image.class.getSimpleName());
					}
				}

				long fileSize = FileHelper.getSize(fileOnDisk);
				if (fileSize > 0) {

					map.put(sizeKey, fileSize);
				}

				file.unlockSystemPropertiesOnce();
				file.setProperties(file.getSecurityContext(), map);

			} catch (IOException ioex) {
				logger.warn("Unable to access {} on disk: {}", fileOnDisk, ioex.getMessage());
			}
		}
	}
751549
public static void scale(double[][] x, double lo, double hi) {
        int n = x.length;
        int p = x[0].length;

        double[] min = colMin(x);
        double[] max = colMax(x);

        for (int j = 0; j < p; j++) {
            double scale = max[j] - min[j];
            if (!Math.isZero(scale)) {
                for (int i = 0; i < n; i++) {
                    x[i][j] = (x[i][j] - min[j]) / scale;
                }
            } else {
                for (int i = 0; i < n; i++) {
                    x[i][j] = 0.5;
                }
            }
        }
    }
23450
private void readObject(java.io.ObjectInputStream s)
        throws java.io.IOException, ClassNotFoundException {
        // Read in all fields
        s.defaultReadObject();
        // validate possibly bad fields
        if (intVal == null) {
            String message = "BigDecimal: null intVal in stream";
            throw new java.io.StreamCorruptedException(message);
        // [all values of scale are now allowed]
        }
        UnsafeHolder.setIntCompactVolatile(this, compactValFor(intVal));
    }
115233
public static void scale(ImageInputStream srcStream, ImageOutputStream destStream, float scale) {
		scale(read(srcStream), destStream, scale);
	}
406843
public int[][] fromFile(File file) throws IOException {
        BufferedImage image = ImageIO.read(file);
        image = scalingIfNeed(image, true);
        return toIntArrayArray(image);
    }
805886
public static Properties readPropertiesFile(final File file) {
		if (!file.exists()) {
			JKIOUtil.logger.info(String.format("File %s doesnot exists , return empty map", file.getName()));
			return new Properties();
		}
		try {
			InputStream in = new FileInputStream(file);
			if (in != null) {
				return readPropertiesStream(in);
			}
		} catch (IOException e) {
			JKExceptionUtil.handle(e);
		}
		return null;
	}
947339
public void setScale(double scale)
    {
        if(scale <= 0 || Double.isNaN(scale) || Double.isInfinite(scale))
            throw new ArithmeticException("Scale must be a positive value, not " + scale);
        this.scale = scale;
        this.logScale = log(scale);
    }
1204888
public static MappedByteBuffer map(File file) {
        N.checkArgNotNull(file);

        return map(file, MapMode.READ_ONLY);
    }
728992
public static void scale(File srcImageFile, File destImageFile, float scale) {
		scale(read(srcImageFile), destImageFile, scale);
	}
936941
public static List<TransformationDescription> getDescriptionsFromXMLFile(File file) {
        List<TransformationDescription> desc = new ArrayList<TransformationDescription>();
        try {
            return loadDescrtipionsFromXMLInputSource(new InputSource(file.getAbsolutePath()), file.getName());
        } catch (Exception e) {
            LOGGER.error("Unable to read the descriptions from file " + file.getAbsolutePath(), e);
        }
        return desc;
    }
648078
public static String readTextFile(File file) {
        try {
            return readTextFile(new FileReader(file));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
1016636
@SneakyThrows
    private void processExcelCellAnnotation(Field field, Object bean) {
        val ann = field.getAnnotation(ExcelCell.class);
        if (ann == null) return;

        Object fv = Fields.invokeField(field, bean);

        if (ann.sheetName()) {
            if (StringUtils.isNotEmpty(ann.replace())) { // 有内容需要替换
                fv = sheet.getSheetName().replace(ann.replace(), Str.nullThen(fv, ""));
            }

            val wb = sheet.getWorkbook();
            val oldSheetName = sheet.getSheetName();
            val newSheetName = "" + fv;
            wb.setSheetName(wb.getSheetIndex(sheet), newSheetName);

            PoiUtil.fixChartSheetNameRef(sheet, oldSheetName, newSheetName);
        } else {
            val cell = PoiUtil.findCell(sheet, ann.value(), StringUtils.defaultIfEmpty(ann.searchKey(), "{" + field.getName() + "}"));
            if (cell == null) {
                log.warn("unable to find cell for {} in field {}", ann, field);
                return;
            }

            if (StringUtils.isNotEmpty(ann.replace())) { // 有内容需要替换
                val old = PoiUtil.getCellStringValue(cell);
                fv = old.replace(ann.replace(), Str.nullThen(fv, ""));
            }

            applyTemplateCellStyle(field, bean, ann, cell);

            val strCellValue = PoiUtil.writeCellValue(cell, fv);
            fixMaxRowHeightRatio(cell.getRow(), ann.maxLineLen(), strCellValue);
        }
    }