How to quickly detect which files cause error in Excel writer and what error the files cause.

Hi @mysteri_guy , Following this topic gave me inspiration for a new component:

You can see it in action in the following workflow

I included your files (renaming the second File 1.xlsx) in the demo workflow’s data area.

What the component does is make use of the Table Validator (Reference) node which can compare a table with a reference table and return details of any errors in the table specification (e.g. missing/additional columns).

Putting this in a loop, we can test each excel file in a list of supplied paths and compare them to a reference table (or a known “good” file) to build up details of which are OK and which fail.

This is the internals of the component which you can of course have a play with in the above workflow, or adapt to your needs if it doesn’t quite do what you require:

My thoughts are that you could use this component as a “pre-processor” to ensure your files are in the correct form before then embarking on the main process. For expediency, at the moment the component assumes that the supplied Path column will be named “Path”. I may add this as a configurable column selection in a later version.


Edit: An additional thought, with the above you can quickly abort downstream processing if any files fail validation, by adding a java snippet onto the lower port of the component. Code the java snippet as follows:

if (ROWINDEX == 0)
{
	throw new Abort("Validation Errors exist in Excel file(s)");
}

Then if none of the files fail, the java snippet simply warns that it has created an empty table (as there were no rows in the “failed” set of files), and further processing can continue.

But if there is at least one failed file, the java snippet will create an “Abort” which will block the flow:

3 Likes