Skip to main content
Question

Creating "Excel formatted table"

  • February 13, 2020
  • 2 replies
  • 286 views

cdalessandro
Contributor
Forum|alt.badge.img+4

Is there a way to create an Excel formatted table with FME?

 

I can create only a named group of cells using this sintax in xls writer sheet name parameter : <sheet_name>/<group_name> as showed below

 

Thank You

2 replies

Forum|alt.badge.img+2
  • February 13, 2020

@cdalessandro We haven't had any luck working with tables in Excel, yet. If you could use a named range to define the data in the table then I think it should work. Then you could use a template to define the table/named range in a similar way to Using a Template File when Writing Excel Data. Alternatively some scripting in Excel may be the approach.

Anyone with deep knowledge of Excel please chime in...


cdalessandro
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 14, 2020

Thank You Mark,

I wrote a macro to do that. I attached it if anyone need it

 

Sub CreaTabelleInFogli()

 

 

 

 

Dim i As Integer

 

 

Dim nr As Integer

 

 

Dim sheetName As String

 

 

Dim rng1 As Range, rng2 As Range

 

 

Dim NewRng As Range

 

 

 

 

' Ciclo tutti i fogli a partire dal secondo

 

 

For i = 4 To Sheets.Count

 

 

' Attivo il foglio sul quale si effettua l'elaborazione

 

 

Sheets(i).Activate

 

 

' Ciclo tutte le righe per trovare la prima null

 

 

For nr = 1 To 4000

 

 

If ActiveSheet.Cells(nr, 1) = vbNullString Then

 

 

Exit For

 

 

End If

 

 

Next nr

 

 

' Setto i range e li seleziono

 

 

Set rng1 = ActiveSheet.Range("A1")

 

 

Set rng2 = ActiveSheet.Range("A" & nr - 1)

 

 

Set NewRng = ActiveSheet.Range(rng1.Address & ":" & rng2.Address)

 

 

NewRng.Select

 

 

' Definisco il nome della tabella

 

 

sheetName = ActiveSheet.Name

 

 

' Creo la tabella

 

 

ActiveSheet.ListObjects.Add(xlSrcRange, NewRng, , xlYes).Name = _

 

sheetName

 

 

 

 

Set rng1 = Nothing

 

 

Set rng2 = Nothing

 

 

Set NewRng = Nothing

 

 

Next i

 

 

 

 

End Sub

 


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