Search in sources :

Example 1 with TableColumn

use of com.xiaocai.demo.excel.oracle.vo.TableColumn in project springboot-demo by small-rose.

the class SelectController method columninfos.

@ApiOperation(value = "查表的列、类型、列注释", response = Map.class)
@GetMapping("/columninfos")
public Map columninfos(String schema, String tableName) {
    if (StringUtils.isEmpty(schema)) {
        schema = "PAYMT";
    }
    if (StringUtils.isEmpty(tableName)) {
        tableName = "T_APPLICATIONS";
    }
    List<TableColumn> columnInfos = oracleSelectService.getColumnInfo(schema, tableName);
    Map map = new HashMap(2);
    map.put("code", "200");
    map.put("data", columnInfos);
    return map;
}
Also used : HashMap(java.util.HashMap) TableColumn(com.xiaocai.demo.excel.oracle.vo.TableColumn) HashMap(java.util.HashMap) Map(java.util.Map) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with TableColumn

use of com.xiaocai.demo.excel.oracle.vo.TableColumn in project springboot-demo by small-rose.

the class ExcelFacadeService method addColumnInfos.

private void addColumnInfos(String schema, String fileName, List<TableInfo> allTables) {
    if (allTables.isEmpty()) {
        log.info(" allTables size is 0 ");
    }
    int index = 2;
    for (TableInfo tableInfo : allTables) {
        if (index == 4) {
            break;
        }
        ExcelWriter excelWriter = EasyExcel.write(fileName, TableColumn.class).build();
        List<TableColumn> columnInfos = oracleSelectService.getColumnInfo(schema, tableInfo.getTableName());
        WriteSheet writeSheet = EasyExcel.writerSheet(index, tableInfo.getTableName()).head(TableColumn.class).build();
        excelWriter.write(columnInfos, writeSheet);
        excelWriter.finish();
        index++;
    }
    System.out.println("=====执行完成=====");
}
Also used : ExcelWriter(com.alibaba.excel.ExcelWriter) WriteSheet(com.alibaba.excel.write.metadata.WriteSheet) TableInfo(com.xiaocai.demo.excel.oracle.vo.TableInfo) TableColumn(com.xiaocai.demo.excel.oracle.vo.TableColumn)

Aggregations

TableColumn (com.xiaocai.demo.excel.oracle.vo.TableColumn)2 ExcelWriter (com.alibaba.excel.ExcelWriter)1 WriteSheet (com.alibaba.excel.write.metadata.WriteSheet)1 TableInfo (com.xiaocai.demo.excel.oracle.vo.TableInfo)1 ApiOperation (io.swagger.annotations.ApiOperation)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1