我想把excel中 第5到1440行的数据转换为二进制文件存到电脑中,
请问高手该怎样实现

解决方案 »

  1.   

    Sub Temp() 'VBA版
      'Dim Sheet1 As Object
      'Dim ExcelApplication As Object
      'Set ExcelApplication=CreateObject("Excel.Application")
      'Set Sheet1=ExcelApplication.Sheets.Open(strFileName) '需要指定Excel文件名变量strFileName  Dim fn As Integer
      Dim i As Long,j As Long,k As Long  fn=FreeFile()
      Open "Temp.txt" For Binary As #fn
      For i=5 To 1440
        For j=1 To 256 '假设每行最大有256个单元格,可视情况设定
            If Len(Trim(Sheet1.Cells(i,j)))>0 Then
               k=0
               Put #fn,,Sheet1.Cells(i,j)
            Else
               k=k+1
            End If
            If k>10 Then Exit For '如果连续有10个无数据的单元格,则读下一行
            DoEvent '由于循环占用了大量的CPU运行时间,故在此作释放.
        Next
      Next
      Close #fn
      'ExcelApplication.Quit
      'Set Sheet1=Nothing
      'Set ExcelApplication=Nothing
    End Sub
      

  2.   

    sorry
    总是出现Script Error 无法给分