Save a PB Data window as a full Excel table

Source: Internet
Author: User
Tags crosstab

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.