Home > database >  In the datawindow CROSSTAB method output to EXCEL
In the datawindow CROSSTAB method output to EXCEL

Time:10-06

In the datawindow CROSSTAB table style:
See attachment, (my PB is 6.5)

I found on the Internet functions:


/* function name: uf_dwsaveas_excel
Function: the data window data export EXCEL file, and will EXCEL file title to replace the default English into Chinese,
Parameters: xin_mz_zx_tj for users to export data window window control name
Return values: an integer 1, and success; 1, the error
Process description: use first saveas () is poured out for excel file, and then replace the header for the Chinese name
Designer: yanhui in November 2003,
The modifier: Ye Wenlin 2004.4.8
Reason: to improve the readability of programs add comments such as a small amount of modified */
The integer li_rtn, ii, li_asc
String ls_name, ls_pathname
Boolean lb_exist
If xin_mz_zx_tj. RowCount () & lt; 1 then
MessageBox (" message ", "please retrieve data export to Excel again!" )
//return - 1 error
End the if
Li_rtn=GetFileSaveName (" save file ", ls_pathname ls_name, "like", "Excel file (*. XLS), *. XLS")

If li_rtn=1 then
Lb_exist=FileExists (ls_pathname)
IF lb_exist THEN
Li_rtn=MessageBox (" save ", ls_pathname + "already exists. Overwrite?" , the Exclamation! YesNo!)
End the if
If li_rtn=1 then
//when a file is user choose cover, or file doesn't seem to exist, pay attention to the variable li_rtn
Li_rtn=xin_mz_zx_tj. SaveAs (ls_pathname, Excel! , true)
If li_rtn=1 then
//MessageBox (" message ", "export data succeed!" )
The else
MessageBox (" error ", "export data failed!" )
//return - 1 error
End the if
The else
//return - 1 error
End the if
The else
The return - 1
End the if

/*
The following program will export EXCEL English title for Chinese characters
*/
Long numcols numrows, c, r
OLEObject xlapp, xlsub
Int ret
Numcols=long (xin_mz_zx_tj. Object. The datawindow. Column. Count)
Numrows=xin_mz_zx_tj. RowCount ()

//produce the oleobject instance
XlApp=Create OLEObject

//connect the ole object
Ret=xlApp. ConnectToNewObject (" Excel Sheet ")
If ret & lt; 0 then
MessageBox (" connection failed!" , "failed to connect to EXCEL, please confirm whether your system is already installed EXCEL! ~ r ~ n "& amp;
+ "error code:" + string (ret))
The return - 1
End the if
//open the EXCEL file
XlApp. Application. Workbooks. Open (ls_pathname)
//the file is
XlApp. Application. The Visible=true

//get the worksheet reference, to improve application performance
Xlsub=xlapp. Application. ActiveWorkbook. Worksheets [1]
String ls_colname ls_text, ls_modistr, ls_col
//to take the field name changed to the corresponding text text values
FOR c=1 to numcols
Ls_col="#" + string (c) + ". The name "
Ls_colname=xin_mz_zx_tj. The describe (ls_col)
Ls_modistr=ls_colname + "_t. Text"
Ls_text=xin_mz_zx_tj. The describe (ls_modistr)
Xlsub. Cells [1] c=ls_text
NEXT

XlApp. DisConnectObject ()
Destroy xlapp
MessageBox (" message ", "export data succeed!" )
Return 1//success

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --


After saved to EXCEL in the output, the column headings or English??????

See figure on the second floor!

Please help! Thank you










CodePudding user response:

CodePudding user response:

\ Users \ \ Administrator \ Desktop \ saved as EXCEL JPG

CodePudding user response:

2 picture I couldn't pass it!!!!!

CodePudding user response:



After I saved as EXCEL, the column name is still in English, expert help!!!

CodePudding user response:

Give you a function, but also others from the Internet to find
Name is adw_dw incoming parameters, the parameter type is a data window control (note that instead of the data window can be placed in the window of the data window control)
The return value is a Boolean type, can be used to determine whether save success, I hope it can help you

///////////////////////////////////////////////////////////////////////////
//
//Parameters: adw_dw: datawindow
//as_file: file name
//Returns: true/false: Boolean
//Description: Save the datawindow as a excel file.
//
///////////////////////////////////////////////////////////////////////////
//the author: purplekite
//date: 2003-01-23
///////////////////////////////////////////////////////////////////////////

SetPointer (HourGlass!

//declare the local variables
Long I, j, li_pos
Int li_value
String ls_objects ls_obj, ls_text ls_err, ls_sql, ls_path, ls_fname
Datastore lds_saveas//export data window
Datastore lds_sort//obtained according to the object. The sort of x band (=detail and visible=1) of the column/compute
Boolean lb_return//the return value
String ls_pbver//pb version information
The environment env//environment variable

Getenvironment (env)
Ls_pbver=string (env. Pbmajorrevision)
Li_value=https://bbs.csdn.net/topics/GetFilesaveName (" please select the export file ", & amp;
+ ls_path, ls_fname, "TXT", & amp;
+ "Excel file (*. XLS), *. XLS," & amp;
)
IF li_value & lt;> 1 THEN return false
//create a row of sequence datastore
Lds_sort=create datastore
Ls_sql='column=(type=char (1) the name=ztext dbname="ztext")' + '~ r ~ n + & amp;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related