Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
是可执行二次,但是你看到的结果仍是第二次的
Dim s1 as XLS.LineStyleEnum
Dim s2 as XLS.LineStyleEnum
Dim s3 as XLS.LineStyleEnum
Dim s4 as XLS.LineStyleEnum
Dim s5 as XLS.AlignHorzEnum
Dim s6 as XLS.AlignVertEnum
select case e.form.controls("Combobox1").value
case "无"
s1 = XLS.LineStyleEnum.None
case "粗线"
s1 = XLS.LineStyleEnum.Thick
case "细线"
s1 = XLS.LineStyleEnum.Thin
case "点线"
s1 = XLS.LineStyleEnum.Dotted
case "双实线"
s1 = XLS.LineStyleEnum.Double
case "虚线"
s1 = XLS.LineStyleEnum.Dashed
case "中等实线"
s1 = XLS.LineStyleEnum.Medium
case "中等的(短线+点+点)"
s1 = XLS.LineStyleEnum.ThinDashDotDotted
case "中等的(短线+点)"
s1 = XLS.LineStyleEnum.ThinDashDotted
case "中等虚线"
s1 = XLS.LineStyleEnum.MediumDashed
end select
select case e.form.controls("Combobox3").value
case "无"
s2 = XLS.LineStyleEnum.None
case "粗线"
s2 = XLS.LineStyleEnum.Thick
case "细线"
s2 = XLS.LineStyleEnum.Thin
case "点线"
s2 = XLS.LineStyleEnum.Dotted
case "双实线"
s2 = XLS.LineStyleEnum.Double
case "虚线"
s2 = XLS.LineStyleEnum.Dashed
case "中等实线"
s2 = XLS.LineStyleEnum.Medium
case "中等的(短线+点+点)"
s2 = XLS.LineStyleEnum.ThinDashDotDotted
case "中等的(短线+点)"
s2 = XLS.LineStyleEnum.ThinDashDotted
case "中等虚线"
s2 = XLS.LineStyleEnum.MediumDashed
end select
select case e.form.controls("Combobox4").value
case "无"
s3 = XLS.LineStyleEnum.None
case "粗线"
s3 = XLS.LineStyleEnum.Thick
case "细线"
s3 = XLS.LineStyleEnum.Thin
case "点线"
s3 = XLS.LineStyleEnum.Dotted
case "双实线"
s3 = XLS.LineStyleEnum.Double
case "虚线"
s3 = XLS.LineStyleEnum.Dashed
case "中等实线"
s3 = XLS.LineStyleEnum.Medium
case "中等的(短线+点+点)"
s3 = XLS.LineStyleEnum.ThinDashDotDotted
case "中等的(短线+点)"
s3 = XLS.LineStyleEnum.ThinDashDotted
case "中等虚线"
s3 = XLS.LineStyleEnum.MediumDashed
end select
select case e.form.controls("Combobox5").value
case "无"
s4 = XLS.LineStyleEnum.None
case "粗线"
s4 = XLS.LineStyleEnum.Thick
case "细线"
s4 = XLS.LineStyleEnum.Thin
case "点线"
s4 = XLS.LineStyleEnum.Dotted
case "双实线"
s4 = XLS.LineStyleEnum.Double
case "虚线"
s4 = XLS.LineStyleEnum.Dashed
case "中等实线"
s4 = XLS.LineStyleEnum.Medium
case "中等的(短线+点+点)"
s4 = XLS.LineStyleEnum.ThinDashDotDotted
case "中等的(短线+点)"
s4 = XLS.LineStyleEnum.ThinDashDotted
case "中等虚线"
s4 = XLS.LineStyleEnum.MediumDashed
end select
select case e.form.controls("Combobox6").value
case "居中"
s5 = XLS.AlignHorzEnum.Center
case "靠左"
s5 = XLS.AlignHorzEnum.Left
case "靠右"
s5 = XLS.AlignHorzEnum.Right
case "默认"
s5 = XLS.AlignHorzEnum.General
end select
select case e.form.controls("Combobox7").value
case "居中"
s6 = XLS.AlignVertEnum.Center
case "靠底"
s6 = XLS.AlignVertEnum.Bottom
case "靠上"
s6 = XLS.AlignVertEnum.Top
case "默认"
s6 = XLS.AlignVertEnum.Undefined
end select
Dim chk1 As WinForm.CheckBox
chk1 = e.form.Controls("CheckBox1")
Dim chk2 As WinForm.CheckBox
chk2 = e.form.Controls("CheckBox2")
Dim dlg As New SaveFileDialog '定一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
dim ss as string
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
ss = dlg.FileName
If FileSys.FileExists("& ss &") = true Then
FileSys.DeleteFile("& ss &",2,2) '则彻底删
End if
Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim Style As Xls.Style = Book.NewStyle '新建一个样式
Style.BorderTop = s1
Style.BorderBottom = s2
Style.BorderLeft = s3
Style.BorderRight = s4
Style.AlignHorz = s5
Style.AlignVert = s6
dim tt1 as integer = e.form.controls("NumericComboBox2").value
dim tt2 as string = e.form.controls("Combobox2").value
if chk1.checked then
Book.DefaultFont = New Font(tt2,tt1,FontStyle.Bold)
else
Book.DefaultFont = New Font(tt2,tt1)
end if
if chk2.checked then
style.wordwrap = true
else
style.wordwrap = false
end if
'Style.BackColor = Color.Red '样式的背景颜色设为红色
Dim lst As WinForm.CheckedListBox
lst = e.Form.Controls("CheckedListBox1")
Dim k As Integer = 0
Dim f as integer
For Each Index As Integer In lst.CheckedIndices
f = index + 1
dim gg as string = "Textbox" & f
Sheet(0, k).Value = lst.Items(Index)
Sheet(0, k).Style = Style
dim t as string
if e.form.controls(gg).value Is nothing or e.form.controls(gg).value <= 60 then
Sheet.Cols(k).Width = 80
else
Sheet.Cols(k).Width = e.form.controls(gg).value
end if
k = k + 1
Next
sheet.Rows(0).Height = 32
dim DataT as string = Vars("活动窗口1") & "_Table1"
Dim dt As Table = Tables(DataT)
Dim Multi As String = lst.value
Dim Values() as String
Values = Multi.split(",")
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
dim h as integer = 0
For Each Index2 As Integer In lst.CheckedIndices
dim name as string = lst.Items(Index2)
Sheet(r+1, h).Value = dt.rows(r)(name)
Sheet(r+1, h).Style = Style
h = h + 1
Next
sheet.Rows(r+1).Height = e.form.controls("NumericComboBox1").value
Next
'新增加的样式,目前怎样改下面的代码都无法实现。
Dim Style1 As XLS.Style = Book.NewStyle
Style1.Format = "yyyy-MM-dd"
For p1 as integer = 0 to Sheet.Cols.count -1
if Sheet(0, p).Value Like "*日期*" then
Sheet.Cols(p).Style = Style1
end if
Next
Book.Save(ss)
end if
Dim Style1 As XLS.Style = Book.NewStyle
Style1.Format = "yyyy-MM-dd"
For p1 as integer = 0 to Sheet.Cols.count -1
if Sheet(0, p).Value Like "*日期*" then
Sheet.Cols(p).Style = Style1
end if
Next
如果把Style.Format = "yyyy-MM-dd" 放在第一个样式就可以,为什么先执行样式1再设置样式2时,样式2不起效果呢?请老大指点呀,谢谢!!
估计你的Excel数据还没有生成之前, if Sheet(0, p).Value Like "*日期*" then 这个条件永远都不会成立的!~