以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]遍历所有单元格后,执行缩进代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=98491)

--  作者:jyh7081
--  发布时间:2017/3/30 16:44:00
--  [求助]遍历所有单元格后,执行缩进代码

下面是当前单元格缩进代码,想遍历所有表、所有单元格后,再执行。

1、缩进代码:

Dim str As String = CurrentTable.Value
    str = str.Replace(chr(10), "").replace("    ", "")
    str = "    " & str.Replace(chr(13), vbcrlf & "    ").trim()
    CurrentTable.Value = str

 

2、遍历代码:

For Each t As Table In Tables
    For Each r As Row In t.rows
        For Each c As Col In t.cols
            

        Next
    Next
Next

 

3、所有单元格缩进2个字符:

 

谢谢!


--  作者:狐狸爸爸
--  发布时间:2017/3/30 17:27:00
--  
虽然可以帮你写出代码,但是我强烈反对你这么做,因为多次一举,而且有副作用。
这种缩进,应该在报表输出的报表加上,而不是在数据中加上。
所以我就不写了。

--  作者:有点色
--  发布时间:2017/3/30 17:42:00
--  
For Each t As Table In Tables
    For Each r As Row In t.rows
        For Each c As Col In t.cols
            If c.IsString AndAlso c.DataCol.Expression = "" Then
                Dim str As String = r(c.name)
                str = str.Replace(chr(10), "").replace("    ", "")
                str = "    " & str.Replace(chr(13), vbcrlf & "    ").trim()
                r(c.name) = str
            End If
        Next
    Next
Next