以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]网格线问题。 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=161790) |
-- 作者:lpedu_jks -- 发布时间:2021/3/29 15:19:00 -- [求助]网格线问题。 生成统计报表时加网格线用下面代码: Tables("报表名").grid.styles.Normal.Border.Color = Color.Black \'网格线颜色(黑色Black红色Red粉红Pink天蓝DeepSkyBlue绿色SpringGreen) Tables("报表名").grid.styles.Normal.Border.Style = 1 \'单格线 Tables("报表名").grid.styles.Normal.Border.width = 1 \'网格线粗细 请问统计报表导出(Excel)时要加网格线 ,如何修改代码?请指教。谢谢! 变成: [此贴子已经被作者于2021/3/29 15:24:38编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/3/29 16:01:00 -- 方法1、设计模板导:http://www.foxtable.com/webhelp/topics/2877.htm 2、导出后使用代码设置:http://www.foxtable.com/webhelp/topics/1146.htm、http://www.foxtable.com/webhelp/topics/1163.htm
|
-- 作者:lpedu_jks -- 发布时间:2021/3/29 17:04:00 -- Dim Values() As String = {"总分"} Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "Excel文件|*.xls" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 For Each Value As String In Values If e.Form.Controls("年级").value Is Nothing Then MessageBox.Show("请选择或输入统计年级后再执行此操作","中止操作",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) Else Dim nj As String = e.Form.Controls("年级").text If Value <> "成绩库" And Value <> "校名设置" Then If DataTables.Contains(value & nj & "级目标") Then Tables(value & nj & "级目标").SaveExcel(dlg.FileName,value & nj & "级目标") \'保存文件 \'DataTables.Delete(value & nj & "级目标") \'删除原文件 End If End If Dim book As new XLS.Book(dlg.FileName) \'保存为Excel文件 Dim sheet As XLS.Sheet = book.Sheets(value & nj & "级目标") \'保存为Excel文件中的一个工作表 Dim Style As Xls.Style = book.NewStyle \'新建一个样式 Style.ForeColor = Color.Red \'样式的字体颜色设为红色 Style.Font = new font("宋体",9,FontStyle.Bold) \'宋体,9号,红色,加粗 Style.AlignHorz = XLS.AlignHorzEnum.Center \'居中 Style.AlignVert = XLS.AlignVertEnum.Center \'居中 For i As Integer = 0 To sheet.Rows.count -1 Dim Hjs() As String = {"全区合计","分数线"} For Each Hj As String In Hjs If sheet(i,0).Text.EndsWith(Hj) Then \'如果指定列(第1列)中含Hj字符存在(列位置) For n As Integer = 0 To sheet.Cols.count -1 sheet(i,n).Style = Style Next End If Next Next Style.BorderTop = XLS.LineStyleEnum.Thin Style.BorderBottom = XLS.LineStyleEnum.Thin Style.BorderLeft = XLS.LineStyleEnum.Thin Style.BorderRight = XLS.LineStyleEnum.Thin Style.BorderColorTop = Color.Black Style.BorderColorBottom = Color.Black Style.BorderColorLeft = Color.Black Style.BorderColorRight = Color.Black Book.Save(dlg.FileName) \'保存文件 End If Next e.Form.Controls("Label1").Text = "目标统计表已导出并删除!" End If 只是单位 = {"全区合计","分数线"}的行单元格加了网格线 [此贴子已经被作者于2021/3/29 17:07:52编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/3/29 17:43:00 -- 如果要整表添加边框,去掉这些限制 Dim Hjs() As String = {"全区合计","分数线"} For Each Hj As String In Hjs If sheet(i,0).Text.EndsWith(Hj) Then \'如果指定列(第1列)中含Hj字符存在(列位置) |
-- 作者:lpedu_jks -- 发布时间:2021/3/30 16:55:00 -- 去掉这些 Dim Hjs() As String = {"全区合计","分数线"} For Each Hj As String In Hjs If sheet(i,0).Text.EndsWith(Hj) Then \'如果指定列(第1列)中含Hj字符存在(列位置) 后整表的边框是加起了,但所有数据都变红加粗了。 如何修改代码?请指教。谢谢! [此贴子已经被作者于2021/3/30 16:57:07编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/3/30 17:10:00 -- Dim book As new XLS.Book(dlg.FileName) \'保存为Excel文件 Dim sheet As XLS.Sheet = book.Sheets(value & nj & "级目标") \'保存为Excel文件中的一个工作表 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.Black Style.BorderColorBottom = Color.Black Style.BorderColorLeft = Color.Black Style.BorderColorRight = Color.Black For i As Integer = 0 To sheet.Rows.count -1 For n As Integer = 0 To sheet.Cols.count -1 sheet(i,n).Style = Style Next Next Style = book.NewStyle Style.ForeColor = Color.Red \'样式的字体颜色设为红色 Style.Font = new font("宋体",9,FontStyle.Bold) \'宋体,9号,红色,加粗 Style.AlignHorz = XLS.AlignHorzEnum.Center \'居中 Style.AlignVert = XLS.AlignVertEnum.Center \'居中 For i As Integer = 0 To sheet.Rows.count -1 Dim Hjs() As String = {"全区合计","分数线"} For Each Hj As String In Hjs If sheet(i,0).Text.EndsWith(Hj) Then \'如果指定列(第1列)中含Hj字符存在(列位置) For n As Integer = 0 To sheet.Cols.count -1 sheet(i,n).Style = Style Next End If Next Next Book.Save(dlg.FileName) \'保存文件
|
-- 作者:lpedu_jks -- 发布时间:2021/3/30 18:22:00 -- 还是不得行。以变成这种了: |
-- 作者:有点蓝 -- 发布时间:2021/3/30 20:12:00 -- 红色字样式也加上边框 |
-- 作者:lpedu_jks -- 发布时间:2021/3/30 20:22:00 -- 是的。得行了。 Dim book As new XLS.Book(dlg.FileName) \'保存为Excel文件 Dim sheet As XLS.Sheet = book.Sheets(value & nj & "级目标") \'保存为Excel文件中的一个工作表 Dim Style As Xls.Style = book.NewStyle \'新建一个样式 Style.AlignHorz = XLS.AlignHorzEnum.Center \'居中 Style.AlignVert = XLS.AlignVertEnum.Center \'居中 Style.BorderTop = XLS.LineStyleEnum.Thin Style.BorderBottom = XLS.LineStyleEnum.Thin Style.BorderLeft = XLS.LineStyleEnum.Thin Style.BorderRight = XLS.LineStyleEnum.Thin Style.BorderColorTop = Color.Black Style.BorderColorBottom = Color.Black Style.BorderColorLeft = Color.Black Style.BorderColorRight = Color.Black For i As Integer = 0 To sheet.Rows.count -1 For n As Integer = 0 To sheet.Cols.count -1 sheet(i,n).Style = Style Next Next Style = book.NewStyle Style.ForeColor = Color.Red \'样式的字体颜色设为红色 Style.Font = new font("宋体",9,FontStyle.Bold) \'宋体,9号,红色,加粗 Style.AlignHorz = XLS.AlignHorzEnum.Center \'居中 Style.AlignVert = XLS.AlignVertEnum.Center \'居中 Style.BorderTop = XLS.LineStyleEnum.Thin Style.BorderBottom = XLS.LineStyleEnum.Thin Style.BorderLeft = XLS.LineStyleEnum.Thin Style.BorderRight = XLS.LineStyleEnum.Thin Style.BorderColorTop = Color.Black Style.BorderColorBottom = Color.Black Style.BorderColorLeft = Color.Black Style.BorderColorRight = Color.Black For i As Integer = 0 To sheet.Rows.count -1 Dim Hjs() As String = {"全区合计","分数线"} For Each Hj As String In Hjs If sheet(i,0).Text.EndsWith(Hj) Then \'如果指定列(第1列)中含Hj字符存在(列位置) For n As Integer = 0 To sheet.Cols.count -1 sheet(i,n).Style = Style Next End If Next Next Book.Save(dlg.FileName) \'保存文件 [此贴子已经被作者于2021/3/30 20:23:13编辑过]
|
-- 作者:lpedu_jks -- 发布时间:2021/5/8 10:34:00 -- 请教:导出表后表头不能自动换行,如何处理?请指教。谢谢! [此贴子已经被作者于2021/5/8 10:37:44编辑过]
|