[Bug] Absolute row/column index 0 is ignored for images, hyperlinks and comments

未关闭 适合新手
#1,332 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@fanOfSunny 已经在做这个了。

开始于 2026年11月12日。

  • #1333 来自 @fanOfSunny —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
backend

调研方向

首先阅读 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/fesod 的其他 Issue

查看 apache/fesod 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。