|
| 1 | +<!-- |
| 2 | +- Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +- contributor license agreements. See the NOTICE file distributed with |
| 4 | +- this work for additional information regarding copyright ownership. |
| 5 | +- The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +- (the "License"); you may not use this file except in compliance with |
| 7 | +- the License. You may obtain a copy of the License at |
| 8 | +- |
| 9 | +- http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +- |
| 11 | +- Unless required by applicable law or agreed to in writing, software |
| 12 | +- distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +- See the License for the specific language governing permissions and |
| 15 | +- limitations under the License. |
| 16 | +--> |
| 17 | + |
| 18 | +<p align="center"> |
| 19 | + <img src="logo.svg"/> |
| 20 | +</p> |
| 21 | + |
| 22 | +# Apache Fesod (Incubating) |
| 23 | + |
| 24 | +[](https://github.com/apache/fesod/actions/workflows/ci.yml) |
| 25 | +[](https://github.com/apache/fesod/actions/workflows/nightly.yml) |
| 26 | +[](https://github.com/apache/fesod/blob/main/LICENSE) |
| 27 | + |
| 28 | +[](https://fesod.apache.org/) |
| 29 | +[](https://deepwiki.com/apache/fesod) |
| 30 | + |
| 31 | +## 简介 |
| 32 | + |
| 33 | +**Apache Fesod (Incubating)** 是一个高性能、内存高效的 Java 库,用于读写 Excel 文件,旨在简化开发并确保可靠性。 |
| 34 | + |
| 35 | +Apache Fesod (Incubating) 可以为开发者和企业提供极大的自由度和灵活性。我们计划在未来引入更多新功能,以持续提升用户体验和工具可用性。Apache Fesod (Incubating) 致力于成为您处理 Excel 文件的最佳选择。 |
| 36 | + |
| 37 | +名称 fesod(发音为 `/ˈfɛsɒd/`),是 "fast easy spreadsheet and other documents"(快速简单的电子表格和其他文档)的首字母缩写,表达了项目的起源、背景和愿景。 |
| 38 | + |
| 39 | +### 特性 |
| 40 | + |
| 41 | +- **高性能读写**:Apache Fesod (Incubating) 专注于性能优化,能够高效处理大规模 Excel 数据。与一些传统的 Excel 处理库相比,它可以显著减少内存消耗。 |
| 42 | +- **简单易用**:该库提供了简单直观的 API,使开发者能够轻松将其集成到项目中,无论是简单的 Excel 操作还是复杂的数据处理。 |
| 43 | +- **流式操作**:Apache Fesod (Incubating) 支持流式读取,最大程度地减少一次性加载大量数据的问题。这一设计在处理数十万甚至数百万行数据时尤其重要。 |
| 44 | + |
| 45 | +## 安装 |
| 46 | + |
| 47 | +Apache Fesod (Incubating) 需要 **Java 1.8** 或更高版本。建议使用最新的 LTS 版本的 Java。我们强烈建议使用最新版本的 Apache Fesod (Incubating),因为最新版本中的性能优化、错误修复和新功能将提升您的使用体验。 |
| 48 | + |
| 49 | +> 目前,Apache Fesod (Incubating) 使用 POI 作为底层包。如果您的项目已包含 POI 相关组件,您需要手动排除 POI 相关的 jar 文件。 |
| 50 | +
|
| 51 | +> 我们目前正在准备 Apache 孵化器下的第一个版本。当前的版本都是非 Apache 版本。您可以通过此链接查看之前的版本:https://fesod.apache.org/docs/quickstart/guide/ |
| 52 | +
|
| 53 | +### Maven |
| 54 | + |
| 55 | +如果使用 Maven 进行项目构建,请在 `pom.xml` 文件中添加以下配置: |
| 56 | + |
| 57 | +```xml |
| 58 | + |
| 59 | +<dependency> |
| 60 | + <groupId>org.apache.fesod</groupId> |
| 61 | + <artifactId>fesod</artifactId> |
| 62 | + <version>version</version> |
| 63 | +</dependency> |
| 64 | +``` |
| 65 | + |
| 66 | +### Gradle |
| 67 | + |
| 68 | +如果使用 Gradle 进行项目构建,请在 build.gradle 文件中添加以下配置: |
| 69 | + |
| 70 | +```gradle |
| 71 | +dependencies { |
| 72 | + implementation 'org.apache.fesod:fesod:version' |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +## 快速开始 |
| 77 | + |
| 78 | +### 读取 |
| 79 | + |
| 80 | +以下是读取 Excel 文档的示例: |
| 81 | + |
| 82 | +```java |
| 83 | +// 实现 ReadListener 接口以设置读取数据的操作 |
| 84 | +public class DemoDataListener implements ReadListener<DemoData> { |
| 85 | + |
| 86 | + @Override |
| 87 | + public void invoke(DemoData data, AnalysisContext context) { |
| 88 | + System.out.println("解析了一条数据" + JSON.toJSONString(data)); |
| 89 | + } |
| 90 | + |
| 91 | + @Override |
| 92 | + public void doAfterAllAnalysed(AnalysisContext context) { |
| 93 | + System.out.println("所有数据解析完成!"); |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +public static void main(String[] args) { |
| 98 | + String fileName = "demo.xlsx"; |
| 99 | + // 读取 Excel 文件 |
| 100 | + Fesod.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead(); |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +### 写入 |
| 105 | + |
| 106 | +以下是创建 Excel 文档的简单示例: |
| 107 | + |
| 108 | +```java |
| 109 | +// 示例数据类 |
| 110 | +public class DemoData { |
| 111 | + |
| 112 | + @ExcelProperty("字符串标题") |
| 113 | + private String string; |
| 114 | + |
| 115 | + @ExcelProperty("日期标题") |
| 116 | + private Date date; |
| 117 | + |
| 118 | + @ExcelProperty("数字标题") |
| 119 | + private Double doubleData; |
| 120 | + |
| 121 | + @ExcelIgnore |
| 122 | + private String ignore; |
| 123 | +} |
| 124 | + |
| 125 | +// 准备要写入的数据 |
| 126 | +private static List<DemoData> data() { |
| 127 | + List<DemoData> list = new ArrayList<>(); |
| 128 | + for (int i = 0; i < 10; i++) { |
| 129 | + DemoData data = new DemoData(); |
| 130 | + data.setString("String" + i); |
| 131 | + data.setDate(new Date()); |
| 132 | + data.setDoubleData(0.56); |
| 133 | + list.add(data); |
| 134 | + } |
| 135 | + return list; |
| 136 | +} |
| 137 | + |
| 138 | +public static void main(String[] args) { |
| 139 | + String fileName = "demo.xlsx"; |
| 140 | + // 创建一个名为 "Template" 的工作表并写入数据 |
| 141 | + Fesod.write(fileName, DemoData.class).sheet("Template").doWrite(data()); |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +## 社区 |
| 146 | + |
| 147 | +### 贡献者 |
| 148 | + |
| 149 | +欢迎贡献者加入 Apache Fesod (Incubating)。请查看[贡献指南](./CONTRIBUTING.md)了解如何为该项目做出贡献。 |
| 150 | + |
| 151 | +感谢所有已经为 Apache Fesod (Incubating) 做出贡献的人们! |
| 152 | + |
| 153 | +<a href="https://github.com/apache/fesod/graphs/contributors"> |
| 154 | + <img src="https://contrib.rocks/image?repo=apache/fesod"/> |
| 155 | +</a> |
| 156 | + |
| 157 | +> 注意:由于 GitHub 图片大小限制,仅显示前 100 名贡献者 |
| 158 | +
|
| 159 | +### 订阅邮件列表 |
| 160 | + |
| 161 | +邮件列表是 Apache 社区中最受认可的交流形式。请通过以下邮件列表联系我们。 |
| 162 | + |
| 163 | +| 名称 | 邮件列表 | |
| 164 | +|:----------------------------------------------------|:--------------------------------------------------------------------------------------------------------------| |
| 165 | + |
| 166 | + |
| 167 | +### Star 历史 |
| 168 | + |
| 169 | +[](https://www.star-history.com/#apache/fesod&Date) |
| 170 | + |
| 171 | +## 许可证 |
| 172 | + |
| 173 | +Apache Fesod (Incubating) 项目采用 [Apache License 2.0](LICENSE) 许可证。 |
| 174 | + |
0 commit comments