CodePudding user response:
Is a list of ah, do a DW is a column, COPY the data in the past, to exportCodePudding user response:
Cycle to take out the dw a list of the values of the middle row value r ~ n together with a string, copy to clipboard paste to excel in
OLEObject ExcelServer
The Integer li_ExcelOK
String ls_Str
='column name ~ r ~ ls_Str n1 ~ r ~ n ~ r ~ n3 ~ r ~ n4 interchange ~ r ~ n5'
ExcelServer=Create OLEObject
Li_ExcelOK=ExcelServer. ConnectToNewObject (" excel. Application ")
IF li_ExcelOK & lt; 0 THEN
MessageBox (" error ", "connection Excel program failed." that StopSign! , Ok!
RETURN
END the IF
ExcelServer. Application. Workbooks. The add ()
ExcelServer. Application. Sheets (" Sheet1 "). SELECT
ExcelServer. Application. Range (" A1 "). SELECT
The Clipboard (ls_Str)
ExcelServer. ActiveSheet. Paste
ExcelServer. ActiveWorkbook. SaveAs (" D: \ aaaa. XLS ")
ExcelServer. Workbooks. CLOSE
ExcelServer. Quit ()
ExcelServer. DisconnectObject ()
Destroy ExcelServer
The Clipboard (' ')
MessageBox (', 'D: \ aaaa XLS saved')
CodePudding user response:
So please write wrong in that??The integer li_rtn, ii, li_asc
String ls_name, ls_pathname
Boolean lb_exist
Long numcols, c, r, j
OLEObject xlapp, xlsub
Int ret
If dw_1. 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
Li_rtn=dw_1. SaveAs (ls_pathname, excel! , true)
If li_rtn=1 then
MessageBox (" message ", "export data success -- -- -- -- -- -- -- --!" )
The else
MessageBox (" error ", "export data failure -- -- -- -- -- -- -- --!" )
//return - 1 error
End the if
The else
//return - 1 error
End the if
The else
The return - 1
End the if
//...
Numcols=long (dw_1. Object. The DataWindow. Column. Count)
XlApp=Create OLEObject//produce the OLEObject instance
Ret=xlApp. ConnectToNewObject (" Excel Sheet ")//connect the ole object
If ret & lt; 0 then
MessageBox (" connection failed!" , "failed to connect to EXCEL, please confirm whether your system is already installed EXCEL! ~ r ~ n "+" error code: "+ string (ret))
The return - 1
End the if
XlApp. Application. Workbooks. Open (ls_pathname)//Open the EXCEL file
XlApp. Application. The Visible=true////the file is
Xlsub=xlapp. Application. ActiveWorkbook. Worksheets [1]//get the worksheet references to improve program performance
String ls_colname ls_text, ls_modistr, ls_col
For c=1 to dw_1. Rowcount ()
J=c + 1//consider header row
Xlsub. Cells [j] 1.=dw_1 object. Si [c]//to the cell assignment
MessageBox (" error ", j)
Next
XlApp. DisConnectObject ()
Destroy xlapp
MessageBox (" message ", "export data succeed!" )
Return 1//success
CodePudding user response:
New add a DW, put to export COPY to come over, then based on DW is derived, the most simpleCodePudding user response:
Copy, paste, like EXCEL operationCodePudding user response:
Son database right-click the task - export (excel)CodePudding user response:
Copy, paste, like EXCEL operationCodePudding user response:
This simple ah, you can click to take of this column, generate a new datawindow, export in the new DW