Foxtable(狐表)用户栏目专家坐堂 → [求助]


  共有7795人关注过本帖平板打印复制链接

主题:[求助]

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


加好友 发短信
等级:三尾狐 帖子:645 积分:4583 威望:0 精华:0 注册:2012/11/12 14:27:00
[求助]  发帖心情 Post By:2013/2/21 16:03:00 [只看该作者]

想把表格(多头表格)导出后写入数据,然后再导入时出现问题,表头被导入,且数据没有被导人。

     导出代码:

 

Dim dcb As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim tbl As Table = Tables(""& dcb.text &"")
Dim hdr As Integer = tbl.HeaderRows '获得表头的层数
Dim cnt As Integer
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
tbl.CreateSheetHeader(Sheet) '生成表头
For c As Integer = 0 To tbl.Cols.Count - 1
    If tbl.Cols(c).Visible Then
        For r As Integer = 0 To tbl.Rows.Count - 1
            sheet(r + hdr,cnt).value = tbl(r,c)
        Next
        cnt = cnt + 1
    End If
Next
Book.Save("d:\记录表\test.xls")
Dim Proc As New Process
Proc.File = "d:\记录表\test.xls"
Proc.Start()

导入代码:Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls|2007Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    MessageBox.Show("你选择的是:" & dlg.FileName,"提示") '提示用户选择的文件
    Dim drb As WinForm.ComboBox = e.Form.Controls("ComboBox3")
    Dim sx1 As WinForm.ComboBox = e.Form.Controls("ComboBox5")
    Dim csxm1 As WinForm.ComboBox = e.Form.Controls("ComboBox7")
    DataTables(""& drb.text &"").DeleteFor("竞赛名称  like '*" & sx1.text & "*' And 参赛项目 like '*" & csxm1.text & "*'")
    Dim mg As New Merger
    mg.SourcePath = dlg.FileName
    mg.Format = "excel" '指定格式
    mg.SourceTableName = "sheet1$"
    mg.DataTableName = ""& drb.text &""
    mg.Merge()
End  If

 

请专家指教!

 


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