Solved

Always create excel file even if data is empty


Badge

I'm creating a new excel file nightly and some nights there will be no data to populate the excel file, but I need the file to be created anyways. Is there a step in the Excel writer that I'm missing to do this?

icon

Best answer by erik_jan 16 May 2016, 17:43

View original

6 replies

Badge +17

FME will create a file when the first feature is written. So when no features are written, no file will be created. I see two ways of bypassing this issue:

- Always create an empty record by writing a feature with no values (but that leave you with a XLS file with an empty line, even if data is written).

- Use the option not to write Filed Names first and create (using Creator and AttributeCreator) a feature with the field names as the first feature to write. That will create the file using the field names as first line.

Hope this is useful.

Badge

FME will create a file when the first feature is written. So when no features are written, no file will be created. I see two ways of bypassing this issue:

- Always create an empty record by writing a feature with no values (but that leave you with a XLS file with an empty line, even if data is written).

- Use the option not to write Filed Names first and create (using Creator and AttributeCreator) a feature with the field names as the first feature to write. That will create the file using the field names as first line.

Hope this is useful.

This answer helped me in the right direction! All I did is only add the Creator transformer (and not the attributeCreator) and that is enough for the excel file to create at least the column headers if there is no data. Thanks!

Badge +17

This answer helped me in the right direction! All I did is only add the Creator transformer (and not the attributeCreator) and that is enough for the excel file to create at least the column headers if there is no data. Thanks!

And if you set the Creator to create the feature at the end (setting of Creator) the empty line will be the last to write and not be visible even if you have data to write.

Userlevel 2
Badge +23

And if you set the Creator to create the feature at the end (setting of Creator) the empty line will be the last to write and not be visible even if you have data to write.

Or use a NoFeatureTester just prior to the writer.

Badge

Or use a NoFeatureTester just prior to the writer.

The NoFeatureTester tool is awesome! Thanks for the heads up on this tool, I actually updated the workbench with this one because it for sure keeps the column headers when there is no data and it works like a charm.

Badge

Yes, NoFeature Tester tools working fine.

Reply