顯示數據我有以下代碼:獲取下週日的日期(跳過週末)在HTML
Public Shared Function DPLoadData() As String
Dim s As StringBuilder = New StringBuilder("<head><meta http-equiv=""content-type"" content=""text/html;charset=utf-8"" /><META HTTP-EQUIV=""REFRESH"" CONTENT=""900"">")
s.Append("<style type=""text/css"" media=""all""> body{font-family: Arial;}h4{font-size: 10pt;font-weight: bold;white-space: nowrap;margin-top: 0; margin-bottom: 10px;}")
s.Append("th{font-size: 9pt;font-weight: normal;text-align: center;white-space: nowrap;}td{font-size: 9pt;}.content td{border: solid 1px #dadada;}")
s.Append(".content th {border: solid 1px #dadada;background-image: url(""tbl_header_row_bg.gif""); background-repeat: repeat-x; white-space: nowrap;}</style></head>")
s.Append("<h3>" & "Daily Plan" & "</h3>")
Dim strCurrDay As String = ""
s.Append("<h5>" & strCurrDay & "</h5>")
Dim CurrDateFirstDay As Date = DateAdd(DateInterval.Day, 1, Now)
strCurrDay = FormatDateTime(CurrDateFirstDay, DateFormat.LongDate)
s.Append("<h5>" & strCurrDay & "</h5>")
s.Append(LoadDataGroupByDate(CurrDateFirstDay))
Return s.ToString()
End Function
功能生成一個HTML文件,表格,並幫您填充它。目前,HTML文件顯示明天的預訂(例如,如果今天是星期一,則顯示星期二的預訂)。到現在爲止還挺好。我想要的是,如果今天是星期五,HTML文件應該顯示星期一的預訂,而不是星期六。那可能嗎?
我的解決方案:
If value.DayOfWeek = DayOfWeek.Friday Then
Dim CurrDateFirstDay As Date = DateAdd(DateInterval.Day, 3, Now)
strCurrDay = FormatDateTime(CurrDateFirstDay, DateFormat.LongDate)
s.Append("<h5>" & strCurrDay & "</h5>")
s.Append(LoadDataGroupByDate(CurrDateFirstDay))
Else
Dim CurrDateFirstDay As Date = DateAdd(DateInterval.Day, 1, Now)
strCurrDay = FormatDateTime(CurrDateFirstDay, DateFormat.LongDate)
s.Append("<h5>" & strCurrDay & "</h5>")
s.Append(LoadDataGroupByDate(CurrDateFirstDay))
End If
我刪除了你的第二個問題有關如何在每天下午5點自動生成文件。這是一個完全獨立的問題,所以你應該單獨提問,而不是將兩者合併爲一個帖子。 –
好的,我會單獨提問。謝謝 – Paks