[Bug] Absolute row/column index 0 is ignored for images, hyperlinks and comments
维护者通常 1 天内回复
评估
调研方向
首先阅读 StyleUtil.getCellCoordinate,issue 将其指出为坐标回退的来源,然后检查 AbstractExcelWriteExecutor 中对它的调用。确认图像、超链接和批注锚点如何处理绝对坐标和相对坐标。完成标准是绝对索引 0 优先,同时 null 和负值保留回退行为;使用 XLSX 和 XLS 的复现步骤进行验证。
由索引模型根据 Issue 内容生成。
描述
Search before asking
- I searched in the issues and found nothing similar.
Fesod version
main (commit 69147b7)
JDK version
17 (the affected code is JDK-independent)
Operating system
Windows 11 (OS-independent)
Steps To Reproduce
StyleUtil.getCellCoordinate only honors an absolute coordinate when it is > 0:
if (absoluteCoordinate != null && absoluteCoordinate > 0) {
return absoluteCoordinate;
}
Index 0 (row 1 / column A) is a valid zero-based coordinate, but it silently falls back to the relative coordinate or to the position of the cell that carries the data. The method is used for image, hyperlink and comment anchors in AbstractExcelWriteExecutor.
Reproduce with an image:
ImageData imageData = new ImageData();
imageData.setImage(imageBytes);
imageData.setFirstRowIndex(0);
imageData.setFirstColumnIndex(0);
imageData.setLastRowIndex(0);
imageData.setLastColumnIndex(0);
WriteCellData<Void> cellData = new WriteCellData<>(CellDataTypeEnum.EMPTY);
cellData.setImageDataList(new ArrayList<>(Collections.singletonList(imageData)));
List<List<Object>> data = Arrays.asList(
Arrays.asList("row1", "value1"),
Arrays.asList("row2", "value2"),
Arrays.asList("row3", cellData)); // written to B4 (one head row)
FesodSheet.write(file)
.head(Arrays.asList(Collections.singletonList("Name"), Collections.singletonList("Image")))
.sheet()
.doWrite(data);
Current Behavior
The picture is anchored at B4 (the data cell) instead of A1, for both XLSX and XLS. When a relative coordinate is also set, the relative value wins over the absolute 0.
Expected Behavior
An absolute index of 0 is honored, and it takes precedence over the relative index. This matches the CoordinateData Javadoc ("Priority is higher than relative...").
Anything else?
Proposed fix: change the check to absoluteCoordinate >= 0. null and negative values keep the current fallback behavior, so existing callers that do not set absolute coordinates are unaffected.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- 主要语言
- Java
- 星标
- 6.3k
- 派生
- 554
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 44
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/fesod 的其他 Issue
-
[DISCUSS] Commit Signature Verification可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭discussion welcome security stale waiting for feedback
难度 2/5 1-3 小时 新手友好度 62/100
apache/fesod#1184 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
[Bug] xlsx stream write leaves temp file可能已有人在做 @nkuprins 于 35 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 75/100
apache/fesod#1137 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[bug]Custom converters with supportExcelTypeKey() == null are silently ignored when writing CSV可能已有人在做 @Mikkey-f 于 66 天前认领。 未关闭
难度 2/5 半天 新手友好度 84/100
维护者通常 1 天内回复
-
[Task] Correct source attribution and align copyright years following LEGAL-737可能已有人在做 @himanchalkaushale 于 1 天前认领。 未关闭good first issue
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
discussion welcome
难度 3/5 1-2 天 新手友好度 15/100
apache/fesod#1308 · 3 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
SasanLabs/VulnerableApp#912 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
desktop edt not responding
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 78/100
datafusion-contrib/StreamFusion#653 ·
维护者通常 1 天内回复
-
Four TestConstraintBasedAlgorithm tests pass when nothing is thrown可能已有人在做 @sharanggupta 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 85/100