以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  excel报表根据单元格内容触发其他单元格  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=161142)

--  作者:i4whylg
--  发布时间:2021/3/8 2:41:00
--  excel报表根据单元格内容触发其他单元格

图片点击可在新窗口打开查看此主题相关图片如下:无标题.png
图片点击可在新窗口打开查看
请老师指教:如图所示,能否判断前一个红框内的字符串的长度大于80,就以逗号分割,依次填入第二个红框内的多个单元格中

--  作者:i4whylg
--  发布时间:2021/3/8 8:49:00
--  
不打算在狐表里增加列,能实现么?
--  作者:有点蓝
--  发布时间:2021/3/8 9:07:00
--  
先生成报表,然后使用代码判断单元格的长度,再拆分。

execl文件的处理可以看看

--  作者:i4whylg
--  发布时间:2021/3/8 9:43:00
--  
请问老师我怎么才能知道选了多少行,例如单元格Sheet(i,m).value里面的i,m怎么通过代码赋值呢
--  作者:有点蓝
--  发布时间:2021/3/8 9:48:00
--  
Sheet(i,2).value = xxx
或者
dim m as integer = 2
Sheet(i,m).value = xxx

--  作者:i4whylg
--  发布时间:2021/3/8 10:28:00
--  
请教老师,我写了如下代码:
放在报表生成按钮里面:
\'\'\'
Dim Book As New XLS.Book(ProjectPath & "Attachments\\ylgg.xlsx")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim fl As String = ProjectPath & "Reports\\ylgg.xlsx"
Book.Build() \'生成细节区
Book.Save(fl) \'保存工作簿
Dim Proc As New Process \'打开工作簿
Dim i As Integer = Sheet.Rows.Count
For m As Integer = 5 To i
    Dim s As String = Sheet(m, 4).Value
    If s.Length > 10 Then
    Dim Values() As String
Values = s.split(",")
For k As Integer = 11 To Values.Length + 10
    Sheet(m, k).Value = Values(k - 11)
Next
Sheet(m, 4).Value = "见附件管号一览表"
End If
Next
Proc.File = fl
Proc.Start()

或者放在报表事件的AfterBuild里面:
Dim Book As New XLS.Book(file)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim i As Integer = Sheet.Rows.Count
For m As Integer = 5 To i
    Dim s As String = Sheet(m, 4).Value
    If s.Length > 10 Then
    Dim Values() As String
Values = s.split(",")
For k As Integer = 11 To Values.Length + 10
    Sheet(m, k).Value = Values(k - 11)
Next
Sheet(m, 4).Value = "见附件管号一览表"
End If
Next

无论放在生成报表还是放在报表事件的AfterBuild里面都没效果
[此贴子已经被作者于2021/3/8 10:32:52编辑过]

--  作者:有点蓝
--  发布时间:2021/3/8 10:34:00
--  
Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xls")
Dim
 fl As String = ProjectPath & "Reports\\出库单.xls"
Book
.Build() \'生成细节区

Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim i As Integer = Sheet.Rows.Count
For m As Integer = 5 To i
    Dim s As String = Sheet(m, 4).Value
    If s.Length > 10 Then
    Dim Values() As String
Values = s.split(",")
msgbox(Values.Length)
For k As Integer = 0 To Values.Length -1
    Sheet(m, k+11).Value = Values(k)
Next
Sheet(m, 4).Value = "见附件管号一览表"
End If
Next

Book
.Save(fl) \'保存工作簿
Dim
 Proc As New Process \'打开工作簿
Proc
.File = fl
Proc
.Start()
--  作者:i4whylg
--  发布时间:2021/3/8 10:41:00
--  
运行显示“打开存储文件失败”,不知道是什么原因
--  作者:有点蓝
--  发布时间:2021/3/8 10:43:00
--  
文件路径不正确,或者不存在

Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xls")
Dim
 fl As String = ProjectPath & "Reports\\出库单.xls"

--  作者:有点蓝
--  发布时间:2021/3/8 10:45:00
--  
\'\'\'
Dim Book As New XLS.Book(ProjectPath & "Attachments\\ylgg.xlsx")
Dim fl As String = ProjectPath & "Reports\\ylgg.xlsx"
Book.Build() \'生成细节区
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim i As Integer = Sheet.Rows.Count
For m As Integer = 5 To i
    Dim s As String = Sheet(m, 4).Value
    If s.Length > 10 Then
    Dim Values() As String
Values = s.split(",")
For k As Integer = 11 To Values.Length + 10
    Sheet(m, k).Value = Values(k - 11)
Next
Sheet(m, 4).Value = "见附件管号一览表"
End If
Next
Book.Save(fl) \'保存工作簿
Dim Proc As New Process \'打开工作簿Proc.File = fl
Proc.Start()