Skip to main content
Solved

Always create excel file even if data is empty

  • May 16, 2016
  • 6 replies
  • 200 views

apence231
Contributor
Forum|alt.badge.img+10

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?

Best answer by erik_jan

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 post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • Best Answer
  • May 16, 2016

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.


apence231
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • May 16, 2016

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!


erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • May 16, 2016

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.


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • May 16, 2016

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.


apence231
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • May 24, 2016

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.


sujitbhunia
Contributor
Forum|alt.badge.img+2
  • Contributor
  • June 12, 2024

Yes, NoFeature Tester tools working fine.