Class TemplateContext

java.lang.Object
org.miaixz.bus.office.excel.writer.TemplateContext

public class TemplateContext extends Object
模板上下文,记录了模板中变量所在的Cell
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
    TemplateContext(org.apache.poi.ss.usermodel.Sheet templateSheet)
    构造
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    fill(Object rowDataBean, boolean isListVar)
    填充变量名name指向的单元格
    int
    获取当前替换的数据行对应变量的底部索引 此方法用户获取填充行,以便下移填充行后的行 如果为实体单元格,直接填充,无需下移,返回0 如果为VirtualCell,返回最底部虚拟单元格各行号
    org.apache.poi.ss.usermodel.Cell
    getCell(String varName)
    获取变量对应的单元格,列表变量以.开头
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TemplateContext

      public TemplateContext(org.apache.poi.ss.usermodel.Sheet templateSheet)
      构造
      Parameters:
      templateSheet - 模板sheet
  • Method Details

    • getCell

      public org.apache.poi.ss.usermodel.Cell getCell(String varName)
      获取变量对应的单元格,列表变量以.开头
      Parameters:
      varName - 变量名
      Returns:
      单元格
    • getBottomRowIndex

      public int getBottomRowIndex(Object rowDataBean)
      获取当前替换的数据行对应变量的底部索引 此方法用户获取填充行,以便下移填充行后的行
      • 如果为实体单元格,直接填充,无需下移,返回0
      • 如果为VirtualCell,返回最底部虚拟单元格各行号
      Parameters:
      rowDataBean - 填充数据
      Returns:
      最大行索引,-1表示无数据填充,0表示无需下移
    • fill

      public void fill(Object rowDataBean, boolean isListVar)
      填充变量名name指向的单元格
      Parameters:
      rowDataBean - 一行数据的键值对
      isListVar - 是否为列表填充,列表填充会自动指向下一列,否则填充结束后删除变量
    • toString

      public String toString()
      Overrides:
      toString in class Object