Description
Saves the contents of a DataWindow or DataStore in the format you specify.
Controls
DataWindow controls, DataStore objects, and child DataWindows
Syntax
dwcontrol.SaveAs ( { filename, saveastype, colheading } )
Argument Description
dwcontrol The name of the DataWindow control, DataStore, or child DataWindow whose contents you want to save
filename (optional) A string whose value is the name of the file in which to save the contents. If you omit filename or specify an empty string (""), PowerBuilder prompts for the filenameWorking with DataStore objects If you are working with a DataStore, you must supply the filename argument
saveastype (optional) A value of the SaveAsType enumerated data type specifying the format in which to save the contents of the DataWindow object. Values are:?Clipboard! ?Save to the clipboard?CSV! ?Comma-separated values?dBASE2! ?dBASE-II format?dBASE3! ?dBASE-III format?DIF! ?Data Interchange Format?Excel! ?Microsoft Excel format?Excel5! ?Microsoft Excel 5 format?HTMLTable! ?Text with HTML formatting that approximates the DataWindow layout?PSReport! ?Powersoft Report (PSR) format?SQLInsert! ?SQL syntax?SYLK! ?Microsoft Multiplan format?Text! ?(Default) Tab-separated columns with a return at the end of each row?WKS! ?Lotus 1-2-3 format?WK1! ?Lotus 1-2-3 format?WMF! ?Windows Metafile formatPlatform information On Macintosh, PSReport! and WMF! are not supported. The Clipboard! format does not support saving graphs to the clipboard.
colheading (optional) A boolean value indicating whether you want to include the DataWindow's column headings at the beginning of the file. The default value is TRUE.For dBASE files Column headings are always saved for dBASE files.
Return value
Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is NULL, SaveAs returns NULL.
Usage
If you don't specify any arguments for SaveAs, PowerBuilder displays the Save As dialog box.
A dropdown listbox lets the user specify the format of the saved data.
If the DataWindow is a composite report, Report format (PSReport! value of SaveAsType) is the only reasonable choice.
If the DataWindow object has the RichText presentation style, choosing PSReport! has no effect.
Saving in PowerBuilder for Unicode
If you are using the Unicode version of PowerBuilder, there are some differences in the way the SaveAs function saves the contents of a DataWindow to the several file formats, specifically how character strings are handled and whether files are marked as Unicode files (two extra bytes added to the start of the file).
File type Format of saved file Unicode file
CSV! Comma-separated values saved as Unicode strings Yes
dBASE2!, dBASE3!, DIF!, Excel!, Excel5!, SYLK!, WKS! Character strings saved as ANSI strings
HTMLTable! HTML syntax saved as a Unicode string Yes
PSReport! Only accessible in the version of PowerBuilder (ANSI or Unicode) in which it was saved
SQLInsert! SQL syntax and data values saved as Unicode strings Yes
Text! Text saved as Unicode strings Yes
WMF! Same in the ANSI or Unicode versions of PowerBuilder