以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]如何让符合条件的单元格变红加粗? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=67586) |
||||||||
-- 作者:cqlpjks -- 发布时间:2015/4/27 10:18:00 -- [求助]如何让符合条件的单元格变红加粗? 符合条件的整行变红加粗暂已搞定。如何让符合条件的单元格变红加粗?请指教。谢谢! 条件:If bb = "高理" Then dr1("语文") < c2 If bb = "高文" Then dr1("语文") < c2
例子:
统计结果为:
<!--StartFragment --> ![]() [此贴子已经被作者于2015/4/27 10:29:12编辑过]
|
||||||||
-- 作者:cqlpjks -- 发布时间:2015/4/27 10:31:00 -- 条件先写错了,应将“=”改成“<”。谢谢! |
||||||||
-- 作者:Bin -- 发布时间:2015/4/27 10:32:00 -- 比如 Dim t As Table = Tables("总分2015级二诊临界生名册") Dim ns2 As C1.Win.C1FlexGrid.CellStyle = t.grid.Styles.Add("自定义的样式2") ns2.ForeColor = Color.Red ns2.Font = New Font("宋体",9, FontStyle.Bold) For Each r As Row In t.Rows If r("语文")>90 Then t.Grid.SetCellStyle(r.Index+1, t.Cols("语文").Index+1, ns2) End If Next |
||||||||
-- 作者:y2287958 -- 发布时间:2015/4/27 11:11:00 -- mark |
||||||||
-- 作者:cqlpjks -- 发布时间:2015/4/27 15:57:00 -- 搞定。谢谢! Dim km1s() As String = {"语文","数学","英语","物理","化学","生物","政治","历史","地理"} |
||||||||
-- 作者:frind19881220 -- 发布时间:2015/4/27 16:01:00 -- 如何 通过代码断开 FTP连接?一直连接的话,占用的资源太多 |
||||||||
-- 作者:cqlpjks -- 发布时间:2019/5/3 16:58:00 -- 统计表导出时要想符合条件的单元格字体变红加粗(如上表“总分2015级二诊临界生名册”效果),下面代码有误,怎么修改?请指教。谢谢! Dim Kms() As String = {"总分"} Dim bbs() As String = {"高文","高理"} Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "Excel文件|*.xls" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 If e.Form.Controls("年级").value Is Nothing And e.Form.Controls("类别").value Is Nothing Then \'如果统计年级和类别存在 MessageBox.Show("请选择统计年级和类别再执行此操作","中止操作",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) Else Dim tjnj As String = e.Form.Controls("年级").text \'统计年级 Dim tjlb As String = e.Form.Controls("类别").text \'统计类别 For Each Km As String In Kms Dim dr As DataRow = DataTables("校名设置").Find("单位 = \'统计\'") Tables(Km & tjnj &"级"& tjlb &"重点线上下"& dr("专科B") &"分名册").SaveExcel(dlg.FileName, "重点线上下"& dr("专科B") &"分名册") \'保存文件 \'DataTables.Delete( Km & tjnj &"级"& tjlb &"重点线上下"& dr("专科B") &"分名册") \'删除原文件 Dim book As new XLS.Book(dlg.FileName) Dim sheet As XLS.Sheet = book.Sheets("重点线上下"& dr("专科B") &"分名册") \'工作表 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 = {"重庆市","梁平县"} Dim km1s() 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 For Each km1 As String In km1s \'低于有效分的字体变红,加粗 Dim t As Table = Tables(dlg.FileName) Dim ns2 As C1.Win.C1FlexGrid.CellStyle = t.grid.Styles.Add("自定义的样式2") ns2.ForeColor = Color.Red ns2.Font = New Font("宋体",9, FontStyle.Bold) For Each bb As String In bbs For Each r As Row In t.Rows If r("部别") = "高理" Then Dim lr As DataRow = DataTables(dlg.FileName).Find("单位 = \'重庆市\' And 部别 = \'高理\' And 年级 = \'" & tjnj & "\'And 类别 = \'" & tjlb & "\'") If r(km1) < lr(km1) Then t.Grid.SetCellStyle(r.Index+1, t.Cols(km1).Index+1, ns2) End If Else Dim wr As DataRow = DataTables(dlg.FileName).Find("单位 = \'重庆市\' And 部别 = \'高文\' And 年级 = \'" & tjnj & "\'And 类别 = \'" & tjlb & "\'") If r(km1) < wr(km1) Then t.Grid.SetCellStyle(r.Index+1, t.Cols(km1).Index+1, ns2) End If End If Next Next Next Next Book.Save(dlg.FileName) Next End If End If e.Form.Controls("Label1").Text = "临界生名册已导出并删除!" |
||||||||
-- 作者:有点甜 -- 发布时间:2019/5/4 9:58:00 --
请上传具体实例测试。
|