我想打印月份中的几天,并突出显示MySQL表中日期与日期相同的日期。
表中有跑步的行(跑步的天数,距离,速度...),我想突出显示跑步的月份。
我的代码:
' For Dynamic data range named "PvtData"
ActiveWorkbook.Names.Add Name:="PvtData", RefersToR1C1:= _
"=OFFSET('Data'!R1C1,0,0,COUNTA('Data'!C1),COUNTA('Data'!R1))"
' For creating Pivot using Dynamic data range named "PvtData"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"PvtData").CreatePivotTable TableDestination:="", TableName:="PivotTable_UBD"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(7, 1)
ActiveSheet.Cells(7, 1).Select
ActiveSheet.PivotTables("PivotTable_UBD").SmallGrid = False
ActiveSheet.Name = "Utilization By Day"
此代码在一个月的所有日子(2018-06-01至2018-06-30)打印,但突出显示的只是一个日期。如何突出显示表格中的所有日期?例如,我的表格中有4行日期在2018-06-01和2018-06-30之间。
这是我的代码的输出:
' For Dynamic data range named "PvtData"
ActiveWorkbook.Names.Add Name:="PvtData", RefersToR1C1:= _
"=OFFSET('Data'!R1C1,0,0,COUNTA('Data'!C1),COUNTA('Data'!R1))"
' For creating Pivot using Dynamic data range named "PvtData"
Set PivotCache = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, _
SourceData:="PvtData")
Worksheets.Add
ActiveSheet.Name = "Utilization By Day"
ActiveWindow.DisplayGridlines = True
Set PivotTable = ActiveSheet.PivotTables.Add(PivotCache:=PivotCache, _
TableDestination:=Range("A1"), TableName:="PivotTable_UBD")
答案 0 :(得分:2)
尝试将所有数据库记录添加到数组:
$runs = array();
$select1cal = mysqli_query($conn, "SELECT * FROM runs WHERE user=$user AND dbmonth=$dbmonth ORDER BY date");
while ($data=mysqli_fetch_array($select1cal)) {
$dateid1=$data['date'];
$event1=date('Y-m-d', $dateid1);
array_push($runs, $event1);
}
然后整天循环播放,然后检查日期是否在数组中。
if (in_array($list, $runs)) {
$show="<p style=\"color:#0f0;\">$list</p>";
} else {
$show="<p>$list</p>
}