Foxtable(狐表)用户栏目专家坐堂 → 为什么 导出的数据不全


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

主题:为什么 导出的数据不全

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


加好友 发短信
等级:婴狐 帖子:87 积分:646 威望:0 精华:0 注册:2017/3/5 20:07:00
为什么 导出的数据不全  发帖心情 Post By:2018/5/2 11:51:00 [显示全部帖子]

库存明细表以前导出一直好好的 现在导出少了第一行

代码如下:

'If _dcbb = False Then
    'MessageBox.Show("对不起!您没有该权限,请联系管理员!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    'Return
'End If
If Tables("库存查询_Table1").Rows.Count = 0 Then
    MessageBox.Show("暂无任何数据,不能导出Excel!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    Return
End If
If e.form.Controls("TabControl1").SelectedPage.text = "商品库存" Then
If FileSys.FileExists(ProjectPath & "模板\库存清单.xls") = False Then
    Messagebox.Show("库存清单.xls模板不存在或已经被删除,导出失败!","错误提示",MessageBoxButtons.OK, MessageBoxIcon.Warning)
    Return
End If
Dim fl As String = ProjectPath & "excel\库存清单.xls"
If FileIsOpened(fl)= True Then
    MessageBox.Show("""库存清单.xls""文件正在打开中,请先关闭再执行导出操作!","温馨提示",MessageBoxButtons.OK, MessageBoxIcon.Warning)
    Return
End If
Dim flg As New SaveExcelFlags
Dim ts As String = e.Form.Controls("提示").text
Dim Book As New XLS.Book(ProjectPath & "模板\库存清单.xls") '打开模板
Dim Sheet As XLS.Sheet = Book.Sheets(0)
With Sheet.PrintSetting
    .PaperKind = 9
    .MarginLeft = 8
    .MarginRight = 5
    .MarginTop = 5
    .MarginBottom = 5
    .LandScape = False
End With
    Sheet(7,0).Value = "<库存查询_Table1>"
    Sheet(4,2).Value =  Date.Today
    Sheet(8,1).Value = "制单人:" & _yhm
Sheet(7,17).Value = "<Item is not null>"  '写入表名
 
Book.Save(fl)
e.Form.Controls("打印预览").Enabled = True
e.Form.Controls("直接打印").Enabled = True
If MessageBox.Show("导出完成,是否打开报表?", "完成提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = 1 Then
    Dim Proc As New Process
    Proc.File = fl
    Proc.Start()
End If
ElseIf e.form.Controls("TabControl1").SelectedPage.text = "库存明细" Then
Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "货品编号,货格"
For Each dr As DataRow In DataTables("商品库存明细").Select("", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("库存查询_table2").filter = "_Identify not in (" & idx.trim(",") & ")"
If FileSys.FileExists(ProjectPath & "模板\库存明细.xls") = False Then
        Messagebox.Show("库存明细Excel模板不存在或已经被删除,导出失败!","错误提示",MessageBoxButtons.OK, MessageBoxIcon.Warning)
        e.Form.Controls("打印预览").Enabled = False
        e.Form.Controls("打印预览").Enabled = False
        Return
    End If
    Dim Book As New XLS.Book(ProjectPath & "模板\库存明细.xls")
    Dim fl As String = ProjectPath & "excel\库存明细.xls"
    If FileIsOpened(fl)= True Then
        MessageBox.Show("""库存明细.xls""文件正在打开中,请先关闭再执行导出操作!")
        e.Form.Controls("打印预览").Enabled = False
        e.Form.Controls("打印预览").Enabled = False
        Return
    End If
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    With Sheet.PrintSetting
        .PaperKind = 9
        .MarginLeft = 12
        .MarginRight = 10
        .MarginTop = 5
        .MarginBottom = 5
        .LandScape = False
    End With
    Sheet(7,0).Value = "<库存查询_Table2>"
    Sheet(4,2).Value =  Date.Today
    Sheet(8,1).Value = "制单人:" & _yhm
Sheet(7,17).Value = "<货品编号 is not null>"
    Book.Build() '生成细节区
    Book.Save(fl) '保存工作簿
    e.Form.Controls("打印预览").Enabled = True
    e.Form.Controls("直接打印").Enabled = True
    If MessageBox.Show("导出完成,是否打开报表?", "完成提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = 1 Then
        Dim Proc As New Process '打开工作簿
        Proc.File = fl
        Proc.Start()
    End If
End If


 回到顶部