Talend中用tFileList与tFileInputExcel合并XLSX文件报错求助
Hey there, let's break down the two key issues popping up in your workflow and walk through how to fix them step by step:
1. First: Resolve the InvalidOperationException from Temporary Excel Files
The error log clearly points to failing to open C:\Users\dell\Desktop\Data2 - Copie\~$S_1.xlsx — this is a hidden temporary lock file that Excel generates automatically when you have the actual S_1.xlsx open locally. tFileList by default scans all files in the target folder, including these hidden temp files, which aren't valid XLSX files, hence the crash.
Here's how to fix this:
- Use tFileList's built-in filtering: In the tFileList component, set the
Filemaskto*.xlsx, and if your Talend version supports it, check the Exclude hidden files option. This will skip all hidden temp files entirely. - Add a tFilterRow if needed: If your Talend version doesn't have the hidden file exclusion option, drop a tFilterRow right after tFileList. Use this condition to filter out temp files:
!((String)globalMap.get("tFileList_CURRENT_FILE_NAME")).startsWith("~$") - Quick pre-check: Make sure none of the target XLSX files are open in Excel on your local machine — closing them will stop the temp files from being generated in the first place.
2. Next: Fix the "For input string: 'N_Vol'" Type Conversion Error
This error means tFileInputExcel is trying to convert the string value N_Vol into a numeric type (like integer or double) for one of your columns, which obviously fails because N_Vol isn't a number.
Here are your actionable fixes:
- Adjust column type in tFileInputExcel: Locate the problematic column in your tFileInputExcel's schema. If this column is supposed to hold text values (like
N_Volas a status marker), change its type toStringinstead of any numeric type. - Handle non-numeric values gracefully: If the column should be numeric but has occasional non-numeric entries like
N_Vol, use a tMap component after tFileInputExcel to clean the data. For example, you can use a conditional expression to set invalid values to null or a default:TalendDate.isNumeric(row1.yourTargetColumn) ? Double.parseDouble(row1.yourTargetColumn) : null - Validate source file formatting: Double-check your source XLSX files to ensure the problematic column doesn't mix numeric and text formats across cells — consistent formatting will prevent these conversion hiccups.
3. Bonus: Tips for Smooth Merging
When merging multiple files into one XLSX, make sure:
- All source files have matching schemas (same column names, compatible data types) — mismatched schemas can cause unexpected errors even after fixing the above issues.
- Use tFileOutputExcel in Append mode, or use tAppendRow to aggregate all data first before writing to the final XLSX file, to ensure all rows are merged correctly.
内容的提问来源于stack exchange,提问作者FarCry

