Brian Dunning's FileMaker Custom Functions

ExcelExportCleaner ( text )

Returns the specified text in a format that is safe to export.

  Be the first to rate this function Log in to vote

Marcus Nilsson   Marcus Nilsson - Show more from this author
Square Moon
https://www.squaremoon.se/

Share on Facebook Share on Twitter

  Sample input:
ExcelExportCleaner ( "Hi Marcus.¶¶My name is…" )
  Sample output:
"Hi Marcus. My name is…"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

/**
* ==================================================================
* ExcelExportCleaner ( text )
*
* PARAMETERS:
* @text (text) Text value
* RETURNS:
* (text) An export friendly text
* EXAMPLE:
* ExcelExportCleaner ( "Hi Marcus.¶¶My name is…" ) returns "Hi Marcus. My name is…"
* DEPENDENCIES:
* None
* AUTHOR:
* Marcus Nilsson, Square Moon Industries AB, marcus@squaremoon.se
* PURPOSE:
* Returns the specified text in a format that is safe to export.
* NOTES:
* none
* REVISIONS:
* 2017-04-10, Marcus Nilsson. Created.
* 2017-04-11, Marcus Nilsson. Redesigned the custom function and made it recursive.
* 2017-04-11, Marcus Nilsson. Added "Char ( 10 ) = "¶" = LF = Line feed.
* ==================================================================
*
*/

Let (
[
~patternCount1 = GetAsNumber ( PatternCount ( text ; "¶" ) ) ;
~patternCount2 = GetAsNumber ( PatternCount ( text ; Char ( 13 ) ) ) ;
~patternCount3 = GetAsNumber ( PatternCount ( text ; Char ( 8232 ) ) ) ;
~patternCount4 = GetAsNumber ( PatternCount ( text ; Char ( 10 ) ) ) ;
~patternCountTotal = GetAsNumber ( ~patternCount1 + ~patternCount2 + ~patternCount3 + ~patternCount4 )
] ;
If ( ~patternCountTotal = GetAsNumber ( 0 ) ;
text ;
// Else
Let (
[
~substitutedText = Substitute ( text ;
[ "¶" ; " " ] ;
[ Char ( 13 ) ; " " ] ; /* Char ( 13 ) = "¶" = CR = Carriage return */
[ Char ( 8232 ) ; " " ] ; /* Char ( 8232 ) = "¶" */
[ Char ( 10 ) ; " " ] /* Char ( 10 ) = "¶" = LF = Line feed */
)
] ;
ExcelExportCleaner ( ~substitutedText )
)
)
)

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: