DanielCarter-stack commented on issue #10365:
URL: https://github.com/apache/seatunnel/issues/10365#issuecomment-3767152035

   <!-- code-pr-reviewer -->
   Thank you for reporting this. I've confirmed the bug exists in the Excel 
connector.
   
   **Root Cause**: `ExcelGenerator.java` incorrectly uses original field 
indices from `sinkColumnsIndexInRow` as Excel column numbers instead of 
sequential column positions (0,1,2,3...). For example, if `sink_columns` maps 
to indices `[0,12,2,3,4...]`, Excel writes columns at positions 0,12,2,3,4 
instead of 0,1,2,3,4.
   
   **Affected Code**:
   - 
`seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/util/ExcelGenerator.java`
 (lines 76-80, 97-100, 120-121)
   
   This affects all file-based sinks (SFTP/HDFS/Local/OSS) when 
`file_format_type=excel`. Other formats (CSV/JSON/ORC) correctly reorder 
columns via `seaTunnelRow.copy()`.
   
   **Suggested Fix**: Replace `createCell(i)` with `createCell(colIndex++)` in 
both header and data writing loops. Add test case with non-sequential indices 
(e.g., `[3,0,2]`) in `ExcelGeneratorTest.java`.
   
   **Workaround**: Use CSV format as output instead, which handles column 
ordering correctly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to