Foxtable(狐表)用户栏目专家坐堂 → 关于ListView的显示问题


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

主题:关于ListView的显示问题

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/15 21:21:00 [只看该作者]

Dim de As Table = Tables("临时箱单")
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.Black
Style.BorderColorBottom = Color.Black
Style.BorderColorLeft = Color.Black
Style.BorderColorRight = Color.Black
Sheet.Rows(0).Height = 30 '设置第1行的行高
Style.AlignHorz = XLS.AlignHorzEnum.Center
Style.AlignVert = XLS.AlignVertEnum.Center
de.CreateSheetHeader(Sheet,1,0,False)'生成表头
Sheet(0,0).Value = "产品销售统计"
Dim styel1 As XLS.Style = Book.NewStyle() '定义新样式
styel1.font = New Font("雅黑", 16, FontStyle.Bold)
Sheet(0,0).Style = styel1
For r As Integer = 0 To de.Rows.Count - 1 '填入数据
    For c As Integer = 0 To de.Cols.Count -1
        Sheet.Cols(0).Width = 120
        Sheet.Cols(1).Width = 120
        Sheet.Cols(2).Width = 70
        Sheet.Cols(3).Width = 120
        For a As Integer = 4 To de.Cols.Count -3
            Sheet.Cols(a).Width = 30 '设置第1列的宽度
        Next
        For a As Integer = de.Cols.Count -2 To de.Cols.Count -1
            Sheet.Cols(a).Width = 50 '设置第1列的宽度
        Next
        Sheet.MergeCell(0,0,1,c+1)
        Sheet(r +3 , c).Value = de.rows(r)(c)
        Sheet(r +3, c).Style = Style
        Sheet(0,c).Style = Style
        Sheet(1,c).Style = Style
        Sheet(2,c).Style = Style
    Next
Next
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()

没反应!图片点击可在新窗口打开查看


 回到顶部
帅哥,在线噢!
有点蓝
  22楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110334 积分:561518 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/15 21:33:00 [只看该作者]

上传实例说明

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/15 22:26:00 [只看该作者]

Dim de As Table = Tables("临时箱单")
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Dim styel1 As XLS.Style = Book.NewStyle() '定义新样式
styel1.font = New Font("微软雅黑", 16)
Dim styel2 As XLS.Style = Book.NewStyle() '定义新样式
styel2.font = New Font("微软雅黑", 12)
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
styel1.BorderTop = XLS.LineStyleEnum.Thin
styel1.BorderBottom = XLS.LineStyleEnum.Thin
styel1.BorderLeft = XLS.LineStyleEnum.Thin
styel1.BorderRight = XLS.LineStyleEnum.Thin
styel2.BorderTop = XLS.LineStyleEnum.Thin
styel2.BorderBottom = XLS.LineStyleEnum.Thin
styel2.BorderLeft = XLS.LineStyleEnum.Thin
styel2.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.Black
Style.BorderColorBottom = Color.Black
Style.BorderColorLeft = Color.Black
Style.BorderColorRight = Color.Black
styel1.BorderColorTop = Color.Black
styel1.BorderColorBottom = Color.Black
styel1.BorderColorLeft = Color.Black
styel1.BorderColorRight = Color.Black
styel2.BorderColorTop = Color.Black
styel2.BorderColorBottom = Color.Black
styel2.BorderColorLeft = Color.Black
styel2.BorderColorRight = Color.Black
Sheet.Rows(0).Height = 30 '设置第1行的行高
styel2.AlignHorz = XLS.AlignHorzEnum.Center
styel2.AlignVert = XLS.AlignVertEnum.Center
styel1.AlignHorz = XLS.AlignHorzEnum.Center
styel1.AlignVert = XLS.AlignVertEnum.Center
Style.AlignHorz = XLS.AlignHorzEnum.Center
Style.AlignVert = XLS.AlignVertEnum.Center
de.CreateSheetHeader(Sheet,1,0,False)'生成表头
Sheet(0,0).Value = "产品销售统计"
For r As Integer = 0 To de.Rows.Count - 1 '填入数据
    For c As Integer = 0 To de.Cols.Count -1
        Sheet.Cols(0).Width = 120
        Sheet.Cols(1).Width = 120
        Sheet.Cols(2).Width = 70
        Sheet.Cols(3).Width = 120
        For a As Integer = 4 To de.Cols.Count -3
            Sheet.Cols(a).Width = 30 '设置第1列的宽度
        Next
        For a As Integer = de.Cols.Count -2 To de.Cols.Count -1
            Sheet.Cols(a).Width = 50 '设置第1列的宽度
        Next
        Sheet(0,0).Style = styel1
        Sheet.MergeCell(0,0,1,c+1)
        Sheet(r +3 , c).Value = de.rows(r)(c)
        Sheet(r +3, c).Style = Style
        Sheet(0,c).Style = Style
        Sheet(1,c).Style = Style
        Sheet(2,c).Style = Style
        Sheet(1,c).Style = styel2
        Sheet(2,c).Style = styel2
        Dim Sum As Double = de.Compute("Sum(数量)")
        Dim Sum3 As Double = de.Compute("Sum(箱数)")
        Dim Sum1 As Integer
        Dim Sum2 As Integer
        sum1 = de.Cols.Count
        sum2 = de.Rows.Count
        Sheet(sum1+2, 0).Value = "合计:"
        Sheet(sum1+2, sum2).Value = sum
        Sheet(sum1+2, sum2-1).Value = sum3

    Next
