exportcell(
exportcell(
FIELD
,
USEPATTERN
)

The exportcell( function takes any database field and converts it to text, using the appropriate display pattern if one has been defined for the field.

Parameters

This function has two parameters:

field – is the name of the field to be converted to text.

usepattern – is an optional pattern that specifies whether the custom display pattern for this field will be used. If false, the standard editing pattern will be used. For example, suppose you are exporting a date field with a custom display pattern of Month ddnth, yyyy. If the usepattern parameter is true (or omitted), the date will be exported using this pattern, for example April 27th, 2015. If the usepattern parameter is false, the date will be exported using the default pattern, for example 04/27/15.

Description

The function converts the data in the current record of the specified field into text. The power of the exportcell( function is that it does not require you to know what type of data you are exporting. It simply takes whatever kind of data is in the field (text, number, date, whatever) and converts it into text.

This example takes any database and outputs it in a comma separated format with quotes around each field.

    global LineFormula
    LineFormula=dbinfo("fields","")
    arrayfilter LineFormula,LineFormula,cr(),
        {""""+exportcell(«}+import()+{»)+""""}
    LineFormula=replace(LineFormula,cr(),{+","+}+cr())
    execute {export "Comma.txt",}+LineFormula

For example, the output of this procedure might look something like this if used with a checkbook database:

    "145","5-dec-97","Acme Widgets","$356.78"
    "146","6-dec-97","Wilson Publishing","$2,994.12"
    "147","9-dec-97","Yellow Freight","$390.12"

Notice that the text and numeric fields have been appropriately converted, without any special handling on the part of the export procedure.

If you’ve never used the execute statement before, this procedure may be a bit unclear. The first five lines of the procedure build a formula. The final formula, which is stored in the LineFormula variable, will be something like this

    """"+exportcell(«CheckNo»)+""""+","+
    """"+exportcell(«Date»)+""""+","+
    """"+exportcell(«Pay To»)+""""+","+
    """"+exportcell(«Amount»)+""""

The final line in the original procedure uses this formula to export the data from the database.

Here is a modified version of this procedure. An additional parameter, false(), has been added to each exportcell( function.

    global LineFormula
    LineFormula=dbinfo("fields","")
    arrayfilter LineFormula,LineFormula,cr(),
        {""""+exportcell(«}+import()+{»,false())+""""}
    LineFormula=replace(LineFormula,cr(),{+","+}+cr())
    execute {export "Comma.txt",}+LineFormula

Here is the LineFormula result, showing the extra false() parameter on each line:

    """"+exportcell(«CheckNo»,false())+""""+","+
    """"+exportcell(«Date»,false())+""""+","+
    """"+exportcell(«Pay To»,false())+""""+","+
    """"+exportcell(«Amount»,false())+""""

With this option, the numbers and dates are exported using Panorama’s default format instead of the custom patterns that have been set up for the Date and Amount fields.

    "145","12/05/97","Acme Widgets","356.78"
    "146","12/06/97","Wilson Publishing","2994.12"
    "147","12/09/97","Yellow Freight","390.12"

See Also

- datepattern( -- converts a number representing a date into text. The function uses a pattern to control how the date is formatted (see Date Patterns).
- export -- exports the selected rows in the current database into a text file.
- exportline() --
- pattern( -- converts a number into text using a pattern.
- str( -- converts a number into text, with no formatting.

History

Version | Status | Notes
10.0 | Updated | Carried over from Panorama 6.0, now there is an optional second parameter that specifies whether custom field patterns should be used. Note: In Panorama 6 and earlier versions, the exportcell function would truncate text fields to the first line. Now all of the text in the cell is always exported. Use the firstline( function if you only want to export the first line.