Foxtable(狐表)用户栏目专家坐堂 → 导出EXCL合并单元格


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

主题:导出EXCL合并单元格

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


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
导出EXCL合并单元格  发帖心情 Post By:2016/10/27 10:51:00 [只看该作者]

Dim dt As Table = Tables("后台统计_table2")
''dt.sort = "单位名称,考试名称,班级,折总 desc"
Dim nms() As String = {"考试名称","单位名称","年级代码","班级","参考人数","语文平均_A","语文平均_B","数学平均_A","数学平均_B","英语平均_A","英语平均_B","政治平均_A","政治平均_B","历史平均_A","历史平均_B","物理平均_A","物理平均_B","化学平均_A","化学平均_B","生物平均_A","生物平均_B","地理平均_A","地理平均_B","体育平均","物理实验","化学实验","总分平均","折总平均","班级排名"} 
Dim caps() As String = {"考试名称","单位名称","年级代码","班级","参考人数","语文A","语文B","数学A","数学B","英语A","英语B","政治A","政治B","历史A","历史B","物理A","物理B","化学A","化学B","生物A","生物B","地理A","地理B","体育","物理实验","化学实验","总分平均","折总平均","班级排名"}
'对应的列标题 
Dim szs() As Integer = {90,90,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,30} '对应的列宽 
Dim Book As New XLS.Book '定义一个Excel工作簿 
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表 
'Dim st As XLS.Style = Book.NewStyle '日期列的显示格式 
'st.Format = "yyyy-MM-dd" 
sheet(0,0).value ="班平统计表"
For c As Integer = 0 To nms.length -1 
    Sheet(1, c).Value = caps(c) '指定列标题
    Sheet.Cols(c).Width = szs(c) '指定列宽
    'If dt.Cols(nms(c)).IsDate Then '如果是日期列
    '    Sheet.Cols(c).Style = st '设置显示格式
   ' End If
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
    For c As Integer = 0 To nms.length -1
        Sheet(r +2, c).Value = dt.rows(r)(nms(c))
    Next
Next
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then
    Book.Save(dlg.FileName)
    Dim Proc As New Process
    Proc.File = dlg.FileName
    Proc.Start()
End If

老师请问导入的EXCL表的顶行sheet(0,0)到sheet(0,27)合并,并设置表标题"班平统计表"的字体和大小,怎么设置

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


加好友 发短信
等级:超级版主 帖子:110544 积分:562604 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/10/27 11:41:00 [只看该作者]


 回到顶部