Next
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()

怎么不计算?


 回到顶部
帅哥,在线噢!
有点蓝
  24楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110334 积分:561518 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/15 22:32:00 [只看该作者]

什么东西不计算?要计算什么

msgbox(sum)
msgbox(sum3)

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/15 22:36:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:qq拼音截图20190415223417.png
图片点击可在新窗口打开查看

 

计算合计箱数和合计数量

不知道为什么会为0


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/15 23:06:00 [只看该作者]

还有一个问题,如何设置行间距

styel1.LineSpacing = 50

这个好像不行


 回到顶部
帅哥,在线噢!
有点蓝
  27楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110334 积分:561518 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/15 23:09:00 [只看该作者]

红色代码放到最后的next后面。如果还不行,上传实例看看

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/15 23:25:00 [只看该作者]

Dim de As Table = Tables("临时箱单")
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
With Sheet.PrintSetting
    .AutoScale = True '自动缩放
    .FitPagesAcross = 1 '垂直方向缩为1页
End With
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Dim styel1 As XLS.Style = Book.NewStyle() '定义新样式
styel1.font = New Font("微软雅黑", 16)
Dim styel2 As XLS.Style = Book.NewStyle() '定义新样式
styel2.font = New Font("微软雅黑", 12)
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
styel1.BorderTop = XLS.LineStyleEnum.Thin
styel1.BorderBottom = XLS.LineStyleEnum.Thin
styel1.BorderLeft = XLS.LineStyleEnum.Thin
styel1.BorderRight = XLS.LineStyleEnum.Thin
styel2.BorderTop = XLS.LineStyleEnum.Thin
styel2.BorderBottom = XLS.LineStyleEnum.Thin
styel2.BorderLeft = XLS.LineStyleEnum.Thin
styel2.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.Black
Style.BorderColorBottom = Color.Black
Style.BorderColorLeft = Color.Black
Style.BorderColorRight = Color.Black
styel1.BorderColorTop = Color.Black
styel1.BorderColorBottom = Color.Black
styel1.BorderColorLeft = Color.Black
styel1.BorderColorRight = Color.Black
styel2.BorderColorTop = Color.Black
styel2.BorderColorBottom = Color.Black
styel2.BorderColorLeft = Color.Black
styel2.BorderColorRight = Color.Black
Sheet.Rows(0).Height = 70 '设置第1行的行高
styel1.WordWrap = True

