MM TO EXCEL


#cs ____________________________________

 Au3 版本: 3.3.6.1
 脚本作者: wozijisunfly 
 Email:
 QQ/TM:
 脚本版本: MMForYou-1.0
 脚本功能: MM TO EXCEL

#ce _______________脚本开始_________________

#include <Excel.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>

Global $fileExcel,$tcnum = 1
Local $verStr = "v-1.1.1"
Local $first[20] = ["","Depth","SpecificName","Specific","yesORno","Author","TC","Level","TCNumber","Number","Trigger","Auto","PresetCondition","Step","ExpectedResult","Remark"]
Local $fileopen,$auto,$trigger,$specific,$anyhow,$userName,$number,$filenum
Local $excel,$row,$icar = 1,$filename,$file,$getStr

If ProcessExists("EXCEL.EXE") Then
 MsgBox(0,"MMForYou","Excel.exe process is running." & @CRLF & @CRLF & "Please save it and then program will be kill it!")
 ProcessClose("EXCEL.EXE")
EndIf

_getGUI()

$excel = _ExcelBookNew()
$row = 1
$num = 1
$point = 0
While 1
 $content = FileReadLine($fileopen)
 If @error = -1 Then ExitLoop
 If StringInStr($content,"<map version=""0.8.1"">") <> 1 And $num = 1 Then
  MsgBox(0,"MMForYou","输入文件不是FreeMind文件,请重新确认.")
  FileClose($fileopen)
  Exit 1
 EndIf
 $dealString = StringStripWS($content,3)
 $strnum = StringLen($dealString)
 If StringCompare($dealString,"</map>",1) == 0 Then
  $filenum = StringSplit($file,"\")
  $fileExcel = StringReplace($file,$filenum[$filenum[0]],$filename)
  _ExcelBookSaveAs($excel,$fileExcel,"xls",0,1)
  ExitLoop
 EndIf
 If StringCompare($dealString,"</node>",1) == 0 Then
  $point = $point - 1
  If $icar <> 1 Then
   $mark = "--"
   _insertData($mark,$excel,$getStr,$row - 1,$point + 1,$tcnum)
   $icar = 1
   $tcnum = $tcnum + 1
  EndIf
  $num = $num + 1
  ContinueLoop
 Else
  $num = $num + 1
 EndIf
 If StringInStr($dealString,"<node ",1) == 1 Then
  $point = $point + 1
  $dealnum = StringInStr($dealString,"TEXT=""",1) + 6
  $lastString = StringRight($dealString,2)
  If StringCompare($lastString,"/>",1) == 0 Then
   $getnum = $strnum - 2 - $dealnum
   $getStr = StringMid($dealString,$dealnum,$getnum)
   $mark = "yes"
   _insertData($mark,$excel,$getStr,$row,$point,$tcnum)
   $tcnum = $tcnum + 1
   $point = $point - 1
   $row = $row + 1
   $num = $num + 1
   ContinueLoop
  ElseIf StringCompare($lastString,""">",1) == 0 Then
   $getnum = $strnum - 1 - $dealnum
   $getStr = StringMid($dealString,$dealnum,$getnum)
   $mark = "no"
   _insertData($mark,$excel,$getStr,$row,$point,$tcnum)
   $row = $row + 1
   $num = $num + 1
   ContinueLoop
  Else
   MsgBox(0,"MMForYou","解析FreeMind文件出错,第" & $num & "行,请检查.")
   FileClose($fileopen)
   Exit 1
  EndIf
 ElseIf StringInStr($dealString,"<icon ",1) == 1 Then
  $icar = $icar + 1
  $num = $num + 1
  ContinueLoop
 ElseIf StringInStr($dealString,"<arrowlink ",1) == 1 Then
  ;TODO 

  ;情况复杂,需要保存数组中
  ;(ID,DESTINATION=ID,TEXT)
  $icar = $icar + 1
  $num = $num + 1
  ContinueLoop

ElseIf StringInStr($dealString,"<hook ",1) == 1 Then
$icar = $icar + 1
;行数加一
$num = $num + 1
ContinueLoop
ElseIf StringInStr($dealString,"<text>",1) == 1 Then
  $point = $point + 1
  $dealnum = StringInStr($dealString,"<text>",1) + 6
  ;判断最后两个字符是否为结束字符,或异常字符
  $lastString = StringRight($dealString,7)
  If StringCompare($lastString,"</text>",1) == 0 Then
   ;获得需要得到的字符数量
   $getnum = $strnum - 6 - $dealnum
   ;获取需要解析的字符串
   $getStr = StringMid($dealString,$dealnum,$getnum)
   ;标记
   $mark = "#"
   _insertData($mark,$excel,$getStr,$row,$point,$tcnum)
   ;TCNUM
   $tcnum = $tcnum + 1
   ;将根结点减一,以适应变化的层次
   $point = $point - 1
   ;$row = $row - 1
  Else
   MsgBox(0,"MMForYou","无法解析的图标,请联系作者。" & @CRLF & "MM图中,第" & $num & "行。")
   $num = $num + 1
   ContinueLoop
  EndIf
  $icar = $icar + 1
  ;行数加一
  $num = $num + 1
  ContinueLoop

ElseIf StringInStr($dealString,"</hook>",1) == 1 Then
$icar = $icar + 1
;行数加一
$num = $num + 1
ContinueLoop
ElseIf StringInStr($dealString,"<cloud/>",1) == 1 Then
$icar = $icar + 1
;行数加一
$num = $num + 1
ContinueLoop

ElseIf StringInStr($dealString,"<font ",1) == 1 Then
  $icar = $icar + 1
  ;行数加一
  $num = $num + 1
  ContinueLoop
ElseIf StringInStr($dealString,"<edge ",1) == 1 Then
$icar = $icar + 1
;行数加一
$num = $num + 1
ContinueLoop
Else
If StringInStr($dealString,"<map version=""0.8.1"">",1) == 1 Then
ContinueLoop
ElseIf StringInStr($dealString,"<!-- ",1) == 1 Then
ContinueLoop
Else
MsgBox(0,"MMForYou","无法解析的图标,请联系作者。")
EndIf
 EndIf
 $num = $num + 1
WEnd
FileClose($fileopen)

Func _getAnalyse($getStr)
 Dim $array[1000], $getStrForChinese = "", $getChinese, $getS
 $judgenum = StringSplit($getStr,"&#x",1)
 $recordeStr = 1
 For $count = 1 To $judgenum[0] Step 1
  $ssnum = StringInStr($getStr,"&#x",2,$count)
  If $recordeStr <> $ssnum Then
   $getStrForChinese = $getStrForChinese & StringMid($getStr,$recordeStr,$ssnum - $recordeStr)
   $recordeStr = $ssnum
  EndIf
  If StringInStr(StringMid($getStr,$ssnum,8),";",2) == 8 Then
   $recordeStr = $recordeStr + 8
   $ascii = StringReplace(StringMid($getStr,$ssnum,7),"&#x","0x")
   $array[$count] = $ascii
   $getChinese = StringFromASCIIArray($array,$count,$count + 1,0)
   
   $getStrForChinese = $getStrForChinese & $getChinese
  ElseIf StringInStr(StringMid($getStr,$ssnum,5),";",2) == 5 Then
   $recordeStr = $recordeStr + 5
   If StringCompare(StringMid($getStr,$ssnum,5),"&#xa;",1) Then
    $getStrForChinese = $getStrForChinese & @LF & ""
   EndIf
  Else
   ContinueLoop
  EndIf
 Next
 
 Return $getStrForChinese
 
EndFunc

Func _getGUI()
 $Form1 = GUICreate("MMForYou", 400, 220, -1, -1)
 GUISetIcon(@SystemDir & "\mspaint.exe", 0)

 $label = GUICtrlCreateLabel("File Path:",30,13)
 $filePath = GUICtrlCreateInput("",100,10,250,Default)
 $label1 = GUICtrlCreateLabel("Number:",10,43)
 $file1 = GUICtrlCreateInput("",55,40,130,Default)
 $label2 = GUICtrlCreateLabel("UserName:",200,43)
 $file2 = GUICtrlCreateInput(@UserName,260,40,130,Default)
 $label3 = GUICtrlCreateLabel("Anyhow:",10,73)
 $file3 = GUICtrlCreateInput(@ComputerName,55,70,130,Default)
 $label4 = GUICtrlCreateLabel("Specific:",200,73)
 $file4 = GUICtrlCreateInput("",260,70,130,Default)
 $label5 = GUICtrlCreateLabel("Trigger:",5,103)
 $com1 = GUICtrlCreateCombo("",55,100,130,Default)
 $file5 = GUICtrlSetData($com1, "item1Trigger|item2Trigger|item3Trigger", "item3Trigger")
 $label6 = GUICtrlCreateLabel("  Auto  :",200,103)
 $com2 = GUICtrlCreateCombo("",260,100,130,Default)
 $file6 = GUICtrlSetData($com2, "item1Auto|item2Auto|item3Auto", "item2Auto")
 $label7 = GUICtrlCreateLabel("DATE:" & @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC,80,143,220)
 
 GUICtrlSetColor($label7,0xff00ff)
 GUICtrlSetBkColor($label7,0x000000)
 GUICtrlSetFont($label7,13)
 
 $OK_Btn = GUICtrlCreateButton("确定", 85, 170, 70, 25)
 $Cancel_Btn = GUICtrlCreateButton("取消", 225, 170, 70, 25)
 $label7 = GUICtrlCreateLabel("VERSION : " & $verStr,130,200)
 GUISetState(@SW_SHOW)
 
 Do
  $msg = GUIGetMsg()
  Select
   Case $msg = $OK_Btn
    $file = GUICtrlRead($filepath)
    $file = "E:\AnalyseMMPicture\新增思维导图.mm"
    If StringLen($file) == 0 Then
     MsgBox(0,"MMForYou","Please input File Path!")
     ContinueLoop
    EndIf
    If StringCompare(StringUpper(StringRight($file,3)),".MM") == 0 Then
     $fileopen = FileOpen($file)
     If $fileopen == -1 Then
      MsgBox(0,"MMForYou","The file can not open.")
      ContinueLoop
     EndIf
    Else
     MsgBox(0,"MMForYou","The file is not FreeMind file.")
     ContinueLoop
    EndIf
    If StringLen(GUICtrlRead($file1)) == 0 Then
     MsgBox(0,"MMForYou","Please input Number.")
     ContinueLoop
    Else
     $number = GUICtrlRead($file1)
    EndIf
    If StringLen(GUICtrlRead($file2)) == 0 Then
     MsgBox(0,"MMForYou","Please input UserName.")
     ContinueLoop
    Else
     $userName = GUICtrlRead($file2)
    EndIf
    If StringLen(GUICtrlRead($file3)) == 0 Then
     MsgBox(0,"MMForYou","Please input Anyhow.")
     ContinueLoop
    Else
     $anyhow = GUICtrlRead($file3)
    EndIf
    If StringLen(GUICtrlRead($file4)) == 0 Then
     MsgBox(0,"MMForYou","Please input Specific.")
     ContinueLoop
    Else
     $specific = GUICtrlRead($file4)
    EndIf
    $trigger = GUICtrlRead($com1)
    $auto = GUICtrlRead($com2)
    $msg = $GUI_EVENT_CLOSE
   Case $msg = $Cancel_Btn
    Exit 1
  EndSelect
 Until $msg = $GUI_EVENT_CLOSE
 
 GUISetState(@SW_HIDE)
 
EndFunc

Func _insertData($mark,$excel,$getStr,$row,$point,$tcnum)
 If $row == 1 Then
  For $rownum = 0 To 16 Step 1
   _ExcelWriteCell($excel,$first[$rownum],$row,$rownum)
  Next
  $filename = _getAnalyse($getStr)
  _ExcelSheetNameSet($excel, "INEEDYOU")
 EndIf
 $row = $row + 1
 $pointS = ""
 $dian = "."
 For $pointnum = 1 To $point Step 1
  $pointS = $pointS & $dian
 Next
 If StringLen($tcnum) == 1 Then
  $tcnumS = ".00" & $tcnum
 ElseIf StringLen($tcnum) == 2 Then
  $tcnumS = ".0" & $tcnum
 Else
  $tcnumS = "." & $tcnum
 EndIf
 If $row = 2 Then
  _ExcelWriteCell($excel,$pointS,$row,1)
  _ExcelWriteCell($excel,_getAnalyse($getStr),$row,2)
  _ExcelWriteCell($excel,$specific,$row,3)
  _ExcelWriteCell($excel,"YES",$row,4)
  _ExcelWriteCell($excel,$userName,$row,5)
  _ExcelWriteCell($excel,$number,$row,9)
  _ExcelWriteCell($excel,$trigger,$row,10)
  _ExcelWriteCell($excel,$auto,$row,11)
 ElseIf StringCompare($mark,"yes") == 0 Then
  _ExcelWriteCell($excel,$pointS,$row,1)
  _ExcelWriteCell($excel,"NO",$row,4)
  _ExcelWriteCell($excel,$userName,$row,5)
  $formula = "=""[""" & "& RIGHT(R" & $row & "C7,1)&""]""" & "&""" & _getAnalyse($getStr) & """"
  _ExcelWriteFormula($excel, $formula, $row, 6)
  _ExcelWriteCell($excel,"Level 1",$row,7)
  _ExcelWriteCell($excel,$specific & $tcnumS,$row,8)
  _ExcelWriteCell($excel,$number,$row,9)
  _ExcelWriteCell($excel,$trigger,$row,10)
  _ExcelWriteCell($excel,$auto,$row,11)
  _ExcelWriteCell($excel,"P1." & @CRLF & "P2.",$row,12)
  _ExcelWriteCell($excel,"S1." & @CRLF & "S2.",$row,13)
  _ExcelWriteCell($excel,"E1." & @CRLF & "E2.",$row,14)
 ElseIf StringCompare($mark,"no") == 0 Then
  _ExcelWriteCell($excel,$pointS,$row,1)
  _ExcelWriteCell($excel,_getAnalyse($getStr),$row,2)
  _ExcelWriteCell($excel,"NO",$row,4)
  _ExcelWriteCell($excel,$userName,$row,5)
 ElseIf StringCompare($mark,"--") == 0 Then
  _ExcelWriteCell($excel,$pointS,$row,1)
  _ExcelWriteCell($excel,"",$row,2)
  _ExcelWriteCell($excel,"NO",$row,4)
  _ExcelWriteCell($excel,$userName,$row,5)
  $formula = "=""[""" & "& RIGHT(R" & $row & "C7,1)&""]""" & "&""" & _getAnalyse($getStr) & """"
  _ExcelWriteFormula($excel, $formula, $row, 6)
  _ExcelWriteCell($excel,"Level 1",$row,7)
  _ExcelWriteCell($excel,$specific & $tcnumS,$row,8)
  _ExcelWriteCell($excel,$number,$row,9)
  _ExcelWriteCell($excel,$trigger,$row,10)
  _ExcelWriteCell($excel,$auto,$row,11)
  _ExcelWriteCell($excel,"P1." & @CRLF & "P2.",$row,12)
  _ExcelWriteCell($excel,"S1." & @CRLF & "S2.",$row,13)
  _ExcelWriteCell($excel,"E1." & @CRLF & "E2.",$row,14)

 ElseIf StringCompare($mark,"#") == 0 Then
  _ExcelWriteCell($excel , _getAnalyse($getStr) , $row - 1, 15)
 EndIf
EndFunc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
rivate Sub Command3_Click() Dim i As Long Dim j As Long Dim objExl As Excel.Application '声明对象变量 Me.MousePointer = 11 '改变鼠标样式 Set objExl = New Excel.Application '初始化对象变量 objExl.SheetsInNewWorkbook = 1 '将新建的工作薄数量设为1 objExl.Workbooks.Add '增加一个工作薄 objExl.Sheets(objExl.Sheets.Count).Name = "book1" '修改工作薄名称 objExl.Sheets.Add , objExl.Sheets("book1") '增加第二个工作薄在第一个之后 objExl.Sheets(objExl.Sheets.Count).Name = "book2" objExl.Sheets.Add , objExl.Sheets("book2") '增加第三个工作薄在第二个之后 objExl.Sheets(objExl.Sheets.Count).Name = "book3" objExl.Sheets("book1").Select '选中工作薄<book1> For i = 1 To 50 '循环写入数据 For j = 1 To 5 If i = 1 Then objExl.Selection.NumberFormatLocal = "@" '设置格式为文本 objExl.Cells(i, j) = " E " & i & j Else objExl.Cells(i, j) = i & j End If Next Next objExl.Rows("1:1").Select '选中第一行 objExl.Selection.Font.Bold = True '设为粗体 objExl.Selection.Font.Size = 24 '设置字体大小 objExl.Cells.EntireColumn.AutoFit '自动调整列宽 objExl.ActiveWindow.SplitRow = 1 '拆分第一行 objExl.ActiveWindow.SplitColumn = 0 '拆分列 objExl.ActiveWindow.FreezePanes = True '固定拆分 objExl.ActiveSheet.PageSetup.PrintTitleRows = "$1:$1" '设置打印固定行 objExl.ActiveSheet.PageSetup.PrintTitleColumns = "" '打印标题 objExl.ActiveSheet.PageSetup.RightFooter = "打印时间: " & _ Format(Now, "yyyy年mm月dd日
使用VFP读取EXCEL中的数据示例 *!* *****数据导入程序,由“学生基本基本情况表模板.xls”导入数据 *!* ***使用VFP控制EXCEL表,计取中指定列的内容*********** *!* "学生基本基本情况表模板.xls"的数据布局 *!* cells(1,1):“标题” *!* cells(2,1):校区 *!* cells(2,3):学历 *!* cells(2,5):专业 *!* cells(2,6):班级 *!* *!* set safe off set talk on LOCAL inf(4) as String *dele file C:\MyDocu~1\Resume.xlw objExcel = CreateObject("Excel.Application") &&创建一个EXCEL应用程序实例 wjm=getfile("xls") objExcel.Workbooks.Open(wjm) &&调用workbooks(Microsoft Excel 应用程序; 中当前打开的所有 Workbook 对象的集合。); 对象的open方法程序来打开指定的文件,并为; 打开的文件创建一个新的工作簿 *objexcel.visible=.f. ***下面的代码判断出生日期字段的格式是否满足要求*** *IF !varTYPE(objexcel.cells(10,6))="d" * MESSAGEBOX("出生日期字段不满足格式要求,不能导入,请将出生日期字段修改为:"+CHR(13); +"mm.dd.yy的格式,如:05.19.83 表示1983年5月19 然后再运行此导入程序") * RETURN *ENDIF inf(1)=substr(objexcel.cells(2,1).value,7)&&校区 Inf(2)=objexcel.cells(2,4).value&&学历 inf(3)=objexcel.cells(2,6).value&&专业 inf(4)=objexcel.cells(2,7).value&&班 LOCAL nrow as Number ,i as Number i=0 *MESSAGEBOX("计算行数") *MESSAGEBOX(objexcel.cells(5,1).value) *MESSAGEBOX(VARTYPE(objexcel.cells(22,1).value)) DO WHILE .t. i=i+1 ?objexcel.cells(i,1).value IF !VARTYPE(objexcel.cells(i,1).value)="C" nrow=i-1 EXIT ENDIF ENDDO *nrow=20 LOCAL arecord(16) *MESSAGEBOX("循环添加记录") USE zlb disinf("zlb.dbf中现有记录"+ALLTRIM(STR(RECCOUNT()))+"条") disinf("正在添加记录") FOR i=4 TO nrow arecord(1)=objexcel.cells(i,1).value&&学号  arecord(2)=objexcel.cells(i,2).value&&姓名 arecord(3)=objexcel.cells(i,3).value&&性别 arecord(4)=objexcel.cells(i,4).value&&籍贯 arecord(5)=objexcel.cells(i,5).value&&民族 *MESSAGEBOX(VARTYPE(objexcel.cells(i,6).value)) IF VARTYPE(objexcel.cells(i,6).value)="C" arecord(6)=RIGHT(objexcel.cells(i,6).value,2)+"/"+"01"+'/'; +LEFT(objexcel.cells(i,6).value,2) ELSE arecord(6)= RIGHT(STR(objexcel.cells(i,6).value,5,2),2); +"/"+"01"+"/"; +LEFT(STR(objexcel.cells(i,6).value,5,2),2) ENDIF &&arecord(6)=IIF(VARTYPE(objexcel.cells(i,6).value)="c",RIGHT(objexcel.cells(i,6).value,2)+"/"+"01"+'/'+LEFT(objexcel.cells(i,6).value,2),; RIGHT(STR(objexcel.cells(i,6).value,5,2),2)+"/"+"01"+'/'+LEFT(STR(objexcel.cells(i,6).value,5,2),2))&&出生年月 arecord(7)=LEFT(ALLTRIM(STR(objexcel.cells(i,8).value,6,0)),6)&&邮政编码 arecord(8)=objexcel.cells(i,7).value&&通讯地址 arecord(9)=objexcel.cells(i,9).value &&收信人 arecord(10)=iif(!ALLTRIM(objexcel.cells(i,10).value)=="",objexcel.cells(i,10).value; ,"无")&&家庭电话 arecord(11)=inf(3)&&专业 arecord(12)=inf(4)&&班级 arecord(13)=objexcel.cells(i,11).value&&寝室号码 arecord(14)=STR(objexcel.cells(i,12).value,7,0)&&寝室电话 arecord(15)=inf(1)&&校区 arecord(16)=inf(2)&&学历 SELECT zlb APPEND FROM ARRAY arecord ENDFOR disinf("zlb.dbf中现有记录"+ALLTRIM(STR(RECCOUNT()))+"条") disinf("记录添加完毕,共添加了"+ALLTRIM(STR(nrow-3))+"条记录,请查检") INKEY(3) WAIT CLEAR ****定义日期转换函数,此函数能将各种格式的日期转换成mm/dd/yy的格式**** ****如果要转换的日期只有年和月,则自动添加日为'01'*** *!* FUNCTION datetran *!* PARAMETERS soudate *!* IF VARTYPE(soudate)="N" *!* DO case *!* CASE LEN(souDATE) ***关闭工作簿,退出EXCEL objexcel.quit RELEASE objexcel *!* objexcel.save *!* *objExcel.ActiveWorkbook.saved=.f. *!* objexcel.Quit &&退出 *!* RELEASE objexcel *!* retu

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值