本文整理汇总了PHP中PHPExcel::setCellValueByColumnAndRow方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel::setCellValueByColumnAndRow方法的具体用法?PHP PHPExcel::setCellValueByColumnAndRow怎么用?PHP PHPExcel::setCellValueByColumnAndRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel
的用法示例。
在下文中一共展示了PHPExcel::setCellValueByColumnAndRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ActionEffect
public function ActionEffect()
{
if (isset($_REQUEST['start_time']) && $_REQUEST['start_time']) {
$date_start = strtotime($_REQUEST['start_time']);
} else {
$prev = time() - 86400;
$date_start = mktime(0, 0, 0, date("n", $prev), date("j", $prev), date("Y", $prev));
$_REQUEST['start_time'] = date('Y-m-d H:i', $date_start);
}
if (isset($_REQUEST['end_time']) && $_REQUEST['end_time']) {
$date_end = strtotime($_REQUEST['end_time']);
} else {
$date_end = time();
$_REQUEST['end_time'] = date('Y-m-d H:i', $date_end);
}
// $db = Events::model()->getDbConnection();
// $c = Events::model()->getCompanyId();
$time_slice = $this->getSliceData($date_start, $date_end);
$event_fields = array(8 => 'wbrknum', 2 => 'sbrknum', 1 => 'tbrknum');
$skip_keys = array('name', 'max_ts', 'min_ts');
$stop_events = array(1, 4, 8);
$other_events = array(2);
$n = count($time_slice);
foreach ($time_slice as $k => $slice) {
//$slice = $time_slice[$i];
$stop_time = 0;
$other_time = 0;
$all_time = 0;
foreach ($slice as $key => $value) {
if (is_numeric($key)) {
//!in_array($key, $skip_keys)
if (in_array($key, $stop_events)) {
$stop_time += $value['time_len'];
}
if (in_array($key, $other_events)) {
$other_time += $value['time_len'];
}
$all_time += $value['time_len'];
if (isset($event_fields[$key])) {
}
}
}
//print_r($slice);
$time_slice[$k]['stop_times'] = $time_slice[$k]['wbrknum'] + $time_slice[$k]['sbrknum'] + $time_slice[$k]['tbrknum'] + $time_slice[$k]['obrknum'];
$time_slice[$k]['all_time0'] = $slice['max_ts'] - $slice['min_ts'];
$time_slice[$k]['all_time'] = $all_time;
$time_slice[$k]['stop_time'] = $stop_time;
$time_slice[$k]['other_time'] = $other_time;
if ($all_time > 0) {
$time_slice[$k]['efficiency'] = ($all_time - $stop_time) / $all_time;
}
}
/////////////////
if (false) {
$objPHPExcel = new PHPExcel();
// $objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
// $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
// $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
// $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
// $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->setActiveSheetIndex(0);
// $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Hello');
// $objPHPExcel->getActiveSheet()->SetCellValue('B2', 'world!');
// $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Hello');
// $objPHPExcel->getActiveSheet()->SetCellValue('D2', 'world!');
//setCellValueByColumnAndRow( [string $pColumn = 0], [string $pRow = 1], [mixed $pValue = null], [bool $returnCell = false])
$objPHPExcel->setCellValueByColumnAndRow(0, 1, '机台');
$objPHPExcel->setCellValueByColumnAndRow(1, 1, '运转效率');
$objPHPExcel->setCellValueByColumnAndRow(2, 1, '总停时间');
$objPHPExcel->setCellValueByColumnAndRow(3, 1, '总停次数');
$objPHPExcel->setCellValueByColumnAndRow(4, 1, '违停时间');
$objPHPExcel->setCellValueByColumnAndRow(5, 1, '违停次数');
$objPHPExcel->setCellValueByColumnAndRow(6, 1, '经停时间');
$objPHPExcel->setCellValueByColumnAndRow(7, 1, '经停次数');
$objPHPExcel->setCellValueByColumnAndRow(8, 1, '耳丝停时间');
$objPHPExcel->setCellValueByColumnAndRow(9, 1, '耳丝停次数');
$objPHPExcel->setCellValueByColumnAndRow(10, 1, '其他停时间');
$objPHPExcel->setCellValueByColumnAndRow(11, 1, '其他停次数');
$i = 1;
foreach ($time_slice as $k => $slice) {
$i++;
$objPHPExcel->setCellValueByColumnAndRow(0, 1, $slice['name']);
$f = '--';
if (isset($slice['efficiency'])) {
$f = sprintf("%.2f", $slice['efficiency'] * 100) . '%';
}
$objPHPExcel->setCellValueByColumnAndRow(1, $i, $f);
$objPHPExcel->setCellValueByColumnAndRow(2, $i, $slice['stop_time']);
$objPHPExcel->setCellValueByColumnAndRow(3, $i, $slice['stop_times']);
$objPHPExcel->setCellValueByColumnAndRow(4, $i, isset($slice[8]) ? $slice[8]['time_len'] : '--');
$objPHPExcel->setCellValueByColumnAndRow(5, $i, $slice['wbrknum']);
$objPHPExcel->setCellValueByColumnAndRow(6, $i, isset($slice[1]) ? $slice[1]['time_len'] : '--');
$objPHPExcel->setCellValueByColumnAndRow(7, $i, $slice['tbrknum']);
$objPHPExcel->setCellValueByColumnAndRow(8, $i, isset($slice[2]) ? $slice[2]['time_len'] : '--');
$objPHPExcel->setCellValueByColumnAndRow(9, $i, $slice['sbrknum']);
$objPHPExcel->setCellValueByColumnAndRow(10, $i, $slice['other_time']);
$objPHPExcel->setCellValueByColumnAndRow(11, $i, $slice['obrknum']);
}
$objPHPExcel->setCellValueByColumnAndRow(0, 1, '');
// $objPHPExcel->getActiveSheet()->setTitle('Simple');
//.........这里部分代码省略.........