styel1.LineSpacing = 50
styel2.AlignHorz = XLS.AlignHorzEnum.Center
styel2.AlignVert = XLS.AlignVertEnum.Center
styel1.AlignHorz = XLS.AlignHorzEnum.Center
styel1.AlignVert = XLS.AlignVertEnum.Center
Style.AlignHorz = XLS.AlignHorzEnum.Center
Style.AlignVert = XLS.AlignVertEnum.Center
de.CreateSheetHeader(Sheet,1,0,False)'生成表头
Sheet(0,0).Value = "产品销售统计" & vbcrlf & "箱单"
For r As Integer = 0 To de.Rows.Count - 1 '填入数据
    For c As Integer = 0 To de.Cols.Count -1
        Sheet.Cols(0).Width = 120
        Sheet.Cols(1).Width = 120
        Sheet.Cols(2).Width = 70
        Sheet.Cols(3).Width = 120
        For a As Integer = 4 To de.Cols.Count -3
            Sheet.Cols(a).Width = 30 '设置第1列的宽度
        Next
        For a As Integer = de.Cols.Count -2 To de.Cols.Count -1
            Sheet.Cols(a).Width = 60 '设置第1列的宽度
        Next
        Sheet(0,0).Style = styel1
        Sheet.MergeCell(0,0,1,c+1)
        Sheet(r +3 , c).Value = de.rows(r)(c)
        Sheet(r +3, c).Style = Style
        Sheet(0,c).Style = Style
        Sheet(1,c).Style = Style
        Sheet(2,c).Style = Style
        Sheet(1,c).Style = styel2
        Sheet(2,c).Style = styel2
        Dim Sum As Double= de.Compute("Sum(数量)")
        Dim Sum3 As Double = de.Compute("Sum(箱数)")
        Dim Sum1 As Integer
        Dim Sum2 As Integer
        sum1 = de.Cols.Count
        sum2 = de.Rows.Count
        Dim dtd As DataTable = DataTables("临时箱单")
        Dim dre = dtd.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
        For Each drf As DataRow In dre
            Sum = Sum + drf("数量")
            Sum3 = Sum3 + drf("箱数")
            Sheet(sum1+2, 0).Value = "合计:"
            Sheet(sum1+2, sum2).Value = sum
            Sheet(sum1+2, sum2-1).Value = sum3
        Next
    Next
Next

Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()

 

styel1.LineSpacing = 50 这个代码好像不对,行间距的代码有吗?

