[Bug] Absolute row/column index 0 is ignored for images, hyperlinks and comments
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start by reading StyleUtil.getCellCoordinate, which the issue identifies as the source of the coordinate fallback, and check its callers in AbstractExcelWriteExecutor. Confirm how absolute and relative coordinates are handled for image, hyperlink, and comment anchors. Done means absolute index 0 takes precedence while null and negative values retain the fallback behavior; verify with the reproduction for XLSX and XLS.
Written by the indexing model from the issue text.
Description
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!
- Dominant language
- Java
- Stars
- 6.3k
- Forks
- 554
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 44
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/fesod
-
[DISCUSS] Commit Signature VerificationPossibly taken A pull request linked to this issue is open or already merged. Opendiscussion welcome security stale waiting for feedback
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
apache/fesod#1184 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
[Bug] xlsx stream write leaves temp filePossibly taken @nkuprins claimed this 35 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/fesod#1137 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
[bug]Custom converters with supportExcelTypeKey() == null are silently ignored when writing CSVPossibly taken @Mikkey-f claimed this 66 days ago. Open
Difficulty 2/5 Half a day Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[Task] Correct source attribution and align copyright years following LEGAL-737Possibly taken @himanchalkaushale claimed this 1 day ago. Opengood first issue
Difficulty 5/5 Over a week Newbie friendliness 35/100
apache/fesod#1322 · 2 comments ·
Maintainers usually reply within 1 day
-
discussion welcome
Difficulty 3/5 1-2 days Newbie friendliness 15/100
apache/fesod#1308 · 3 comments · 3 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
SasanLabs/VulnerableApp#912 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
desktop edt not responding
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
datafusion-contrib/StreamFusion#653 ·
Maintainers usually reply within 1 day
-
Four TestConstraintBasedAlgorithm tests pass when nothing is thrownPossibly taken @sharanggupta claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 85/100