Solved

How to control Excel column width a FeatureWriter.

  • 21 January 2022
  • 5 replies
  • 120 views

Badge +3

I'm fairly new to FME Desktop. I have a FeatureWriter with three inputs. I'm creating an Excel file with three sheets. It works great except many of the column widths are much wider than the content. I have to open each sheet, select all columns and Auto Fit Column Width.

 

Today I realized that if the data type is text(255) then the column width will be 255. If the data type is text(150) then the column width will be 150. My data source is an ArcGIS feature layer created from Survey123. The default length for a text field is 255 so, I have many columns that with a width of 255 in Excel. This doesn't seem like a great way to determine width. I'd rather go with the Excel default column width.

 

In the User Attributes tab of the FeatureWriter parameters, I see that I can set the column width. I believe that I can use zero to auto fit the column width. The problem is that I have about 30 columns and 3 sheets so, I'd have to type '0' close to hundred times. Is there a better way? Thanks.

icon

Best answer by ebygomm 21 January 2022, 14:35

View original

5 replies

Userlevel 6
Badge +32

You can import this. Prepare an excel document as you like (copy the data including columns from the Visual Preview / Data Inspector, paste in Excel, fix column widths), then create the writer or configure the FeatureWriter, import the sheets and the column widths will imported with the column names.

 

As an alternative you can use the prepared file as a template for the writer, remove the data (not the columns) and set it as a template.

 

WriterParametersFeatureWriterParameters

Userlevel 1
Badge +10

If you highlight the attributes to change, you only need to type the new value once, it will update all selected attributes

image

Badge +3

If you highlight the attributes to change, you only need to type the new value once, it will update all selected attributes

image

Thanks. I think that this is what I want, but I can't change the cell width unless I change the Attribute Definition to Manual or Dynamic. When I do that my Excel sheet name changes (first item in the Feature Types list) and the sheet is no longer written out properly. I'm new to FME and have a feeling I'm making simple mistakes.

 

image

Badge +3

You can import this. Prepare an excel document as you like (copy the data including columns from the Visual Preview / Data Inspector, paste in Excel, fix column widths), then create the writer or configure the FeatureWriter, import the sheets and the column widths will imported with the column names.

 

As an alternative you can use the prepared file as a template for the writer, remove the data (not the columns) and set it as a template.

 

WriterParametersFeatureWriterParameters

Thanks for letting me know about this capability.

Badge +3

Thanks. I think that this is what I want, but I can't change the cell width unless I change the Attribute Definition to Manual or Dynamic. When I do that my Excel sheet name changes (first item in the Feature Types list) and the sheet is no longer written out properly. I'm new to FME and have a feeling I'm making simple mistakes.

 

image

I reviewed this again. If I click on Manual only, then the sheet name doesn't change. Your suggestion works great. Thanks.

 

When I first tried this, I clicked on Dynamic then clicked on Manual. That changed the sheet’s name. I guess that I’m a beginner!

 

Reply