类 Excel

java.lang.Object
cool.scx.ext.util.Excel

public final class Excel extends Object
todo : (注意 此工具类只支持单 sheet页的情况) 需要改为支持多个 sheet 页的情况 Excel 操作类 对 生成 excel 进行一些简单的封装 方便使用
版本:
0.9.1
作者:
scx567888
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    final Map<Integer,org.apache.poi.ss.usermodel.Row>
    行缓存 此处提前创建 row 方便后续直接根据索引使用
    final org.apache.poi.ss.usermodel.Sheet
    当前 sheet 后期会修改为 支持多个 sheet 页
    final org.apache.poi.ss.usermodel.Workbook
    Excel 实例
  • 方法概要

    修饰符和类型
    方法
    说明
    org.apache.poi.ss.usermodel.CellStyle
    创建单元格样式
    org.apache.poi.ss.usermodel.Font
    创建字体
    static Excel
    get03Excel(String sheetName, int rowSize)
    获取 03 版 excel (xls)
    static Excel
    get07Excel(String sheetName, int rowSize)
    获取 07 版 excel (xlsx)
    org.apache.poi.ss.usermodel.Row
    getRow(int rowIndex)
    根据索引获取行
    org.apache.poi.ss.usermodel.Sheet
    获取 sheet 页
    org.apache.poi.ss.usermodel.Sheet
    获取指定名称的 sheet
    org.apache.poi.ss.util.CellRangeAddress
    mergedRegion(int firstRow, int firstCol, int down, int right)
    合并单元格 注意 right 和 down 为合并大小 及 最终表格大小会是 right 和 down + 1 因为包括原始行
    org.apache.poi.ss.util.CellRangeAddress
    mergedRegion(org.apache.poi.ss.util.CellRangeAddress addresses)
    根据坐标合并单元格
    org.apache.poi.ss.util.CellRangeAddress
    setBorder(int firstRow, int firstCol)
    设置边框 (只设置一个单元格)*
    org.apache.poi.ss.util.CellRangeAddress
    setBorder(int firstRow, int lastRow, int firstCol, int lastCol)
    设置边框
    org.apache.poi.ss.util.CellRangeAddress
    setBorder(org.apache.poi.ss.util.CellRangeAddress cellAddresses)
    设置边框 根据坐标
    org.apache.poi.ss.usermodel.Cell
    setCellValue(int firstRow, int firstCol, String value)
    设置单元格样式
    org.apache.poi.ss.usermodel.Cell
    setCellValue(int firstRow, int firstCol, String value, org.apache.poi.ss.usermodel.CellStyle xssfCellStyle)
    设置单元格数据
    byte[]
    toBytes.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • workbook

      public final org.apache.poi.ss.usermodel.Workbook workbook
      Excel 实例
    • sheet

      public final org.apache.poi.ss.usermodel.Sheet sheet
      当前 sheet 后期会修改为 支持多个 sheet 页
    • rowMap

      public final Map<Integer,org.apache.poi.ss.usermodel.Row> rowMap
      行缓存 此处提前创建 row 方便后续直接根据索引使用
  • 方法详细资料

    • get03Excel

      public static Excel get03Excel(String sheetName, int rowSize)
      获取 03 版 excel (xls)
      参数:
      sheetName - sheet 名称
      rowSize - 初始的行大小 建议提前估算一个值 并设置为 估算值的 1.5倍
      返回:
      xls
    • get07Excel

      public static Excel get07Excel(String sheetName, int rowSize)
      获取 07 版 excel (xlsx)
      参数:
      sheetName - sheet 名称
      rowSize - 初始的行大小 建议提前估算一个值 并设置为 估算值的 1.5倍
      返回:
      xlsx
    • setBorder

      public org.apache.poi.ss.util.CellRangeAddress setBorder(int firstRow, int lastRow, int firstCol, int lastCol)
      设置边框
      参数:
      firstRow - 起始行
      lastRow - 结束行
      firstCol - 起始列
      lastCol - 结束列
      返回:
      返回坐标地址 方便链式调用
    • setBorder

      public org.apache.poi.ss.util.CellRangeAddress setBorder(org.apache.poi.ss.util.CellRangeAddress cellAddresses)
      设置边框 根据坐标
      参数:
      cellAddresses - 坐标
      返回:
      返回坐标地址 方便链式调用
    • setBorder

      public org.apache.poi.ss.util.CellRangeAddress setBorder(int firstRow, int firstCol)
      设置边框 (只设置一个单元格)*
      参数:
      firstRow - 起始行
      firstCol - 起始列
      返回:
      坐标
    • getSheet

      public org.apache.poi.ss.usermodel.Sheet getSheet()
      获取 sheet 页
      返回:
      当前 sheet
    • getSheet

      public org.apache.poi.ss.usermodel.Sheet getSheet(String name)
      获取指定名称的 sheet
      参数:
      name - a String object.
      返回:
      a Sheet object.
    • mergedRegion

      public org.apache.poi.ss.util.CellRangeAddress mergedRegion(int firstRow, int firstCol, int down, int right)
      合并单元格 注意 right 和 down 为合并大小 及 最终表格大小会是 right 和 down + 1 因为包括原始行
      参数:
      firstRow - 起始行 (纵向)
      firstCol - 起始列 (横向)
      down - 向下合并几个单元格 可以为负数
      right - 向左合并几个单元格 可以为负数
      返回:
      a CellRangeAddress object.
    • mergedRegion

      public org.apache.poi.ss.util.CellRangeAddress mergedRegion(org.apache.poi.ss.util.CellRangeAddress addresses)
      根据坐标合并单元格
      参数:
      addresses - a CellRangeAddress object.
      返回:
      a CellRangeAddress object.
    • setCellValue

      public org.apache.poi.ss.usermodel.Cell setCellValue(int firstRow, int firstCol, String value, org.apache.poi.ss.usermodel.CellStyle xssfCellStyle)
      设置单元格数据
      参数:
      firstRow - a int.
      firstCol - a int.
      value - a String object.
      xssfCellStyle - a CellStyle object.
      返回:
      a Cell object.
    • setCellValue

      public org.apache.poi.ss.usermodel.Cell setCellValue(int firstRow, int firstCol, String value)
      设置单元格样式
      参数:
      firstRow - a int.
      firstCol - a int.
      value - a String object.
      返回:
      a Cell object.
    • createCellStyle

      public org.apache.poi.ss.usermodel.CellStyle createCellStyle()
      创建单元格样式
      返回:
      a CellStyle object.
    • createFont

      public org.apache.poi.ss.usermodel.Font createFont()
      创建字体
      返回:
      a Font object.
    • getRow

      public org.apache.poi.ss.usermodel.Row getRow(int rowIndex)
      根据索引获取行
      参数:
      rowIndex - a int.
      返回:
      a Row object.
    • toBytes

      public byte[] toBytes()

      toBytes.

      返回:
      an array of
      引用无效
      byte
      objects