Skip to main content
Solved

Add row(s) above header in Excel


djmcdermott
Contributor
Forum|alt.badge.img+6

Hi,

I would like to add a new row containing some descriptive information from a seperate stream above header row in an excel spreadsheet.

Thanks

David McDermott

Best answer by takashi

Hi @djmcdermott, a possible way is to write data records starting with a specific row using a FeatureWriter, and then write (insert) descriptive rows starting with the first row in the same sheet using another Excel writer. You can control starting row through the Start Row parameter in the Excel writer feature type. For example, assuming that the number of descriptive rows is three,

FeatureWriter (Excel Writer / Feature Type) Parameters

  • Overwrite Existing File: Yes
  • Output Field Names: Yes
  • Use Attribute Names As Column Positions: No
  • Start Position | Start Row: 4 (= 3 + 1)

Excel Writer / Feature Type Parameters

  • Overwrite Existing File: No
  • Output Field Names: No
  • Use Attribute Names As Column Positions: Yes
  • Start Position | Start Row: 1
View original
Did this help you find an answer to your question?

5 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • June 20, 2017

Hi @djmcdermott, a possible way is to write data records starting with a specific row using a FeatureWriter, and then write (insert) descriptive rows starting with the first row in the same sheet using another Excel writer. You can control starting row through the Start Row parameter in the Excel writer feature type. For example, assuming that the number of descriptive rows is three,

FeatureWriter (Excel Writer / Feature Type) Parameters

  • Overwrite Existing File: Yes
  • Output Field Names: Yes
  • Use Attribute Names As Column Positions: No
  • Start Position | Start Row: 4 (= 3 + 1)

Excel Writer / Feature Type Parameters

  • Overwrite Existing File: No
  • Output Field Names: No
  • Use Attribute Names As Column Positions: Yes
  • Start Position | Start Row: 1

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • June 20, 2017

Excel reader has a xlsx_row_id attribute.

Read the excel, increase xlsx_row_id by 1.

Create your row to be inserted on top, give it number 0 and sort.

Write to excel.


djmcdermott
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • June 21, 2017
takashi wrote:

Hi @djmcdermott, a possible way is to write data records starting with a specific row using a FeatureWriter, and then write (insert) descriptive rows starting with the first row in the same sheet using another Excel writer. You can control starting row through the Start Row parameter in the Excel writer feature type. For example, assuming that the number of descriptive rows is three,

FeatureWriter (Excel Writer / Feature Type) Parameters

  • Overwrite Existing File: Yes
  • Output Field Names: Yes
  • Use Attribute Names As Column Positions: No
  • Start Position | Start Row: 4 (= 3 + 1)

Excel Writer / Feature Type Parameters

  • Overwrite Existing File: No
  • Output Field Names: No
  • Use Attribute Names As Column Positions: Yes
  • Start Position | Start Row: 1
Thanks @takashi. Shame there isn't a more elegant way in the writer itself.

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • June 21, 2017
takashi wrote:

Hi @djmcdermott, a possible way is to write data records starting with a specific row using a FeatureWriter, and then write (insert) descriptive rows starting with the first row in the same sheet using another Excel writer. You can control starting row through the Start Row parameter in the Excel writer feature type. For example, assuming that the number of descriptive rows is three,

FeatureWriter (Excel Writer / Feature Type) Parameters

  • Overwrite Existing File: Yes
  • Output Field Names: Yes
  • Use Attribute Names As Column Positions: No
  • Start Position | Start Row: 4 (= 3 + 1)

Excel Writer / Feature Type Parameters

  • Overwrite Existing File: No
  • Output Field Names: No
  • Use Attribute Names As Column Positions: Yes
  • Start Position | Start Row: 1
If you will write the header (field names row) as well as the descriptive rows, this workflow is also possible, since you can specify the row number (1-based sequential number) for each feature via the Row Number Attribute optionally. I don't know if this is more elegant...

 

 

 

 

 


bernarddinon
Forum|alt.badge.img+1
takashi wrote:

Hi @djmcdermott, a possible way is to write data records starting with a specific row using a FeatureWriter, and then write (insert) descriptive rows starting with the first row in the same sheet using another Excel writer. You can control starting row through the Start Row parameter in the Excel writer feature type. For example, assuming that the number of descriptive rows is three,

FeatureWriter (Excel Writer / Feature Type) Parameters

  • Overwrite Existing File: Yes
  • Output Field Names: Yes
  • Use Attribute Names As Column Positions: No
  • Start Position | Start Row: 4 (= 3 + 1)

Excel Writer / Feature Type Parameters

  • Overwrite Existing File: No
  • Output Field Names: No
  • Use Attribute Names As Column Positions: Yes
  • Start Position | Start Row: 1

Hi @Takashi

 

 

Your answer help me a lot to solve : https://knowledge.safe.com/questions/112230/how-to-define-some-values-in-excel-header-with-att.html

 

 

Thank you

Reply


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