以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何给导出的excel表设设置字段 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=128114) |
-- 作者:lihe60 -- 发布时间:2018/11/29 9:24:00 -- 如何给导出的excel表设设置字段 Dim tbl As Table = Args(0) 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 If tbl(r,c)<>Nothing sheet(r + hdr,cnt).value = tbl(r,c) End If Next cnt = cnt + 1 End If Next Book.Save("c:\\reports\\test.xls") Dim Proc As New Process Proc.File = "c:\\reports\\test.xls" Proc.Start()
[此贴子已经被作者于2018/11/29 9:32:00编辑过]
|
-- 作者:有点甜 -- 发布时间:2018/11/29 9:45:00 -- 1、你可以先对table的列进行隐藏或者显示,再导出。
2、或者参考 http://www.foxtable.com/webhelp/scr/1148.htm
|
-- 作者:lihe60 -- 发布时间:2018/11/29 18:40:00 -- 使用一楼的代码,让导出的表头居中,如何写代码? [此贴子已经被作者于2018/11/29 18:44:00编辑过]
|
-- 作者:有点甜 -- 发布时间:2018/11/29 19:26:00 -- 以下是引用lihe60在2018/11/29 18:40:00的发言:
使用一楼的代码,让导出的表头居中,如何写代码? [此贴子已经被作者于2018/11/29 18:44:00编辑过]
本来就是默认居中的。 |
-- 作者:lihe60 -- 发布时间:2018/11/29 20:18:00 -- Dim tbl As Table = Args(0) Dim hdr As Integer = tbl.HeaderRows \'获得表头的层数 Dim cnt As Integer Dim Book As New XLS.Book Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim Style As XLS.Style = Book.NewStyle() \'定义新样式 Style.BorderTop = XLS.LineStyleEnum.Thin Style.BorderBottom = XLS.LineStyleEnum.Thin Style.BorderLeft = XLS.LineStyleEnum.Thin Style.BorderRight = XLS.LineStyleEnum.Thin Style.BorderColorTop = Color.Red Style.BorderColorBottom = Color.Red Style.BorderColorLeft = Color.Red Style.BorderColorRight = Color.Red Dim St2 As XLS.Style = Book.NewStyle() \'定义新样式 St2.BorderTop = XLS.LineStyleEnum.Thin St2.BorderBottom = XLS.LineStyleEnum.Thin St2.BorderLeft = XLS.LineStyleEnum.Thin St2.BorderRight = XLS.LineStyleEnum.Thin St2.BorderColorTop = Color.Red St2.BorderColorBottom = Color.Red St2.BorderColorLeft = Color.Red St2.BorderColorRight = Color.Red St2.Format = "yyyy-MM-dd" tbl.CreateSheetHeader(Sheet) \'生成表头 Dim c As Integer =0 For Each c1 As Col In tbl.cols If c1.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 c=c+1 Next c=0 For Each c1 As Col In tbl.cols If c1.visible=True Sheet(0, c).style = style c=c+1 End If Next For r As Integer = hdr-1 To tbl.Rows.Count+hdr - 1 \'填入数据 c =0 For Each c1 As Col In tbl.cols If c1.visible=True Sheet(r, c).style = style If tbl.cols(c).Isdate If r<>tbl.Rows.count+hdr-1 Sheet(r,c).Style = st2 Else Sheet(r,c).Value = Nothing End If End If c=c+1 End If Next Next Book.Save("c:\\reports\\test.xls") Dim Proc As New Process Proc.File = "c:\\reports\\test.xls" Proc.Start() “合同”两个字没有居中 [此贴子已经被作者于2018/11/29 20:18:26编辑过]
|
-- 作者:有点甜 -- 发布时间:2018/11/29 20:59:00 -- Dim tbl As Table = CurrentTable Dim Sty As xls.style = book.NewStyle
tbl.CreateSheetHeader(Sheet) \'生成表头
|
-- 作者:lihe60 -- 发布时间:2018/11/30 20:29:00 -- 如何设置字体及大小? [此贴子已经被作者于2018/11/30 20:42:30编辑过]
|
-- 作者:有点蓝 -- 发布时间:2018/11/30 20:47:00 -- http://www.foxtable.com/webhelp/scr/1165.htm |
-- 作者:lihe60 -- 发布时间:2018/12/1 10:39:00 -- sty.F 这样提示错误
|
-- 作者:有点蓝 -- 发布时间:2018/12/1 11:11:00 -- http://www.foxtable.com/webhelp/scr/0494.htm style.font = New Font("宋体",12,FontStyle.Bold or FontStyle.Underline) |