SaveDisplayedDataAs

Description

Saves the display values of the DataWindow in the specified format.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataStore object


Syntax

PowerBuilder

integer dwcontrol.SaveDisplayedDataAs ( { string filename, saveastype saveastype { , encoding encoding } } )

Argument

Description

dwcontrol

A reference to a DataWindow control or DataStore.

filename

(optional)

A string whose value is the name of the file in which to save the contents. If you omit this argument, or specify an empty string ("") for filename but specify valid values for the saveastype argument, the DataWindow prompts end users for a file name.

If you are working with a DataStore, you must supply the filename argument.

saveastype

(optional)

A value of the SaveAsType enumerated datatype specifying the format in which to save the contents of the DataWindow object.

Supported formats include:

  • Text!

  • CSV!

  • Excel!

  • Excel5!

  • Excel8!

  • XLSX!

  • XLSB!

encoding

(optional)

Character encoding of the file to which the data is saved.

This parameter applies only to the following formats: TEXT and CSV. If you do not specify an encoding parameter, the file is saved in the ANSI format.

Values are:

  • EncodingANSI! (default)

  • EncodingUTF8!

  • EncodingUTF16LE!

  • EncodingUTF16BE!


Return value

Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is null, SaveDisplayedDataAs returns null.

Usage

SaveDisplayedDataAs is like SaveAs. However, unlike SaveAs, SaveDisplayedDataAs formats the text and saves column headers in the form in which they are displayed in the DataWindow instead of as the column name. For example, if the heading for the cust_id column is Customer ID, SaveDisplayedDataAs saves Customer ID to the text file, whereas SaveAs saves cust_id. SaveDisplayedDataAs also saves computed fields and allows you to customize formats in the file.

PowerBuilder assigns a cell for each DataWindow object (which can include computed columns and group totals).

If you do not specify any arguments for SaveDisplayedDataAs, PowerBuilder displays the Save As dialog box. A drop-down list lets the user specify the format of the saved data.

SaveDisplayedDataAs supports Grid, Tabular, FreeForm, CrossTab, N-up, Group, and TreeView DataWindows, but does not support Composite, Graph, OLE, RichText, and Label styles in DataWindow.

SaveDisplayedDataAs supports saving the display values of the DDLB, DDDW, RadioButton, and EditMask.

SaveDisplayedDataAs supports saving the display value of the Edit column according to the format setting.

SaveDisplayedDataAs supports saving Text, Column and Computed Field objects; but does not support saving graphical objects such as Button, Picture, GroupBox, Line, etc.

SaveDisplayedDataAs supports saving data of the band layer, and does not support saving the data of the Foreground and Background layers.

SaveDisplayedDataAs does not support saving Font attributes, including FaceName, Size, Color, Bold, etc.

If the visible property of the object is set via the computed field, the visibility of the first row in that column will determine whether the data in the other rows is saved. Specifically, if the first row is set to visible, the subsequent rows will also be saved; if it is not visible, the other rows will not be saved either.

The width of cells in Excel may not match the width of columns in the DataWindow.

Due to differences between Excel and DataWindow, for non-Grid style DataWindows, if objects are not aligned properly, the content may be misaligned when saved to Excel.

When object heights vary significantly, blank rows may appear in the data when saved to Excel.

Examples

The following script saves the contents of dw_1 to the file c:\test.xlsx.

// save to excel
Dw_1.SaveDisplayedDataAs ("c:\test.xlsx", XLSX!)

See also

SaveAs

SaveAsFormattedText