Skip to main content

Hi,

I would like to write to an Excel Spreadsheet where the header row is formatted differently from the rest of the spreadsheet. I tried using an Excel Template but that requires me to overwrite the output every time and I do not want to overwrite the existing output.

I thought perhaps I could add a new record where the values are the same as the column names and then use a TestFilter and ExcelStyler to style that row of values differently from the rest, but I can't work out how to create a new record with the column names as values.

I am using FME Desktop 2018.1

Any ideas?

Thanks,

Hi @aquamarine,

The AttributeExploder transformer should help you achieve this.

"If the attributes are exploded into Features, each input feature will become many - one for every attribute in the original feature. The new features will have both the original attribute names and values added as new attributes. Below, we use the default new attribute names _attr_name and _attr_value."

"In the case of a spreadsheet, where a row is considered a single feature, this is the equivalent of exploding every cell into its own feature."


Hi @aquamarine, I don't think you need to use a template. You can append only data rows into an existing Excel spreadsheet containing field names row.

Try the configuration below. Assuming the destination Excel file exists and the Sheet1 contains header row formatted with some style.


Hi @aquamarine,

The AttributeExploder transformer should help you achieve this.

"If the attributes are exploded into Features, each input feature will become many - one for every attribute in the original feature. The new features will have both the original attribute names and values added as new attributes. Below, we use the default new attribute names _attr_name and _attr_value."

"In the case of a spreadsheet, where a row is considered a single feature, this is the equivalent of exploding every cell into its own feature."

Thanks @hollyatsafe I have tried the AttributeExploder but I now have two columns _attr_name and _attr_value. How do I get the unique values in _attr_name into the rows of the original attributes?


Hi @aquamarine, I don't think you need to use a template. You can append only data rows into an existing Excel spreadsheet containing field names row.

Try the configuration below. Assuming the destination Excel file exists and the Sheet1 contains header row formatted with some style.

Thanks @takashi unfortunately the destination Excel file does not already exist....


Hi @aquamarine, I don't think you need to use a template. You can append only data rows into an existing Excel spreadsheet containing field names row.

Try the configuration below. Assuming the destination Excel file exists and the Sheet1 contains header row formatted with some style.

I suppose you have already tried an approach using a template. You can use the template file as the destination file.


I figured out a way to do this. I used a 'Creator' to create a dummy feature and then added a 'Counter' which gave the dummy feature a count value of 0. Then I used 'AttributeManager' to assign all the attributes values of the dummy feature with a value that is the same as their attribute name. I then used a 'TestFilter' with three ports (Header, Even Rows, Odd Rows) and routed each port to a separate 'ExcelStyler' which enabled me to style the rows differently... Probably not the neatest approach but it did the trick!


I figured out a way to do this. I used a 'Creator' to create a dummy feature and then added a 'Counter' which gave the dummy feature a count value of 0. Then I used 'AttributeManager' to assign all the attributes values of the dummy feature with a value that is the same as their attribute name. I then used a 'TestFilter' with three ports (Header, Even Rows, Odd Rows) and routed each port to a separate 'ExcelStyler' which enabled me to style the rows differently... Probably not the neatest approach but it did the trick!

@aquamarine, I'm trying to do the same thing. How are you adding the attribute names as values? Are you just manually doing that?


@aquamarine, I'm trying to do the same thing. How are you adding the attribute names as values? Are you just manually doing that?

Hi @tnarladni please see the screenshot of my AttributeManager. I used a conditional statement within attribute manager to assign a value depending on whether the row was of count 0 or not. If it is count 0 (ie my dummy record) then I input the attribute name as the value manually.


Reply