Home > database >  Saveas, please () into excel how will save to file field name in Chinese?
Saveas, please () into excel how will save to file field name in Chinese?

Time:09-21

Saveas, please () into excel how will save to file field name in Chinese?
Foreign solution using SQL select id as StudentID, dept as DepartName...
It won't be in the archive file database column names, but how to deal with in Chinese?
(because of my version of environment can't resolved using SQL)

CodePudding user response:

Advice column names don't use Chinese!

Solution: set up the corresponding text object for each column, and named colname_t, use the following f_dwSaveas save (),
Definition:
//attached API FUNCTION ulong ShellExecute (ulong HWND, ref string lpOperation, ref string lpFile, ref string lpParameters, ref string lpDirectory, ulong nShowCmd) LIBRARY "shell32. DLL" ALIAS FOR "ShellExecuteA 
"
Constant long SW_RESTORE=9
String ls_pathname ls_sfilename, ls_extendname, ls_pathname1
Int li_value li_pos, li_return
String ls_Operation ls_Parameters, ls_exe, ls_colName
N_systemapi lno_sysApi


As_filename=f_replace_missfilenamechar (as_filename, "")
Ls_pathname=as_filename

Li_value=https://bbs.csdn.net/topics/getFileSaveName (f_TranslateText (" save as "), ls_pathname, ls_sfilename, XLS, & amp;
"The.xls Files (*. Xls), *. Xls," + & amp;
"Text Files (*.txt), *. TXT," + & amp;
"The Dbf Files (*. Dbf), *. Dbf," + & amp;
"Html Files (*. Html), *. Html," + & amp;
"Psr Files (*. Psr), *. Psr," + & amp;
"The Sql Files (*.sql), *. Sql")

If li_value=https://bbs.csdn.net/topics/1 then
Ls_sfilename=Trim (ls_sfilename)
Li_Pos=LastPos (ls_sfilename, ". ")
Ls_extendname=Right (ls_sfilename, Len (ls_sfilename) - li_pos)

Choose a Case ls_extendname
Case "TXT"
Li_return=adw_obj. SaveAS (ls_sfilename, Text! , TRUE)
Ls_exe="TEXT"

Case "XLS"
Li_return=adw_obj. SaveAs (ls_sfilename excel8! , true)//8 data is not lost, but be garbled form name
Ls_exe="EXCEL"

Case "DBF
"Li_return=adw_obj. SaveAs (ls_sfilename, dBASE3! , TRUE)
Ls_exe="DBASE"

Case "HTML
"Li_return=adw_obj. SaveAs (ls_sfilename HTMLTable! , TRUE)
Ls_exe="HTML"

Case "PSR"
Li_return=adw_obj. SaveAs (ls_sfilename PSReport! , TRUE)
Ls_exe="PSR"

Case "SQL"
Li_return=adw_obj. SaveAs (ls_sfilename SQLInsert! , TRUE)
Ls_exe="TEXT"

In Case the Else
MessageBox (f_TranslateText (" tip "), f_TranslateText (" please select a file format "), the Exclamation!)
Return
The End Choose

If li_return=1 Then
MessageBox (f_TranslateText (" error "), f_TranslateText (" file save failed!" ), StopSign!)
Return
End the If


//here is to save the file after modified
Long handle_channel
Int li_ColumnCount, li_loop
String str_save
String ls_ColumnHead []

If ls_extendname="XLS" then
Lno_sysApi=create n_systemapi

Ls_Operation="open"
Ls_Parameters=""

Ls_pathname1=Left (ls_pathname, Len (ls_pathname) - Len (ls_sfilename))
Lno_sysApi. Of_ShellExecute (Handle (aw_window), ls_Operation, ls_sfilename, ls_Parameters, ls_pathname1, SW_RESTORE)

Handle_channel=OpenChannel (ls_exe ls_pathname, Handle (aw_window) establishment and EXCEL//channel
If handle_channel & gt; 0 then
Li_ColumnCount=Integer (adw_obj. Object. The DataWindow. Column. Count)//get the number of columns
For li_loop=1 To li_ColumnCount
//get the columns column headings
Ls_colName=adw_obj. The describe (" # "+ string (li_loop) +". The Name ")
Ls_ColumnHead [li_loop]=f_strip (adw_obj. The describe (ls_colName + "_t. Text"))
If ls_columnHead [li_loop]="!" Then ls_columnHead [li_loop]=ls_colName

SetRemote (" r1c "+ String (li_loop), ls_ColumnHead [li_loop], handle_channel)
Next

Str_save="[Save]"
Execremote (str_save handle_channel)

//change the value of a row or a column, at the same time close the channel
Closechannel (handle_channel, handle (aw_window))
End the if

Destroy lno_sysApi
End the if
End the if