This is an automated email from the ASF dual-hosted git repository.
delei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fesod.git
The following commit(s) were added to refs/heads/main by this push:
new 40d54dc1 docs: add documentation for the includeColumnIndex parameter
(#1008)
40d54dc1 is described below
commit 40d54dc1ba7c22eb70b8201ce2027657d9c2800b
Author: Selim S. <[email protected]>
AuthorDate: Sat Aug 15 13:44:51 2026 +0200
docs: add documentation for the includeColumnIndex parameter (#1008)
* docs: add both chinese and english versions of docs for the
includeColumnIndex parameter
* docs: fixing formatting of the docs
* docs: fixing formatting of the docs 2
* docs: adding more description to pojo and parameter mds
* docs: small headers fix
* docs: small headers fix
* docs: small headers fix
* docs: small headers fix
---------
Co-authored-by: Selim Soufargi <[email protected]~>
Co-authored-by: Bengbengbalabalabeng
<[email protected]>
---
website/docs/sheet/help/parameter.md | 3 ++
website/docs/sheet/read/csv.md | 24 ++++++++++++++++
website/docs/sheet/read/pojo.md | 3 ++
website/docs/sheet/read/sheet.md | 30 ++++++++++++++++++++
.../current/sheet/help/parameter.md | 3 ++
.../current/sheet/read/csv.md | 24 +++++++++++++++-
.../current/sheet/read/pojo.md | 3 ++
.../current/sheet/read/sheet.md | 32 ++++++++++++++++++++++
8 files changed, 121 insertions(+), 1 deletion(-)
diff --git a/website/docs/sheet/help/parameter.md
b/website/docs/sheet/help/parameter.md
index bf5d5a64..1c4de33c 100644
--- a/website/docs/sheet/help/parameter.md
+++ b/website/docs/sheet/help/parameter.md
@@ -42,6 +42,7 @@ class BasicParameter {
class ReadBasicParameter {
- Integer headRowNumber
- List~ReadListener~?~~ customReadListenerList
+ - Collection~Integer~ includeColumnIndexes
}
class ReadSheet {
- Integer sheetNo
@@ -138,6 +139,7 @@ All parameters inherit from `BasicParameter`.
|------------------------|---------------|----------------------------------------------------------------------------------------------------------------|
| customReadListenerList | Empty | Can register multiple listeners.
When reading spreadsheet, the listener's methods will be continuously called. |
| headRowNumber | 1 | The number of rows in the header of
spreadsheet, default is 1 row. |
+| includeColumnIndexes | Empty | Specify 0-based column
indices to read. Excluded columns are skipped during parsing, and target
columns are remapped to contiguous 0-based indices.
|
### ReadWorkbook
@@ -171,6 +173,7 @@ All parameters inherit from `BasicParameter`.
| sheetHidden | false | Normal Hidden Status
|
| sheetVeryHidden | false | Absolute Hidden State
|
| numRows | 0 | Read the specified number of rows. 0 means
no limit on the number of rows, i.e. read all rows. |
+| includeColumnIndexes | Empty | Specify 0-based column
indices to read. Excluded columns are skipped during parsing, and target
columns are remapped to contiguous 0-based indices. |
## Writing Operations
diff --git a/website/docs/sheet/read/csv.md b/website/docs/sheet/read/csv.md
index cb1d8592..1fd907a0 100644
--- a/website/docs/sheet/read/csv.md
+++ b/website/docs/sheet/read/csv.md
@@ -41,6 +41,7 @@ The main parameters are as follows:
| `recordSeparator` | `CRLF` | Record (line) separator. Varies by
operating system, such as `CsvConstant.CRLF`(Windows) or
`CsvConstant.LF`(Unix/Linux). |
| `nullString` | `null` | String used to represent `null`
values. Note this is different from an empty string `""`.
|
| `escape` | `null` | Escape character used to escape
quote characters themselves.
|
+| `includeColumnIndexes` | `null` | List of 0-based column indices
to read. Excluded columns are skipped, and target columns are remapped to
contiguous 0-based indices. |
---
@@ -142,6 +143,29 @@ public void escapeDemo() {
}
```
+### includeColumnIndexes
+
+`includeColumnIndexes` specifies which columns to read from the CSV file.
Unselected columns are skipped during parsing, and the resulting column indices
are remapped to contiguous 0-based indices.
+
+#### Code Example
+
+```java
+@Test
+public void includeColumnIndexesDemo() {
+ String csvFile = "path/to/your.csv";
+ // Specify 0-based column indices to include (e.g., columns 0, 2, and
4)
+ List<Integer> includeColumnIndexes = Arrays.asList(0, 2, 4);
+
+ try (ExcelReader excelReader = FesodSheet.read(csvFile,
DemoData.class, new DemoDataListener()).build()) {
+ ReadSheet readSheet = FesodSheet.readSheet(0)
+
.includeColumnIndexes(includeColumnIndexes)
+ .build();
+ excelReader.read(readSheet);
+ }
+ }
+
+```
+
## CSVFormat Configuration Details and Examples
Supports directly building a `CSVFormat` object.
diff --git a/website/docs/sheet/read/pojo.md b/website/docs/sheet/read/pojo.md
index 4b914d1a..09b287b5 100644
--- a/website/docs/sheet/read/pojo.md
+++ b/website/docs/sheet/read/pojo.md
@@ -64,6 +64,9 @@ public void indexOrNameRead() {
}
```
+> **Note when using `includeColumnIndexes`:**
+> If `includeColumnIndexes` is configured on the reader (e.g., selecting
original columns `[0, 2, 4]`), the parsed columns are remapped to contiguous
indices (`0, 1, 2`). Ensure `@ExcelProperty(index = ...)` matches the
**remapped** index rather than the original file column index.
+
---
## Cell Objects
diff --git a/website/docs/sheet/read/sheet.md b/website/docs/sheet/read/sheet.md
index 202ab285..77548266 100644
--- a/website/docs/sheet/read/sheet.md
+++ b/website/docs/sheet/read/sheet.md
@@ -100,3 +100,33 @@ public void exceptionRead() {
> xlSheetVeryHidden)". Very hidden can be set through `VBA`, and in this case,
> the hidden sheet cannot be unhidden
> through
> the "Unhide" operation.
+
+## Reading Specific Columns
+
+### Overview
+
+By configuring `includeColumnIndexes`, you can specify which columns to read
from a sheet. Unselected columns are skipped during parsing, and the target
columns are remapped to contiguous zero-based indices.
+
+Note: This feature supports both modern `.xlsx` (OOXML) and legacy `.xls`
(BIFF8 / Excel 97–2003) file formats.
+
+### Code Example
+
+```java
+@Test
+public void readSpecificColumns() {
+// Works with both demo.xlsx and demo.xls
+String fileName = "path/to/demo.xls";
+
+ // Specify 0-based column indices to include (e.g., Column A, C, E)
+ List<Integer> includeColumnIndexes = Arrays.asList(0, 2, 4);
+
+ try (ExcelReader excelReader = FesodSheet.read(fileName).build()) {
+ ReadSheet readSheet = FesodSheet.readSheet(0)
+ .head(DemoData.class)
+ .includeColumnIndexes(includeColumnIndexes)
+ .registerReadListener(new DemoDataListener())
+ .build();
+ excelReader.read(readSheet);
+ }
+}
+```
diff --git
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/help/parameter.md
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/help/parameter.md
index 30626a91..bef5173c 100644
---
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/help/parameter.md
+++
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/help/parameter.md
@@ -25,6 +25,7 @@ class BasicParameter {
class ReadBasicParameter {
- Integer headRowNumber
- List~ReadListener~?~~ customReadListenerList
+ - Collection~Integer~ includeColumnIndexes
}
class ReadSheet {
- Integer sheetNo
@@ -121,6 +122,7 @@ WriteWorkbook --|> WriteBasicParameter
|------------------------|-----|----------------------------------|
| customReadListenerList | 空 | 可以注册多个监听器,读取电子表格的时候会不断的回调监听器中的方法 |
| headRowNumber | 1 | 电子表格中头的行数,默认 1 行 |
+| includeColumnIndexes | 无 | 指定需要读取的列索引列表(从 0
开始)。未指定的列将在解析过程中被跳过,且目标列会被重新映射为从 0 开始的连续索引。 |
### ReadWorkbook 参数
@@ -154,6 +156,7 @@ WriteWorkbook --|> WriteBasicParameter
| sheetHidden | false | Sheet 页普通隐藏状态 |
| sheetVeryHidden | false | Sheet 页绝对隐藏状态 |
| numRows | 0 | 读取指定的行数,0 表示不限制行数,即读取所有行 |
+| includeColumnIndexes | 无 | 指定需要读取的列索引列表(从 0
开始)。未指定的列将在解析过程中被跳过,且目标列会被重新映射为从 0 开始的连续索引。 |
## 写操作
diff --git
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/csv.md
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/csv.md
index d22fd5a2..a4513688 100644
---
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/csv.md
+++
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/csv.md
@@ -23,6 +23,7 @@ Fesod 通过不同的参数设计进行 CSV
| `recordSeparator` | `CRLF` | 记录(行)分隔符。根据操作系统不同而变化,例如 `CsvConstant.CRLF`
(Windows) 或 `CsvConstant.LF` (Unix/Linux)。 |
| `nullString` | `null` | 用于表示 `null` 值的字符串。注意这与空字符串 `""` 不同。
|
| `escape` | `null` | 转义字符,用于转义引用符号自身。
|
+| `includeColumnIndexes` | `null` | 指定需要读取的列索引列表(从 0
开始)。未指定的列将被跳过,且读取的数据会被重新映射为从 0 开始的连续索引。 |
---
@@ -119,6 +120,28 @@ public void escapeDemo() {
}
```
+### includeColumnIndexes
+
+`includeColumnIndexes` 用于指定只读取 CSV 文件中的某些列。未选中的列会在解析过程中被跳过,且解析出的列索引会被重新映射为从 0
开始的连续索引。
+
+#### 代码示例
+
+```java
+@Test
+public void includeColumnIndexesDemo() {
+ String csvFile = "path/to/your.csv";
+ // 指定读取第 0、2、4 列(例如第 1、3、5 列)
+ List<Integer> includeColumnIndexes = Arrays.asList(0, 2, 4);
+
+ try (ExcelReader excelReader = FesodSheet.read(csvFile,
DemoData.class, new DemoDataListener()).build()) {
+ ReadSheet readSheet = FesodSheet.readSheet(0)
+
.includeColumnIndexes(includeColumnIndexes)
+ .build();
+ excelReader.read(readSheet);
+ }
+}
+```
+
## CSVFormat 设置详解与示例
支持直接构建一个 `CSVFormat` 对象。
@@ -140,7 +163,6 @@ public void csvFormatDemo() {
CsvReadWorkbookHolder csvReadWorkbookHolder =
(CsvReadWorkbookHolder) readWorkbookHolder;
csvReadWorkbookHolder.setCsvFormat(csvFormat);
}
-
ReadSheet readSheet = FesodSheet.readSheet(0).build();
excelReader.read(readSheet);
}
diff --git
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/pojo.md
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/pojo.md
index c2f54a12..a43cb76b 100644
---
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/pojo.md
+++
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/pojo.md
@@ -46,6 +46,9 @@ public void indexOrNameRead() {
}
```
+使用 includeColumnIndexes 时的注意事项:
+如果在读取器上配置了 includeColumnIndexes(例如选择原始列 [0, 2, 4]),解析后的列会被重新映射为连续的索引(0, 1,
2)。请确保 @ExcelProperty(index = ...) 中的索引对应的是重新映射后的列索引,而非原始文件中的列索引。
+
---
## 单元格对象
diff --git
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/sheet.md
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/sheet.md
index f19e6c96..1c9d5bd6 100644
---
a/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/sheet.md
+++
b/website/i18n/zh-cn/docusaurus-plugin-content-docs/current/sheet/read/sheet.md
@@ -77,3 +77,35 @@ public void exceptionRead() {
> 微软 Excel 中,Sheet
> 有“普通隐藏(xlSheetHidden)”和“绝对隐藏(xlSheetVeryHidden)”两种状态,绝对隐藏可通过 `VBA` 来设置,此时隐藏的
> Sheet 无法通过“取消隐藏”的操作来取消。
+
+---
+
+## 读取指定列
+
+### 概述
+
+通过设置 `includeColumnIndexes` 参数,可以指定只读取 Sheet
中的某些列。未选中的列会在解析过程中被跳过,且目标列会被重新映射为从 0 开始的连续索引。
+
+> **注意:** 该功能同时支持 `.xlsx` (OOXML) 和 `.xls` (BIFF8 / Excel 97–2003) 文件格式。
+
+### 代码示例
+
+```java
+@Test
+public void readSpecificColumns() {
+ // 同时支持 .xlsx 和 .xls 格式
+ String fileName = "path/to/demo.xls";
+
+ // 指定需要读取的列索引(从 0 开始,例如 0, 2, 4 代表 A, C, E 列)
+ List<Integer> includeColumnIndexes = Arrays.asList(0, 2, 4);
+
+ try (ExcelReader excelReader = FesodSheet.read(fileName).build()) {
+ ReadSheet readSheet = FesodSheet.readSheet(0)
+ .head(DemoData.class)
+ .includeColumnIndexes(includeColumnIndexes)
+ .registerReadListener(new DemoDataListener())
+ .build();
+ excelReader.read(readSheet);
+ }
+}
+```
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]