1 Reply Latest reply on Feb 25, 2015 5:51 AM by mbornhoe

    Exporting a Layout with Labels to a text file.

    KenSutton

      Title

      Exporting a Layout with Labels to a text file.

      Post

      I have spent the last couple of days trying to solve the following problem with filemaker.

      I have a layout designed that I would like to export to a comma delimited file.

      It is laid out as follows.

      ============================================================

      Header Line 1   Fieldnlabel1,Fieldlabel2,Fieldlabel3 ... (New Line)

      Header Line 2  Fieldlabel4,Fieldlabel5, Fieldlabel6 (New Line)

      Header Line 3  TEXT (Newline)

       

      Body                Field1,Field2,Field3

      Body line 2       Field4, Field5, Field6

      TEXT

      ============================================================

      I need to export the header lines as three seperate lines with a Return at the end of each.

      I then need to export the body once for each record in the database.

      If I use the Export field contents script option the file gets overwritten with each new line and I end up with just the last line in the file.

      If I use the export records or Merge export I get my header reduced to a single line with the field names Followed by the contents of each record on a single line per record.

      Any ideas to point me in the right direction to get this achieved. Can the export field contents be used to append to an existing file instead of creating a new one each time.

      Your Thoughts would be appreciated.

      Ken

        • 1. Re: Exporting a Layout with Labels to a text file.
          mbornhoe
          I have done something similar with a couple of solutions I have built.
          Try this.  Create a calculation field with a result of text and name it "OutputText" or whatever is appropriate for you and use the following:
          Case ( Get ( RecordNumber ) = 1; "fieldlabel1,fieldlabel2,fieldlabel3..." & Char ( 13 ) //Header1
          & "fieldlabel4,fieldlabel5,fieldlabel6..." & Char ( 13 ) //Header2
          & "TEXT" & Char ( 13 )  //Header3
          & field1 & ","& field2 & ","& field3...& Char(13)  //Body1
          & field4 & ","& field5 & ","& field6...& Char(13)  //Body2
          & "TEXT"  //Body3
          ;  //Else
          & field1 & ","& field2 & ","& field3...& Char(13)  //Body1
          & field4 & ","& field5 & ","& field6...& Char(13)  //Body2
          & "TEXT"  //Body3
          )  //End Case Statement
          Export the field "OutputText" and you should have the export file you wanted.  Only the first record will contain the three lines of header information and the three lines of data.  After that only the three lines of data will output.  I hope this helps.  Good luck.