1 Star 1 Fork 0

xyxhbc / multilevel-excel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

multilevel-excel

项目介绍

使用循环 + 递归的方式,构造多级表头、多级数据的excel,并自动计算单元格的横向合并与纵向合并。可以将指定格式的json数据导出为excel,也可以将导出的excel还原为json数据

项目说明

  1. MultilevelExcelBuilder 负责数据的解析,只使用了 java.lang 和 java.util 包
  2. MultilevelExcelUtil 使用poi将解析后的数据生成excel,或读取excel数据供MultilevelExcelBuilder进行解析
  3. Main 运行main方法,使用测试数据演示多级数据的导出与导入

使用说明

  1. 指定表头结构
[
  {
    "key": "name",
    "title": "省份名称"
  },
  {
    "key": "code",
    "title": "行政区划码"
  },
  {
    "key": "children",
    "title": "地级市",
    "children": [
      {
        "key": "name",
        "title": "地级市名称"
      },
      {
        "key": "code",
        "title": "行政区划码"
      },
      {
        "key": "children",
        "title": "区县",
        "children": [
          {
            "key": "name",
            "title": "区县名称"
          },
          {
            "key": "code",
            "title": "行政区划码"
          },
          {
            "key": "children",
            "title": "乡镇",
            "children": [
              {
                "key": "name",
                "title": "乡镇名称"
              },
              {
                "key": "area",
                "title": "面积(平方千米)"
              }
            ]
          }
        ]
      }
    ]
  },
  {
    "key": "capital",
    "title": "省会"
  }
]
  1. 指定记录结构
[
  {
    "name": "江苏省",
    "code": "320000",
    "children": [
      {
        "name": "南京市",
        "code": "320100",
        "children": [
          {
            "name": "玄武区",
            "code": "320102",
            "children": [
              {
                "name": "新街口街道",
                "area": "2.6"
              },
              {
                "name": "红山街道",
                "area": "7.16"
              },
              {
                "name": "玄武湖街道",
                "area": "19.6"
              }
            ]
          },
          {
            "name": "浦口区",
            "code": "320111",
            "children": [
              {
                "name": "泰山街道",
                "area": "45"
              },
              {
                "name": "汤泉街道",
                "area": "3.35"
              }
            ]
          },
          {
            "name": "栖霞区",
            "code": "320113"
          },
          {
            "name": "高淳区",
            "code": "320118"
          }
        ]
      },
      {
        "name": "无锡市",
        "code": "320200"
      }
    ],
    "capital": "南京市"
  },
  {
    "name": "浙江省",
    "code": "330000",
    "capital": "杭州市",
    "children": [
      {
        "name": "杭州市",
        "code": "330100"
      }
    ]
  }
]
  1. 效果

项目背景

1.使用递归方式,构建多级表头、多级数据excel导入导出

2.目前测试过的最大数据层级为4级,还没有试过更多层级

3.如果对这个功能感兴趣,或有相似需求,欢迎使用此工具类

MIT License Copyright (c) 2024 xyxhbc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

使用循环 + 递归的方式,构造多级表头、多级数据的excel,并自动计算单元格的横向合并与纵向合并。可以将指定格式的json数据导出为excel,也可以将导出的excel还原为json数据 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/xyxhbc/multilevel-excel.git
git@gitee.com:xyxhbc/multilevel-excel.git
xyxhbc
multilevel-excel
multilevel-excel
master

搜索帮助