Forum
Improved Data Export (Excel compatible)
Quote from laynemydb on 03/25/2026, 11:26 amFileMaker has a simple export for creating Excel files. Generally, it's nice, but some reports need custom headers (not fields with relationship names) and summaries, etc. This sample is an easy way to create a CSV file that can be opened in your favorite word processor.
# =-=-=-=-=-=-=-=-=-=-=-=-=-=
# Export Safaris Data
# =-=-=-=-=-=-=-=-=-=-=-=-=-=Set Variable [ $header ; Value: "Trip Status," & "Trip Name," & "Trip Code," & "Operator Name," & "Country," & "Start Date," & "End Date," & "# Nights," & "# Lodge Nights," & "# Mobile Nights," & "PAX,"& "Creation Date" ]
# Create data file
Set Variable [ $path ; Value: Get(DesktopPath) & "/Safari List.csv" ]
Create Data File [ “$path” ; Create folders: Off ]
Open Data File [ “$path” ; Target: $fileID ]
Set Data File Position [ File ID: $fileID ; New position: 1 ]
Write to Data File [ File ID: $fileID ; Data source: $header ; Write as: UTF-16 ; Append line feed ]
Go to Record/Request/Page [ First ]
Loop [ Flush: Always ]
Set Variable [ $line ; Value: GetAsText ( trip_Status::Status & "," & Trip::TripName & "," & Trip::TripCode & "," & Trip::lk_OperatorName & "," & Trip::Countries & "," & Trip::DefaultDateBegin & "," & Trip::DefaultDateEnd & "," & Trip::NumNights & "," & Trip::LodgeNight & "," … ]
Write to Data File [ File ID: $fileID ; Data source: $line ; Write as: UTF-16 ; Append line feed ]
Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
Close Data File [ File ID: $fileID ]
Show Custom Dialog [ "Exported" ; "The file has been exported to your desktop." ]
FileMaker has a simple export for creating Excel files. Generally, it's nice, but some reports need custom headers (not fields with relationship names) and summaries, etc. This sample is an easy way to create a CSV file that can be opened in your favorite word processor.
# =-=-=-=-=-=-=-=-=-=-=-=-=-=
# Export Safaris Data
# =-=-=-=-=-=-=-=-=-=-=-=-=-=
Set Variable [ $header ; Value: "Trip Status," & "Trip Name," & "Trip Code," & "Operator Name," & "Country," & "Start Date," & "End Date," & "# Nights," & "# Lodge Nights," & "# Mobile Nights," & "PAX,"& "Creation Date" ]
# Create data file
Set Variable [ $path ; Value: Get(DesktopPath) & "/Safari List.csv" ]
Create Data File [ “$path” ; Create folders: Off ]
Open Data File [ “$path” ; Target: $fileID ]
Set Data File Position [ File ID: $fileID ; New position: 1 ]
Write to Data File [ File ID: $fileID ; Data source: $header ; Write as: UTF-16 ; Append line feed ]
Go to Record/Request/Page [ First ]
Loop [ Flush: Always ]
Set Variable [ $line ; Value: GetAsText ( trip_Status::Status & "," & Trip::TripName & "," & Trip::TripCode & "," & Trip::lk_OperatorName & "," & Trip::Countries & "," & Trip::DefaultDateBegin & "," & Trip::DefaultDateEnd & "," & Trip::NumNights & "," & Trip::LodgeNight & "," … ]
Write to Data File [ File ID: $fileID ; Data source: $line ; Write as: UTF-16 ; Append line feed ]
Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
Close Data File [ File ID: $fileID ]
Show Custom Dialog [ "Exported" ; "The file has been exported to your desktop." ]