#include <Array.au3>
#include<Excel.au3>
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir&"\新建 Microsoft Excel 工作表.xls");自己的桌面文档名称,自行更改
Local $aResult = _Excel_RangeRead($oWorkbook, "Sheet1","A1:A8") ;读取Sheet1 里面A1-A8的内容
_ArrayDisplay($aResult,'Debug~~~')
$sresult =_ArrayToString($aResult,@CR)
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$sresult' & @lf & @lf & 'Return:' & @lf & $sresult & @lf & @lf & '@Error:' & @lf & @Error) ;### Debug MSGBOX
$zresult=StringRegExpReplace($sresult, '(\d+)\.(\d{3})\.(\d{3})', '$1.$2$3') ;利用正则替换小数点
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$zresult' & @lf & @lf & 'Return:' & @lf & $zresult & @lf & @lf & '@Error:' & @lf & @Error) ;### Debug MSGBOX
MsgBox($MB_SYSTEMMODAL, "", _ArrayToString($aResult,@CR));补充右括号之后。。。。。。。。。。。。。。。。
$aResult2=StringSplit($zresult, @CR,2);2, 关闭第一个元素中的返回数量
_ArrayDisplay($aResult2,'Debug~~~')
_Excel_RangeWrite($oWorkbook,"Sheet1",$aResult2,"B1:B8",True) ;写入到B1:B8里面
Local $FileNew = StringFormat('%04s%02s%02s_%02d%02d%02d.xls', @YEAR, @MON, @MDAY, @HOUR, @MIN, @SEC) ;以当前时间给工作表命名
_Excel_BookSaveAs($oWorkbook, @DesktopDir & "" &$FileNew , Default, True)
|