All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bing.excel.core.BingExcel Maven / Gradle / Ivy

package com.bing.excel.core;

import com.bing.excel.converter.FieldValueConverter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.SQLException;
import java.util.List;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.xml.sax.SAXException;

import com.bing.excel.core.impl.BingExcelImpl;


/**
 * 操作excel的类,需要poi3.13的jar包
* maven地址,目前仅支持03版本 *

* <dependency>
*  <groupId>org.apache.poi</groupId>
*  <artifactId>poi</artifactId>
*   <version>3.8</version>
* </dependency> *

* * @author shizhongtao * * 2015 2015-4-24 下午5:49:55 * */ public interface BingExcel { /** *

* Title: readFileToList</p> *

* Description:读取excel 的第一个sheet页到list</p> * * @param file excel对应的文件 * @param clazz 要转换类型的class对象 * @param startRowNum 从第几行开始读取 * @return * @throws Exception */ BingExcelImpl.SheetVo readFile(File file, Class clazz, int startRowNum) throws Exception ; /** * 根据condition条件读取相应的sheet到list对象 * @param file * @param condition * @return * @throws Exception */ BingExcelImpl.SheetVo readFile(File file, ReaderCondition condition) throws Exception ; /** * 读取所condition 对应 sheet表格,到list * @param file * @param conditions 每个表格对应的condition,注:对于返回的条数,取conditions中 endNum的最小值 * @return sheetVo的list对象,如果没有符合conditions的结果,返回empetyList对象 * @throws Exception */ List readFileToList(File file, ReaderCondition[] conditions) throws Exception ; BingExcelImpl.SheetVo readStream(InputStream stream, ReaderCondition condition) throws InvalidFormatException, IOException, SQLException, OpenXML4JException, SAXException ; /** * read sheet witch index equal 0 * @param stream * @return * @throws SQLException * @throws IOException * @throws InvalidFormatException * @throws SAXException */ BingExcelImpl.SheetVo readStream(InputStream stream, Class clazz, int startRowNum) throws InvalidFormatException, IOException, SQLException ,OpenXML4JException, SAXException; /** * read sheets * @param stream * @param condition * @return * @throws InvalidFormatException * @throws IOException * @throws SQLException * @throws OpenXML4JException * @throws SAXException */ List readStreamToList(InputStream stream, ReaderCondition[] condition) throws InvalidFormatException, IOException, SQLException, OpenXML4JException, SAXException ; /** * 输出model集合到excel 文件。 * @param iterables 要输出到文件的集合对象, * @param file 文件对象 */ void writeExcel(File file,Iterable... iterables)throws FileNotFoundException; void writeOldExcel(File file,Iterable... iterables)throws FileNotFoundException; /** * 输出model集合到excel 文件。 * @param iterables * @param path 文件路径 */ void writeExcel(String path,Iterable... iterables); /** * 写出xls格式的excel文件 * @param path * @param iterables */ void writeOldExcel(String path,Iterable... iterables); /** * 写出xls格式的excel到输出流 * @param stream * @param iterables */ void writeExcel(OutputStream stream,Iterable... iterables); void writeOldExcel(OutputStream stream,Iterable... iterables); void writeCSV(String path,Iterable iterable) throws IOException; void writeCSV(OutputStream os,Iterable iterable) throws IOException; void modelName(Class clazz, String alias); void fieldConverter(Class clazz, String filedName, int index, String alias, FieldValueConverter converter); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy