gpt4 book ai didi

java - 测试apache poi生成excel内容

转载 作者:行者123 更新时间:2023-12-02 05:04:18 25 4
gpt4 key购买 nike

我在测试 apache poi 生成 excel 方法时遇到问题。我的方法返回资源(org.springframework.core.io.Resource),现在我想将其转换为例如InputStream来创建工作簿和测试内容文件。如何做到这一点?

目前我仅测试文件是否存在但内容不存在:

ResponseEntity<Resource> response = myService.createExcel();
ByteArrayResource responseBody = (ByteArrayResource) response.getBody();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseBody).isNotNull();
assertThat(responseBody.contentLength()).isGreaterThan(0);

最佳答案

你别无选择,只能再次用 POI 解析内容,就像你的服务器端所做的那样。

关于java - 测试apache poi生成excel内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56363726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com