Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【疑问】官网示例中读取 Excel 所有Sheet前多少行只作用于第一个 Sheet #151

Open
Lyx3ZzSs opened this issue Dec 22, 2024 · 2 comments
Assignees
Labels
pending verification This problem needs to be confirmed planning It may be developed later

Comments

@Lyx3ZzSs
Copy link

描述问题

官网示例代码展示了如何读取 Excel所有Sheet 的前多少行数据,但示例中默认只读取了第一个 Sheet,而未按预期读取所有 Sheet 页的前 100 行。

官网示例代码

  EasyExcel.read(fileName, DemoData.class, new PageReadListener<DemoData>(dataList -> {
          for (DemoData demoData : dataList) {
              log.info("读取到一条数据{}", JSON.toJSONString(demoData));
          }
      })).numRows(100).sheet().doRead();

预期行为

  • numRows(100) 应该在所有 Sheet 页中都生效,读取每个 Sheet 的前 100 行。

实际行为:

  • 示例代码只作用于第一个 Sheet,其他 Sheet 的数据未被读取。

复现步骤:

  1. 创建一个包含多个 Sheet 页的 Excel 文件(如 demo.xlsx)。

image

  1. 在代码中使用官网示例的读取逻辑。
  2. 查看控制台输出,发现只读取了第一个 Sheet 的数据。
11:38:27.521 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串101"}
11:38:27.523 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串2"}
11:38:27.523 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串3"}
11:38:27.523 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串4"}
11:38:27.523 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串5"}
11:38:27.524 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串6"}
11:38:27.524 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串7"}
11:38:27.524 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串8"}
11:38:27.524 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串9"}
11:38:27.524 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串10"}
11:38:27.525 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串11"}
11:38:27.525 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串12"}
11:38:27.525 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串13"}
11:38:27.525 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串14"}
11:38:27.525 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串15"}
11:38:27.526 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串16"}
11:38:27.526 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串17"}
11:38:27.526 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串18"}
11:38:27.526 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串19"}
11:38:27.526 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串20"}
11:38:27.527 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串21"}
11:38:27.527 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串22"}
11:38:27.527 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串23"}
11:38:27.527 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串24"}
11:38:27.527 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串25"}
11:38:27.527 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串26"}
11:38:27.528 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串27"}
11:38:27.528 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串28"}
11:38:27.528 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串29"}
11:38:27.528 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串30"}
11:38:27.528 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串31"}
11:38:27.528 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串32"}
11:38:27.529 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串33"}
11:38:27.529 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串34"}
11:38:27.529 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串35"}
11:38:27.529 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串36"}
11:38:27.530 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串37"}
11:38:27.530 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串38"}
11:38:27.530 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串39"}
11:38:27.530 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串40"}
11:38:27.530 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串41"}
11:38:27.530 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串42"}
11:38:27.530 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串43"}
11:38:27.531 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串44"}
11:38:27.531 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串45"}
11:38:27.531 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串46"}
11:38:27.531 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串47"}
11:38:27.531 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串48"}
11:38:27.531 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串49"}
11:38:27.531 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串50"}
11:38:27.532 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串51"}
11:38:27.532 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串52"}
11:38:27.532 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串53"}
11:38:27.532 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串54"}
11:38:27.532 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串55"}
11:38:27.532 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串56"}
11:38:27.532 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串57"}
11:38:27.533 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串58"}
11:38:27.533 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串59"}
11:38:27.533 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串60"}
11:38:27.533 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串61"}
11:38:27.533 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串62"}
11:38:27.533 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串63"}
11:38:27.533 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串64"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串65"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串66"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串67"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串68"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串69"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串70"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串71"}
11:38:27.534 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串72"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串73"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串74"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串75"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串76"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串77"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串78"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串79"}
11:38:27.535 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串80"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串81"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串82"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串83"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串84"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串85"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串86"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串87"}
11:38:27.536 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串88"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串89"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串90"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串91"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串92"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串93"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串94"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串95"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串96"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串97"}
11:38:27.537 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串98"}
11:38:27.538 [main] INFO com.sprixin.FastExcelTest -- 读取到一条数据{"date":"2024-12-22 09:58:42","doubleData":0.65,"string":"字符串99"}
@psxjoy psxjoy added the pending verification This problem needs to be confirmed label Dec 22, 2024
@psxjoy psxjoy self-assigned this Dec 22, 2024
@psxjoy psxjoy added the planning It may be developed later label Dec 24, 2024
@poo0054
Copy link

poo0054 commented Dec 30, 2024

我去验证一下这个问题

@poo0054
Copy link

poo0054 commented Dec 31, 2024

@Lyx3ZzSs 你可以参考https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read#%E8%AF%BB%E5%A4%9A%E4%B8%AAsheet,读取多行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending verification This problem needs to be confirmed planning It may be developed later
Projects
None yet
Development

No branches or pull requests

3 participants