Foxtable(狐表)用户栏目专家坐堂 → 报存储空间不足


  共有2241人关注过本帖树形打印复制链接

主题:报存储空间不足

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/4/17 17:11:00 [显示全部帖子]

 上传个实例上来测试下吧,调试才知道问题所在。

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/4/19 11:39:00 [显示全部帖子]

1、我这边设备可能好一点,没有报错。

 

2、当打开excel,特别是给数组赋值的时候,行数列数越多,需要的内存就越多,当你电脑支撑不住的时候,就会报错。

 

3、你给数组赋值的时候,可以每次1000行,这样可以减少内存溢出的问题。


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/4/19 12:32:00 [显示全部帖子]

 参考这里

 

http://www.foxtable.com/webhelp/scr/2121.htm

 

 动态设置range即可。


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/4/19 14:23:00 [显示全部帖子]

Dim st As Date = Date.Now
Dim lbl As WinForm.Label = Forms("窗口1").Controls("Label6")
Dim lbl8 As WinForm.Label = Forms("窗口1").Controls("Label8")
Dim lbl9 As WinForm.Label = Forms("窗口1").Controls("Label9")
Dim path As String = args(0)
Dim file As Object
Dim app As new MSExcel.Application
'app.visible = True
'//准备字典信息
'try
Dim dic As new Dictionary(of String,String)
Dim dicfile As String =  Forms("窗口1").Controls("TextBox2").value

Dim Book As New XLS.Book(dicfile) '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表

For i As Integer = 0 To Sheet.Rows.Count-1
    If dic.ContainsKey(Sheet(i, 0).Text.ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), "")) = False Then
        dic.add(Sheet(i, 0).Text.ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), ""),Sheet(i, 1).Text)
    End If
Next

'--------------------

'//开始翻译
For Each file In FileSys.GetFiles(path)
    'try
    'Dim excelcol As Integer
    'Dim excelrows As Integer
   
    If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
        Dim wb=app.WorkBooks.open(file)
       
        For k As Integer=1 To wb.worksheets.Count
           
            Dim Ws As MSExcel.WorkSheet=Wb.WorkSheets(k)
            Dim RowsMax As Integer = 0
            'Dim ColsMax  As Integer = 0
            Dim ColsMax As Integer = ws.UsedRange.columns.count
            'Dim ColsMax  As Integer = ws.UsedRange.columns.count
            Output.Show("ws.UsedRange.columns.count=" & ColsMax )
            '获取最大行
            For i As Integer = 1 To ColsMax
                Dim r = ws.cells(1048576,i).End(MsExcel.XlDirection.xlUp).Row '扩展名为XLSX的文件最大行为1048576
                If r > RowsMax Then
                    RowsMax = r
                End If
            Next
            Output.Show("rowsmax =" & rowsmax )
            '获取最大列
            For i As Integer = 1 To RowsMax
                Dim r = ws.cells(i,16384).End(MsExcel.XlDirection.xlToLeft).Column  '扩展名为XLSX的文件最大列为16384
                If r > ColsMax Then
                    ColsMax = r
                End If
            Next
           
           
            Output.Show("ColsMax =" & ColsMax )
            'Output.Show(ws.UsedRange.Rows.count)
            Dim  rg As MSExcel.Range =  Ws.Range(Ws.Cells(1,1), Ws.Cells(RowsMax,ColsMax))
            'Dim rg As MSExcel.Range=Ws.UsedRange
            If rg.Count = 1 And rg(1).Value = "" Then
                Continue For
            End If
            Dim idx As Integer = 1
            Do While True
                If idx > Rowsmax Then Exit Do
                Dim max As Integer = iif(idx+1000>Rowsmax, Rowsmax, idx+1000)
                rg =  Ws.Range(Ws.Cells(idx,1), Ws.Cells(max,ColsMax))
               
                Dim ary = rg.value
               
                Output.Show("ary ok")
                For i As Integer= 1 To rg.Rows.count
                   
                    For j As Integer = 1 To ColsMax
                       
                        If ary(i, j) <> Nothing  AndAlso Typeof ary(i,j) Is String AndAlso dic.ContainsKey(ary(i,j).ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), "")) Then
                            rg(i, j).Value= ary(i,j) & "|" & dic(ary(i,j).ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), ""))
                        End If
                    Next
                Next
                idx = max+1
            Loop
        Next
       
        Dim txt1 As WinForm.TextBox = Forms("窗口1").Controls("TextBox3")
        txt1.text = file & vbcrlf & txt1.text & vbcrlf
        Application.DoEvents()
        FileCount=FileCount+1
        lbl.Text="共处理" & FileCount & "个文件"
        wb.Save
       
    End If
   
Next
app.quit

For Each p As String In FileSys.GetDirectories(path)
    Functions.Execute("处理隐藏列", p)
Next
lbl9.Text="计算结束, 耗时: " & (Date.Now - st).TotalSeconds & "秒"


 回到顶部