Skip to main content
Solved

How can I save data to certain column in Excel?


Forum|alt.badge.img
I would like to collect data every week and save one weeks data to column. How can I save data from week 1 to column 1, week 2 to column 2 etc? I have tried to set 'Start Column' as $(xlsx_start_col), but that does not work. I also tried to use $(xlsx_start_col) as 'Use Attribute Names As Column Positions, but but didn't work also.

Best answer by david_r

Hi,

 

 

scripted parameters are very powerful, but perhaps not very well documented. But there are several articles here on FMEpedia to help you along.

 

 

Here's how you can implement it:

 

 

 

 

In the output feature type:

 

 

 

 

Hope this helps.

 

 

David
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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.

7 replies

owen
Forum|alt.badge.img+1
  • May 7, 2014
Have you used a column number instead of a letter?

david_r
Celebrity
  • May 7, 2014
Hi,

 

 

I think Own is right, these settings inserted a value into cell B2 using FME 2014 SP1:

 

 

 

 

Note that column and row numbers start at 1, not 0.

 

 

David

Forum|alt.badge.img
  • Author
  • May 7, 2014
Thanks for your answers, but problem is not yet solved. This is what I am trying to do:

 

 

1st I get number of week:

 

 

 

Then I add it to XLSX writer feature type properties as Start Column:

 

 

 

So feature type properties look like this

 

 

 

That does not work, because default value is used. xlsx_start_col has values.

david_r
Celebrity
  • May 7, 2014
Hi,

 

 

that isn't possible, I'm afraid. User parameters are locked once you start your workspace, they cannot be modified at runtime, like you can with feature attributes.

 

 

You should consider using a Python scripted parameter instead, they are interpreted before the translation starts. This script will return the week number for you (just like the TimeStamper) and you can use it in the Excel writer:

 

 

---

 

import datetime

 

return datetime.date.today().isocalendar()[1]

 

---

 

 

David

Forum|alt.badge.img
  • Author
  • May 8, 2014
Thanks David! I hope it is not too much to ask if you could show whole Python Script and what I have to add to PythonCaller Parameters, because there was so much red at log. Only thing I have done with Python is that I have used mr Takashi's code last week with FME. I guess I need take some Python Script course for newbies.

david_r
Celebrity
  • Best Answer
  • May 8, 2014
Hi,

 

 

scripted parameters are very powerful, but perhaps not very well documented. But there are several articles here on FMEpedia to help you along.

 

 

Here's how you can implement it:

 

 

 

 

In the output feature type:

 

 

 

 

Hope this helps.

 

 

David

Forum|alt.badge.img
  • Author
  • May 8, 2014
That sure helps! Now I get data where I want it. Thank you! I hope I manage to do next Python script coding by myself =)

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings