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