Foxtable(狐表)用户栏目专家坐堂 → 不知道错哪了?


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

主题:不知道错哪了?

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/19 22:42:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下:无法显示.jpg
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:无法显示2.jpg
图片点击可在新窗口打开查看

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/20 15:53:00 [显示全部帖子]

Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")


If cj.text <> Nothing AndAlso dm.text <> Nothing Then
    Dim dt As DataTable = DataTables("箱单数据")
    'Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    'Dim ggs = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    Dim gfc2  As List(Of String) = dt.GetValues("分仓信息", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
    Dim gfc3  As new List(Of String)
    For Each fc As String In dt.GetValues("分仓信息")
        If gfc2.Contains(fc) Then gfc3.Add(fc)
    Next
    Dim ggs() As String ={"XXXS","XXS","XS","S","M","L","XL","XXL","XXXL","F","60","65","70","75","80","85","90","95","100","105","110","115","120","125","130","135","140","145","150","155","160","165","170","175","180","185","190","195","200"}
    Dim ggs2  As List(Of String) = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
    Dim ggs3  As new List(Of String)
    For Each gg As String In ggs
        If ggs2.Contains(gg) Then ggs3.Add(gg)
    Next
    lvw.StopRedraw() '暂停绘制
    lvw.Groups.Clear() '清除原来的分组
    lvw.Columns.Clear() '清除原来的列
    lvw.Rows.Clear() '清除原来的行
    lvw.View = ViewMode.Details '显示模式为详细信息
    lvw.GridLines = True '显示网格线
    Dim cls() As String = {"颜色","箱号"} '定义列名
    Dim wds() As String = {80,50} '定义列宽
    For i As Integer = 0 To  cls.Length - 1  '增加列
        Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
        c.Text = cls(i) '指定列标题
        c.Name = cls(i) '指定列名
        c.Width = wds(i) '指定列宽
    Next
    For Each gg As String In ggs3
        Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
        c.Text = gg
        c.Name = gg
        c.Width = 30
    Next
    cls = new String() {"箱数","数量"} '定义列名
    wds = new String()  {40,40} '定义列宽
    For i As Integer = 0 To  cls.Length - 1  '增加列
        Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
        c.Text = cls(i) '指定列标题
        c.Name = cls(i) '指定列名
        c.Width = wds(i) '指定列宽
    Next
    '--------------------------分组--------------------------------------
    For Each zh As String In dt.GetValues("分仓信息", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'") '增加分组
        Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
        grp.Name = zh
        grp.Text = zh
    Next
    '--------------------------------------------------------------------
    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("箱号") = 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  WinForm.ListViewRow =  lvw.Rows.Add() '增加一行
            '----------------------分组----------------------------------
            r.Group = dr("分仓信息")
            '------------------------------------------------------------
            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("箱号") = xhs.trim("-")
            pr(pdr("规格")) = dr("数量")
            pr("箱数") = xs
            pr("数量") = sl
        End If
    End If
    lvw.ResumeRedraw
    Dim sll As WinForm.Label = e.Form.Controls("Label1")
    sll.Visible = True
    Dim Sum As Integer
    Dim Sum1 As Integer
    Dim Sum2 As Integer
    For Each dr As DataRow In drs
        Sum = Sum + dr("数量")
        sum1 = lvw.Columns.Count - 4
        sum2 = lvw.Rows.Count
    Next
    sll.text ="合计件数: "  & Sum &  " 件, 共 " & sum1 & " 列 " & sum2 & " 行"
End If

 

不知道怎么写了


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/20 17:12:00 [显示全部帖子]

Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")


If cj.text <> Nothing AndAlso dm.text <> Nothing Then
    Dim dt As DataTable = DataTables("箱单数据")
    'Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    'Dim ggs = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    Dim gfc2  As List(Of String) = dt.GetValues("分仓信息", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
    Dim gfc3  As new List(Of String)
Dim Products As New List(Of String)
Products = DataTables("箱单数据").GetValues("分仓信息","","_sortkey")
For ie As Integer = 0 To Products.Count -1
    Dim ggs() As String ={"XXXS","XXS","XS","S","M","L","XL","XXL","XXXL","F","60","65","70","75","80","85","90","95","100","105","110","115","120","125","130","135","140","145","150","155","160","165","170","175","180","185","190","195","200"}
    Dim ggs2  As List(Of String) = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'and 分仓信息 = '" & Products(ie) & "'")
    Dim ggs3  As new List(Of String)
    For Each gg As String In ggs
        If ggs2.Contains(gg) Then ggs3.Add(gg)
    Next

    lvw.StopRedraw() '暂停绘制
    lvw.Groups.Clear() '清除原来的分组
    lvw.Columns.Clear() '清除原来的列
    lvw.Rows.Clear() '清除原来的行
    lvw.View = ViewMode.Details '显示模式为详细信息
    lvw.GridLines = True '显示网格线
    Dim cls() As String = {"颜色","箱号"} '定义列名
    Dim wds() As String = {80,50} '定义列宽
    For i As Integer = 0 To  cls.Length - 1  '增加列
        Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
        c.Text = cls(i) '指定列标题
        c.Name = cls(i) '指定列名
        c.Width = wds(i) '指定列宽
    Next
    For Each gg As String In ggs3
        Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
        c.Text = gg
        c.Name = gg
        c.Width = 30
    Next
    cls = new String() {"箱数","数量"} '定义列名
    wds = new String()  {40,40} '定义列宽
    For i As Integer = 0 To  cls.Length - 1  '增加列
        Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
        c.Text = cls(i) '指定列标题
        c.Name = cls(i) '指定列名
        c.Width = wds(i) '指定列宽
    Next
Next
    '--------------------------分组--------------------------------------
    For Each zh As String In dt.GetValues("分仓信息", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'") '增加分组
        Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
        grp.Name = zh
        grp.Text = zh
    Next
    '--------------------------------------------------------------------
    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("箱号") = 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  WinForm.ListViewRow =  lvw.Rows.Add() '增加一行
            '----------------------分组----------------------------------
            r.Group = dr("分仓信息")
            '------------------------------------------------------------
            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("箱号") = xhs.trim("-")
            pr(pdr("规格")) = dr("数量")
            pr("箱数") = xs
            pr("数量") = sl
        End If
    End If
    lvw.ResumeRedraw
    Dim sll As WinForm.Label = e.Form.Controls("Label1")
    sll.Visible = True
    Dim Sum As Integer
    Dim Sum1 As Integer
    Dim Sum2 As Integer
    For Each dr As DataRow In drs
        Sum = Sum + dr("数量")
        sum1 = lvw.Columns.Count - 4
        sum2 = lvw.Rows.Count
    Next
    sll.text ="合计件数: "  & Sum &  " 件, 共 " & sum1 & " 列 " & sum2 & " 行"
End If

 

 

搞了老半天还是没搞出来


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/20 17:36:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下:wt12.jpg
图片点击可在新窗口打开查看

 

问题是没有了,但是箱号出问题了,4-6应该是单独显示4和6而不是显示4-6


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/20 17:37:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下:wt11.jpg
图片点击可在新窗口打开查看

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/20 19:53:00 [显示全部帖子]

Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")


If cj.text <> Nothing AndAlso dm.text <> Nothing Then
    Dim dt As DataTable = DataTables("箱单数据")
    'Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    'Dim ggs = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
    Dim gfc2  As List(Of String) = dt.GetValues("分仓信息", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
    Dim gfc3  As new List(Of String)
    Dim Products As New List(Of String)
    Products = DataTables("箱单数据").GetValues("分仓信息","","_sortkey")
    For ie As Integer = 0 To Products.Count -1
        Dim ggs() As String ={"XXXS","XXS","XS","S","M","L","XL","XXL","XXXL","F","60","65","70","75","80","85","90","95","100","105","110","115","120","125","130","135","140","145","150","155","160","165","170","175","180","185","190","195","200"}
        Dim ggs2  As List(Of String) = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
        Dim ggs3  As new List(Of String)
        For Each gg As String In ggs
            If ggs2.Contains(gg) Then ggs3.Add(gg)
        Next
        lvw.StopRedraw() '暂停绘制
        lvw.Groups.Clear() '清除原来的分组
        lvw.Columns.Clear() '清除原来的列
        lvw.Rows.Clear() '清除原来的行
        lvw.View = ViewMode.Details '显示模式为详细信息
        lvw.GridLines = True '显示网格线
        Dim cls() As String = {"颜色","箱号"} '定义列名
        Dim wds() As String = {80,50} '定义列宽
        For i As Integer = 0 To  cls.Length - 1  '增加列
            Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
            c.Text = cls(i) '指定列标题
            c.Name = cls(i) '指定列名
            c.Width = wds(i) '指定列宽
        Next
        For Each gg As String In ggs3
            Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
            c.Text = gg
            c.Name = gg
            c.Width = 30
        Next
        cls = new String() {"箱数","数量"} '定义列名
        wds = new String()  {40,40} '定义列宽
        For i As Integer = 0 To  cls.Length - 1  '增加列
            Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
            c.Text = cls(i) '指定列标题
            c.Name = cls(i) '指定列名
            c.Width = wds(i) '指定列宽
        Next
    Next
    '--------------------------分组--------------------------------------
    For Each zh As String In dt.GetValues("分仓信息", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'","_sortkey") '增加分组
        Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
        grp.Name = zh
        grp.Text = zh
    Next
    '--------------------------------------------------------------------
    For Each fc As String In Products
        Dim pdr As DataRow = Nothing
        Dim xs As Double = 0
        Dim xhs As String = ""
        Dim sl As Double = 0
        Dim pr As object = Nothing
        Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
        For Each dr As DataRow In dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%' and 分仓信息 = '" & fc & "'", "_sortkey")
            If pdr Is Nothing OrElse pdr("规格") <> dr("规格") OrElse pdr("颜色") <> dr("颜色") OrElse pdr("数量") <> dr("数量") OrElse pdr("分仓信息") <> grp.Text Then
                If pr IsNot Nothing Then
                    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  WinForm.ListViewRow =  lvw.Rows.Add() '增加一行
                '----------------------分组----------------------------------
                r.Group = fc
                '------------------------------------------------------------
                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("箱号") = xhs.trim("-")
                pr(pdr("规格")) = dr("数量")
                pr("箱数") = xs
                pr("数量") = sl
            End If
        End If
    Next
    lvw.ResumeRedraw
    Dim sll As WinForm.Label = e.Form.Controls("Label1")
    sll.Visible = True
    Dim Sum As Integer
    Dim Sum1 As Integer
    Dim Sum2 As Integer
    For Each dr As DataRow In drs
        Sum = Sum + dr("数量")
        sum1 = lvw.Columns.Count - 4
        sum2 = lvw.Rows.Count
    Next
    sll.text ="合计件数: "  & Sum &  " 件, 共 " & sum1 & " 列 " & sum2 & " 行"
End If

不知道,这样对不对?


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/20 20:57:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下:ggmm1.jpg
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:ggmm.jpg
图片点击可在新窗口打开查看

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:装箱系统.foxdb

请问用什么办法,把Excel的报表做出像ListView一样?


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/22 23:48:00 [显示全部帖子]

Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim dt As DataTable = DataTables("箱单数据")
'Dim ggs = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'","_sortkey")
Dim ggs() As String ={"XXXS","XXS","XS","S","M","L","XL","XXL","XXXL","F","60","65","70","75","80","85","90","95","100","105","110","115","120","125","130","135","140","145","150","155","160","165","170","175","180","185","190","195","200"}
Dim ggs2  As List(Of String) = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
Dim ggs3  As new List(Of String)
Dim Products As New List(Of String)
Products = DataTables("箱单数据").GetValues("分仓信息","","_sortkey")
For Each gg As String In ggs
    If ggs2.Contains(gg) Then ggs3.Add(gg)
Next
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)
dtb.AddDef("仓库",Gettype(String),10)
For Each v As String In ggs3
    dtb.AddDef(v , Gettype(Double), "", "规格_" & v)
Next
dtb.AddDef("箱数",Gettype(String),10)
dtb.AddDef("数量",Gettype(String),10)
dtb.Build()
For Each fc As String In Products
    Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'and 分仓信息 = '" & fc & "'", "_sortkey")
    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("数量") 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("颜色")
            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
Next
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,2,0,True)'生成表头
Sheet(0,0).Value = "产品销售统计" & vbcrlf & "箱单"

Dim dtd As DataTable = DataTables("临时箱单")
Dim idx As Integer = 0
For Each ck As String In dtd.GetValues("仓库")
    Dim Rows = dtd.Select("仓库='" & ck & "'")
    Sheet(idx+4,0).Value = "仓库: " & ck
    idx += 1
    For r As Integer = 0 To Rows.Count - 1 '填入数据
        For c As Integer = 0 To de.Cols.Count -1
            Sheet.Cols(0).Width = 100
            Sheet.Cols(1).Width = 100
            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.MergeCell(idx +3,0,1,c+1)
            If rows(r)(de.cols(c).name) = Nothing Then
                Sheet(r+idx+4 , c).Value = Nothing
            Else
                Sheet(r+idx+4 , c).Value = rows(r)(de.cols(c).name)
            End If

            Sheet(r+idx +4, c).Style = Style
            Sheet(0,c).Style = Style
            Sheet(2,c).Style = Style
            Sheet(3,c).Style = Style
            Sheet(2,c).Style = styel2
            Sheet(3,c).Style = styel2
        Next
    Next
    idx += Rows.Count
Next

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 = idx

Dim dre = dtd.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
For Each drf As DataRow In dre
    Sum = Sum + drf("数量")
    Sum3 = Sum3 + drf("箱数")
    Sheet(sum2+4, 0).Value = "合计:"
    Sheet(sum2+4, sum1-1).Value = sum
    Sheet(sum2+4, sum1-2).Value = sum3
Next

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

 

 


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

应该是4和6分开的不应该是4—6,这样会误认为是4,5,6

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


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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/22 23:49:00 [显示全部帖子]

请问怎么写这个代码?

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


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/4/23 17:53:00 [显示全部帖子]

图片点击可在新窗口打开查看不是这个ListView,是生成的临时表,怎么修改代码,使临时表里不会因为只有4和6,变成4—6,

 回到顶部
总数 20 1 2 下一页