[此贴子已经被作者于2019/4/15 23:25:23编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/4/16 9:18:00 [只看该作者]

只有这些属性

 

AlignHorz
AlignVert
BackColor
BorderBottom
BorderColorBottom
BorderLeft
BorderColorLeft
BorderTop
BorderColorTop
BorderRight
BorderColorRight
Diagonal
DiagonalColor
DiagonalStyle
Font
FontName
FontSize
FontBold
FontItalic
FontStrikeout
FontUnderline
ForeColor
Format
Locked
Rotation
WordWrap

Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
For Each o As object In style.Gettype.getproperties
    output.show(o.name)
Next

 

如果你要设置额外的属性,请用vba处理,才行的

 

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

 


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/16 9:43:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:qq拼音截图20190415223417.png
图片点击可在新窗口打开查看

 


图片点击可在新窗口打开查看此主题相关图片如下:qq拼音截图20190416094040.png
图片点击可在新窗口打开查看

 


请问如何将上面2张图的规格排序

要求是XS,S,M,L,XLXXL...

 

Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim dt As DataTable = DataTables("箱单数据")
Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
Dim ggs = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'","_sortkey")
Dim dtb As New DataTableBuilder("临时箱单")
dtb.AddDef("合同号",Gettype(String),10)
dtb.AddDef("款号",Gettype(String),10)
dtb.AddDef("箱号",Gettype(String),10)
dtb.AddDef("颜色",Gettype(String),10)
For Each v As String In ggs
    dtb.AddDef(v , Gettype(Double), "", "规格_" & v)
Next
dtb.AddDef("箱数",Gettype(String),10)
dtb.AddDef("数量",Gettype(String),10)
dtb.Build()

Dim pdr As DataRow = Nothing
Dim xs As Double = 0
Dim xhs As String = ""
Dim sl As Double = 0
Dim pr As object = Nothing
For Each dr As DataRow In drs
    If pdr Is Nothing OrElse pdr("规格") <> dr("规格") OrElse pdr("颜色") <> dr("颜色") OrElse pdr("数量") <> dr("数量")Then
        If pr IsNot Nothing Then
            pr("合同号") = cj.Text
            pr("款号") = dm.Text
            pr("箱号") = xhs.trim("-")
            pr(pdr("规格")) = pdr("数量")
            pr("箱数") = xs
            pr("数量") = sl
            Dim arr() As String = pr("箱号").split("-")
            If arr.length > 2
                pr("箱号") = arr(0) & "-" & arr(arr.length - 1)
            End If
        End If
        Dim r As  DataRow = DataTables("临时箱单").AddNew()
        r("颜色") = dr("颜色")
        xhs = dr("箱号")
        xs = 1
        sl = dr("数量")
        pr = r
    Else
       
        xhs &= "-" & dr("箱号")
        xs += 1
        sl += dr("数量")
    End If
    pdr = dr
Next
If drs.count > 0
    Dim dr = drs(drs.count - 1)
    If pr IsNot Nothing Then
        pr("合同号") = cj.Text
        pr("款号") = dm.Text
        pr("箱号") = xhs.trim("-")
        pr(pdr("规格")) = dr("数量")
        pr("箱数") = xs
        pr("数量") = sl
    End If
End If
MainTable = Tables("临时箱单")
Dim de As Table = Tables("临时箱单")
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
With Sheet.PrintSetting
    .AutoScale = True '自动缩放
    .FitPagesAcross = 1 '垂直方向缩为1页
End With
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Dim styel1 As XLS.Style = Book.NewStyle() '定义新样式
styel1.font = New Font("微软雅黑", 16)
Dim styel2 As XLS.Style = Book.NewStyle() '定义新样式
styel2.font = New Font("微软雅黑", 12)
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
styel1.BorderTop = XLS.LineStyleEnum.Thin
styel1.BorderBottom = XLS.LineStyleEnum.Thin
styel1.BorderLeft = XLS.LineStyleEnum.Thin
styel1.BorderRight = XLS.LineStyleEnum.Thin
styel2.BorderTop = XLS.LineStyleEnum.Thin
styel2.BorderBottom = XLS.LineStyleEnum.Thin
styel2.BorderLeft = XLS.LineStyleEnum.Thin
styel2.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.Black
Style.BorderColorBottom = Color.Black
Style.BorderColorLeft = Color.Black
Style.BorderColorRight = Color.Black
styel1.BorderColorTop = Color.Black
styel1.BorderColorBottom = Color.Black
styel1.BorderColorLeft = Color.Black
styel1.BorderColorRight = Color.Black
styel2.BorderColorTop = Color.Black
styel2.BorderColorBottom = Color.Black
styel2.BorderColorLeft = Color.Black
styel2.BorderColorRight = Color.Black
Sheet.Rows(0).Height = 70 '设置第1行的行高
styel1.WordWrap = True
styel2.AlignHorz = XLS.AlignHorzEnum.Center
styel2.AlignVert = XLS.AlignVertEnum.Center
styel1.AlignHorz = XLS.AlignHorzEnum.Center
styel1.AlignVert = XLS.AlignVertEnum.Center
Style.AlignHorz = XLS.AlignHorzEnum.Center
Style.AlignVert = XLS.AlignVertEnum.Center
de.CreateSheetHeader(Sheet,1,0,True)'生成表头
Sheet(0,0).Value = "产品销售统计" & vbcrlf & "箱单"
For r As Integer = 0 To de.Rows.Count - 1 '填入数据
    For c As Integer = 0 To de.Cols.Count -1
        Sheet.Cols(0).Width = 120
        Sheet.Cols(1).Width = 120
        Sheet.Cols(2).Width = 70
        Sheet.Cols(3).Width = 120
        For a As Integer = 4 To de.Cols.Count -3
            Sheet.Cols(a).Width = 30 '设置第1列的宽度
        Next
        For a As Integer = de.Cols.Count -2 To de.Cols.Count -1
            Sheet.Cols(a).Width = 60 '设置第1列的宽度
        Next
        Sheet(0,0).Style = styel1
        Sheet.MergeCell(0,0,1,c+1)
        Sheet(r +3 , c).Value = de.rows(r)(c)
        Sheet(r +3, c).Style = Style
        Sheet(0,c).Style = Style
        Sheet(1,c).Style = Style
        Sheet(2,c).Style = Style
        Sheet(1,c).Style = styel2
        Sheet(2,c).Style = styel2
        Dim Sum As Double= de.Compute("Sum(数量)")
        Dim Sum3 As Double = de.Compute("Sum(箱数)")
        Dim Sum1 As Integer
        Dim Sum2 As Integer
        sum1 = de.Cols.Count
        sum2 = de.Rows.Count
        Dim dtd As DataTable = DataTables("临时箱单")
        Dim dre = dtd.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
        For Each drf As DataRow In dre
            Sum = Sum + drf("数量")
            Sum3 = Sum3 + drf("箱数")
            Sheet(sum1+2, 0).Value = "合计:"
            Sheet(sum1+2, sum2).Value = sum
            Sheet(sum1+2, sum2-1).Value = sum3
        Next
    Next
Next

Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()


 回到顶部
总数 43 上一页 1 2 3 4 5 下一页