类 ExcelUtil

java.lang.Object
org.anyline.poi.excel.ExcelUtil

public class ExcelUtil extends Object
  • 字段详细资料

  • 构造器详细资料

    • ExcelUtil

      public ExcelUtil()
  • 方法详细资料

    • read

      public static List<List<String>> read(File file, int sheet, int rows, int foot)
      读取指定Sheet也的内容
      参数:
      file - file 文件
      sheet - sheet序号,从0开始
      rows - 从第几行开始读取
      foot - 到第几行结束(如果负数表示 表尾有多少行不需要读取)
      返回:
      List
    • read

      public static List<List<String>> read(File file, int sheet, int rows)
      读取指定Sheet也的内容
      参数:
      file - file 文件
      sheet - sheet序号,从0开始
      rows - 从第几行开始读取
      返回:
      List
    • position

      public static int[] position(org.apache.poi.ss.usermodel.Sheet sheet, int rows, int cols, String regex)
    • position

      public static int[] position(InputStream is, int sheet, int rows, int cols, String regex)
      根据内容(正则)定位单元格
      参数:
      is - 文件
      sheet - sheet
      rows - 开始行
      cols - 开始列
      regex - 匹配内容
      返回:
      int[]
    • position

      public static int[] position(InputStream is, String sheet, int rows, int cols, String regex)
    • position

      public static int[] position(InputStream is, int sheet, String regex)
    • position

      public static int[] position(InputStream is, String sheet, String regex)
    • position

      public static int[] position(InputStream is, String regex)
    • position

      public static int[] position(File file, int sheet, int rows, int cols, String regex)
    • position

      public static int[] position(File file, String sheet, int rows, int cols, String regex)
    • position

      public static int[] position(File file, int sheet, String regex)
    • position

      public static int[] position(File file, String sheet, String regex)
    • position

      public static int[] position(File file, String regex)
    • read

      public static List<List<String>> read(InputStream is, int sheet, int rows)
      读取指定Sheet也的内容
      参数:
      is - 输入流
      sheet - sheet序号,从0开始
      rows - 从第几行开始读取
      返回:
      List
    • read

      public static List<List<String>> read(InputStream is, int sheet, int rows, int foot)
    • read

      public static List<List<String>> read(File file, int sheet)
      读取指定Sheet也的内容
      参数:
      file - file 文件
      sheet - sheet序号,从0开始
      返回:
      List
    • read

      public static List<List<String>> read(InputStream is, int sheet)
    • read

      public static List<List<String>> read(File file)
      读取excel
      参数:
      file - 文件 第0个sheet第0行开始读取
      返回:
      list
    • read

      public static List<List<String>> read(InputStream is)
    • read

      public static List<List<String>> read(File file, String sheet, int rows)
      读取excel
      参数:
      file - 文件
      sheet - sheet
      rows - 从rows行开始读取
      返回:
      list
    • read

      public static List<List<String>> read(File file, String sheet, int rows, int foot)
      读取excel
      参数:
      file - 文件
      sheet - sheet
      rows - 从rows行开始读取
      foot - 到第几行结束(如果负数表示 表尾有多少行不需要读取)
      返回:
      list
    • read

      public static List<List<String>> read(InputStream is, String sheet, int rows, int foot)
    • read

      public static List<List<String>> read(InputStream is, String sheet, int rows)
    • read

      public static List<List<String>> read(File file, String sheet)
      读取excel
      参数:
      file - 文件
      sheet - sheet
      返回:
      list
    • read

      public static List<List<String>> read(InputStream is, String sheet)
    • getWorkbook

      public static org.apache.poi.ss.usermodel.Workbook getWorkbook(File file) throws org.apache.poi.EncryptedDocumentException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, IOException
      抛出:
      org.apache.poi.EncryptedDocumentException
      org.apache.poi.openxml4j.exceptions.InvalidFormatException
      IOException
    • getWorkbook

      public static org.apache.poi.ss.usermodel.Workbook getWorkbook(InputStream is) throws org.apache.poi.EncryptedDocumentException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, IOException
      抛出:
      org.apache.poi.EncryptedDocumentException
      org.apache.poi.openxml4j.exceptions.InvalidFormatException
      IOException
    • read

      public static List<List<String>> read(org.apache.poi.ss.usermodel.Sheet sheet, int start, int end)
      读取sheet
      参数:
      sheet - sheet
      start - 从第rows行开始
      end - 到第几行结束(如果负数表示 表尾有多少行不需要读取)
      返回:
      List
    • isMerged

      public static boolean isMerged(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col)
      判断指定的单元格是否是合并单元格
      参数:
      sheet - sheet
      row - 行下标
      col - 列下标
      返回:
      boolean
    • getMergedRegionValue

      public static String getMergedRegionValue(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col)
      获取合并单元格的值
      参数:
      sheet - sheet
      row - row
      col - col
      返回:
      String
    • values

      public static List<String> values(File file, int sheet, int row)
      读取1行数据
      参数:
      file - 文件
      sheet - sheet
      row - 行
      返回:
      List
    • values

      public static List<String> values(InputStream is, int sheet, int row)
    • values

      public static List<String> values(InputStream is, int row)
    • values

      public static List<String> values(File file, int row)
    • values

      public static List<String> values(File file, String sheet, int row)
    • values

      public static List<String> values(InputStream is, String sheet, int row)
    • values

      public static List<String> values(org.apache.poi.ss.usermodel.Sheet sheet, int row)
    • values

      public static List<String> values(String path, int sheet, int row)
    • values

      public static List<String> values(String path, String sheet, int row)
    • values

      public static List<String> values(String path, int row)
    • value

      public static String value(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col)
    • value

      public static String value(String path, int sheet, int row, int col)
    • value

      public static String value(org.apache.poi.ss.usermodel.Workbook workbook, int sheet, int row, int col)
    • value

      public static String value(org.apache.poi.ss.usermodel.Workbook workbook, String sheet, int row, int col)
    • value

      public static String value(File file, int sheet, int row, int col)
    • value

      public static String value(File file, String sheet, int row, int col)
    • value

      public static String value(InputStream is, int sheet, int row, int col)
    • value

      public static String value(InputStream is, String sheet, int row, int col)
    • value

      public static String value(InputStream is, int row, int col)
    • value

      public static void value(String path, int sheet, int row, int col, String value)
    • value

      public static void value(String path, int row, int col, String value)
    • value

      public static void value(String path, String sheet, int row, int col, String value)
    • value

      public static void value(File file, int sheet, int row, int col, String value)
    • value

      public static void value(File file, String sheet, int row, int col, String value)
    • value

      public static void value(String path, int sheet, int row, int col, double value)
    • value

      public static void value(String path, int row, int col, double value)
    • value

      public static void value(String path, String sheet, int row, int col, double value)
    • value

      public static void value(File file, int sheet, int row, int col, double value)
    • value

      public static void value(File file, String sheet, int row, int col, double value)
    • value

      public static void value(String path, int sheet, int row, int col, int value)
    • value

      public static void value(String path, String sheet, int row, int col, int value)
    • value

      public static void value(File file, int sheet, int row, int col, int value)
    • value

      public static void value(File file, String sheet, int row, int col, int value)
    • value

      public static void value(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col, String value)
    • value

      public static void value(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col, double value)
    • value

      public static void value(org.apache.poi.ss.usermodel.Sheet sheet, int row, int col, int value)
    • value

      public static String value(org.apache.poi.ss.usermodel.Cell cell)
    • export

      public static boolean export(OutputStream os, String sheet, int insert, List<String> headers, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      os - 输出流
      sheet - sheet
      insert - 导出的开始位置
      headers - 表头 headers 表头
      keys - 对应列名属性名 keys 对应列名属性名
      set - 数据源 set 数据源
      返回:
      boolean
    • export

      public static boolean export(File file, String sheet, int insert, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File file, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File file, String sheet, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File template, OutputStream os, String sheet, int insert, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File template, File file, String sheet, int insert, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File template, File file, int sheet, int insert, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File template, OutputStream os, org.anyline.entity.html.Table table)
    • export

      public static boolean export(OutputStream os, String sheet, int insert, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File file, int rows, List<String> headers, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      rows - 开始写入的行数
      headers - 表头
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(OutputStream os, int rows, List<String> headers, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File file, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(OutputStream os, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File file, List<String> headers, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      headers - 表头
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(OutputStream os, List<String> headers, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File file, int rows, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      rows - 从第几行开始写入
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(OutputStream os, int rows, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File file, String sheet, int rows, Collection<?> set, String... configs)
      导出excel
      参数:
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      sheet - sheet 如果文件存在 并且为空时 则取第0个sheet
      rows - 行数
      set - 数据
      configs - 姓名:NAME或NAME
      返回:
      boolean
    • export

      public static boolean export(OutputStream os, String sheet, int rows, Collection<?> set, String... configs)
    • export

      public static boolean export(File file, int rows, Collection<?> set, String... configs)
      导出excel
      参数:
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      rows - 行数
      set - 数据
      configs - 姓名:NAME或NAME
      返回:
      boolean
    • export

      public static boolean export(OutputStream os, int rows, Collection<?> set, String... configs)
    • export

      public static boolean export(File file, Collection<?> set, String... configs)
      导出excel
      参数:
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      set - 数据
      configs - 姓名:NAME或NAME
      返回:
      boolean
    • export

      public static boolean export(OutputStream os, Collection<?> set, String... configs)
    • export

      public static boolean export(File template, File file, String sheet, int insert, List<String> headers, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      template - 模板
      file - 导致文件位置
      sheet - sheet
      insert - 导出的开始位置
      headers - 表头 headers 表头
      keys - 对应列名属性名 keys 对应列名属性名
      set - 数据源 set 数据源
      返回:
      boolean
    • export

      public static boolean export(File file, String sheet, int insert, List<String> headers, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File template, OutputStream os, String sheet, int insert, List<String> headers, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File template, File file, int rows, List<String> headers, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      template - template
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      rows - 开始写入的行数
      headers - 表头
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(File template, OutputStream os, int rows, List<String> headers, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File template, File file, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      template - template
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(File template, OutputStream os, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File template, File file, List<String> headers, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      template - template
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      headers - 表头
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(File template, OutputStream os, List<String> headers, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File template, File file, int insert, List<String> keys, Collection<?> set)
      导出EXCEL
      参数:
      template - template
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      insert - 从第几行开始写入
      keys - 读取集合条目的属性
      set - 数据集合
      返回:
      boolean
    • export

      public static boolean export(File template, OutputStream os, int insert, List<String> keys, Collection<?> set)
    • export

      public static boolean export(File template, File file, String sheet, int rows, Collection<?> set, String... configs)
      导出excel
      参数:
      template - template
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      sheet - sheet 如果文件存在 并且为空时 则取第0个sheet
      rows - 行数
      set - 数据
      configs - 姓名:NAME或NAME
      返回:
      boolean
    • export

      public static boolean export(File template, OutputStream os, String sheet, int insert, Collection<?> set, String... configs)
    • export

      public static boolean export(File template, File file, int insert, Collection<?> set, String... configs)
      导出excel
      参数:
      template - template
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      insert - 开始插入的位置
      set - 数据
      configs - 姓名:NAME或NAME
      返回:
      boolean
    • export

      public static boolean export(File template, File file, int insert, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File template, OutputStream os, int insert, Collection<?> set, String... configs)
    • export

      public static boolean export(File template, OutputStream os, int insert, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File template, File file, Collection<?> set, String... configs)
      导出excel
      参数:
      template - template
      file - 导致文件位置,如果文件已存存,则以当前文件作为模板
      set - 数据
      configs - 姓名:NAME或NAME
      返回:
      boolean
    • export

      public static boolean export(File template, File file, org.anyline.entity.html.Table table)
    • export

      public static boolean export(File template, OutputStream os, Collection<?> set, String... configs)
    • merge

      public static boolean merge(org.apache.poi.ss.usermodel.Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol)