Java源码示例:com.ruoyi.common.annotation.Excel.Type

示例1
public void init(List<T> list, String sheetName, Type type)
{
    if (list == null)
    {
        list = new ArrayList<T>();
    }
    this.list = list;
    this.sheetName = sheetName;
    this.type = type;
    createExcelField();
    createWorkbook();
}
 
示例2
/**
 * 放到字段集合中
 */
private void putToField(Field field, Excel attr)
{
    if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
    {
        this.fields.add(new Object[] { field, attr });
    }
}
 
示例3
public void init(List<T> list, String sheetName, Type type)
{
    if (list == null)
    {
        list = new ArrayList<T>();
    }
    this.list = list;
    this.sheetName = sheetName;
    this.type = type;
    createExcelField();
    createWorkbook();
}
 
示例4
/**
 * 得到所有定义字段
 */
private void createExcelField()
{
    this.fields = new ArrayList<Field>();
    Field[] allFields = clazz.getDeclaredFields();
    // 得到所有field并存放到一个list中.
    for (Field field : allFields)
    {
        Excel attr = field.getAnnotation(Excel.class);
        if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
        {
            fields.add(field);
        }
    }
}
 
示例5
/**
 * 对list数据源将其里面的数据导入到excel表单
 * 
 * @param list 导出数据集合
 * @param sheetName 工作表的名称
 * @return 结果
 */
public AjaxResult exportExcel(List<T> list, String sheetName)
{
    this.init(list, sheetName, Type.EXPORT);
    return exportExcel();
}
 
示例6
/**
 * 对list数据源将其里面的数据导入到excel表单
 * 
 * @param sheetName 工作表的名称
 * @return 结果
 */
public AjaxResult importTemplateExcel(String sheetName)
{
    this.init(null, sheetName, Type.IMPORT);
    return exportExcel();
}
 
示例7
/**
 * 对list数据源将其里面的数据导入到excel表单
 * 
 * @param list 导出数据集合
 * @param sheetName 工作表的名称
 * @return 结果
 */
public AjaxResult exportExcel(List<T> list, String sheetName)
{
    this.init(list, sheetName, Type.EXPORT);
    return exportExcel();
}
 
示例8
/**
 * 对list数据源将其里面的数据导入到excel表单
 * 
 * @param sheetName 工作表的名称
 * @return 结果
 */
public AjaxResult importTemplateExcel(String sheetName)
{
    this.init(null, sheetName, Type.IMPORT);
    return exportExcel();
}