本帖最后由 chzj589 于 2018-9-26 18:45 编辑
试试:
Local $ListColumnCount = _GUICtrlListView_GetColumnCount($ListView3)
Local $ListRowCount = _GUICtrlListView_GetItemCount($ListView3)
If $ListRowCount <> 0 Then
Dim $ItemArray[1][$ListColumnCount]
For $i = 0 To $ListRowCount - 1
$aItem = _GUICtrlListView_GetItemTextString($ListView3, $i)
_ArrayAdd($ItemArray, $aItem, 0)
Next
_ArrayDelete($ItemArray, 0)
Local $oExcel = _Excel_Open()
Local $sWorkbook = @ScriptDir & "\拣货单.xlsx";GUICtrlRead($CA_Inputb29);@ScriptDir & "\Book13.xlsx";"\.xls"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
$oWorkbook.activesheet.cells(2, 1).resize($ListRowCount, $ListColumnCount) = $oWorkbook.application.transpose($ItemArray)
$oWorkbook.activesheet.Range("A1:F" & $ListRowCount + 1).Select ;选中区域
$oWorkbook.activesheet.range("A1:F" & $ListRowCount).borders.linestyle = 1 ;设置边框
EndIf
_Excel_Close($oExcel)
If @error Then Exit MsgBox(0, "Excel UDF: _Excel_Close 示例 2", "关闭 Excel 应用时出错." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Sleep(2000)
$aProcesses = ProcessList("Excel.exe")
;MsgBox(0, "Excel UDF: _Excel_Close 示例 2", "函数成功结束." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel 实例仍在运行.")
|