以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 导出EXCL合并单元格 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=92142) |
-- 作者:刘林 -- 发布时间:2016/10/27 10:51:00 -- 导出EXCL合并单元格 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)合并,并设置表标题"班平统计表"的字体和大小,怎么设置
|
-- 作者:有点蓝 -- 发布时间:2016/10/27 11:41:00 -- 参考:http://www.foxtable.com/webhelp/scr/1153.htm |