In many cases, we need to save the data in the Book window as a format for other applications (for example, MS Excel, Word, email, and so on). The SaveAs function is provided for this powerbuilder, However, there are some drawbacks to SaveAs saving the data window to the EXECL format, that is, it can't save the format we see, some graphics, crosstab, compute fields, etc. are discarded, and it only holds the data in the Data window buffer. To output visual data such as cross reports, groups, and compute fields, PowerBuilder 6.5 (after build 444) provides new functions to address these defects, which are: Saveasascii () functions. It allows the visual portion of the output data window to be in text format, and groups, crosstab reports, and computational fields are saved as part of the output data. This function is discussed below:
Description: Saves the contents of a data window or data store as an ASCII text file
Applies to: Data Windows and Datastore objects
Symbol:
Dwcontrol. Saveasascii (FileName {, separatorcharacter {, quotecharacter {, lineending}})
which
Dwcontrol bit Data window or datastore name
FileName: the filename to save;
Separatorcharacter (optional): A string that splits individual data, the default is tab
Quotecharacter (optional): A string enclosing the value, the default is null;
Lineending (optional): The string that is placed at the end of each line, and the default is carriage return character (~r~n)
The following example shows that the data in the data window is saved to the file Monthly.txt, and each data is split by ' | '
Dw_4.saveasascii ("Monthly.txt", "|")
Using delimiters between data is a good note, because the default tab character may be problematic when you import Excel. When you import Excel, he prompts you for what delimiters are used in your data. This article is from http://bianceng.cn (Getting started with programming)
To import into Excel, just open the file in Excel, and you may see a wizard window that defines the correct separator. The following example shows a file that is exported with the Saveasascii () function, which is not possible when using the SaveAs function.
Dept Id
Manager Id 100 200 300 400 500
501 1090
703 868
902 1039 1576
1293 902 1390
1576 1191