Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 每周添加一个空白栏_Php - Fatal编程技术网

Php 每周添加一个空白栏

Php 每周添加一个空白栏,php,Php,如何为每周添加空白列,如下图所示: 我有以下代码: while($j < $tout - 1) { echo $j." -> ".($j+6)."<br>"; $excel2->getActiveSheet()->mergeCells("A".$j.":A".($j+6)) ->setCellValue("A".$j, $o); $j += 7; $o++;

如何为每周添加空白列,如下图所示:

我有以下代码:

while($j < $tout - 1) {
   echo $j." -> ".($j+6)."<br>";
   $excel2->getActiveSheet()->mergeCells("A".$j.":A".($j+6))
                     ->setCellValue("A".$j, $o);   
   $j += 7; 
   $o++;                 
}
我希望每周我加上+1以得到空白列

例如,当我到达44->50时,下一个将是:

52 -> 58
...
希望你能理解我

提前谢谢。

试试这个

$i=0;
while($j < $tout - 1)
{
   $i++;
   if($i > 6) {
        $j += 1;
        $i = 0;
   }
   echo $j." -> ".($j+6)."<br>";
   $excel2->getActiveSheet()->mergeCells("A".$j.":A".($j+6))
                     ->setCellValue("A".$j, $o);   
   $j += 7; 
   $o++;
}
$i=0;
而($j<$tout-1)
{
$i++;
如果($i>6){
$j+=1;
$i=0;
}
回声$j.“->.”($j+6)。“
”; $excel2->getActiveSheet()->mergeCells(“A”。$j.:A”。($j+6)) ->setCellValue(“A”。$j,$o); $j+=7; $o++; }

希望这能奏效…

您可以再添加1个计数器变量(即,
$x
),并增加8个-

$x = $j; // initiate to start with $j
while($j < $tout - 1) {
   echo $j." -> ".($j+6)."<br>";
   echo "<br>"; // mimics $x in excel below
   $excel2->getActiveSheet()->mergeCells("A".$x.":A".($x+6))
                     ->setCellValue("A".$x, $o);   
   $j += 7; 
   $x += 8; // creates 1 blank after $j
   $o++;                 
}
$x=$j;//从$j开始
而($j<$tout-1){
回声$j.“->.”($j+6)。“
”; echo“
”;//在下面的excel中模拟$x $excel2->getActiveSheet()->mergeCells(“A”。$x.:A”。($x+6)) ->setCellValue(“A”。$x,$o); $j+=7; $x+=8;//在$j之后创建1个空格 $o++; }
工作得很有魅力,非常感谢:)这正是我需要的!接受,抱歉,我是新来的;)这个怎么做?对于($u=0;$u<$tout-1;$u++){$excel2->getActiveSheet()->setCellValue($B'$i,($i-1))->setCellValue($C'$i,en_francais($date($D',strotTime($dates[$u])->setCellValue($D'$i,$dates[$u]);$excel2->getActiveSheet()->getStyle($C'$i)->applyFromArray($styleArray);$excel2->getActiveSheet()->getStyle('A'.$i)->ApplyFlomarray($styleArray);$i++;}和我的答案一样,区别只是循环…`对于($u=0;$u<$tout-1;$u++){$i++;如果($i>6){$u+=1;$i=0;}}`我尝试过但没有结果,必须知道我这样定义:$i=2$j=9$o=2;但当我尝试你的代码时,我只得到了5列日期,原来只有140($tout-1):)
$x = $j; // initiate to start with $j
while($j < $tout - 1) {
   echo $j." -> ".($j+6)."<br>";
   echo "<br>"; // mimics $x in excel below
   $excel2->getActiveSheet()->mergeCells("A".$x.":A".($x+6))
                     ->setCellValue("A".$x, $o);   
   $j += 7; 
   $x += 8; // creates 1 blank after $j
   $o++;                 
}