Before exporting an Excel file, set the column name to Chinese.

Source: Internet
Author: User

Solve the problem that the exported Excel column name is Chinese

Use saveasascii (docname, excel5 !, True) although the exported column name is Chinese, the exported data has a series of problems, such as the data type problem and the last four digits of the ID card number are 0;

Using the saveas (docname) method, although the exported column name is in English, the data is exported in the display mode of the data window.

You can easily set the column name to Chinese by viewing the dbname settings in the Pb help document. See:

1. Set the column name statically as follows:Code:

Dw_name.object.username.dbname = 'username' // username is the column name.

Dw_name.object.password.dbname = 'Password'

 

2. The code for dynamically setting column names is as follows:

// The data window on this page is dw_name. The click () event string docname, namedinteger valuestring ls_colname, ls_text, ls_modistr, ls_collong numcols, numrows, C, rboolean lb_exist = falsedocname = "Xinchang county urban and rural residents' social endowment insurance (continued) staff register" value = getfilesavename ("select Save file", docname, named, "xls ", "xls file (*. XLS ),*. xls ") if value = 1 thenlb_exist = fileexists (docname) If lb_exist then value = MessageBox (" save ", docname +" already exists, overwrite? ", Exclamation !, Yesno !) End if value = 1 then numcols = long (dw_name.object.data?#column.count) numrows = dw_name.rowcount () for C = 1 to numcolsls_col = "#" + String (c) + ". name "ls_colname = dw_name.describe (ls_col) ls_modistr = ls_colname +" _ T. text "ls_text = string (dw_name.describe (ls_modistr) dw_name.modify (ls_colname + ". dbname = '"+ trim (ls_text) +"' ") nextvalue = dw_name.saveas (docname, excel5 !, True) If value = 1 then MessageBox ("message", "data exported successfully! ") Elsemessagebox (" error message "," failed to export data! ") Return-1end if end ifend if

 

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.