Location: PHPKode > projects > Opensheet > opensheet/functions/export.xls.dm.projects.php
<?php
#Add sessions
# Add overtime
session_start();
if (isset($_GET['start'])  && isset($_GET['finish']) && isset($_GET['type'])) {
$user_index = $_SESSION['id'];
	
$start = $_GET['start'];
$finish = $_GET['finish'];
$type = $_GET['type'];

require_once 'Spreadsheet/Excel/Writer.php';
include ('base.functions.php');
include ('../classes/global.class.php');

#echo "<pre>";


#echo $user_index;
#echo $start;
#echo $finish;
#echo $type;



$filename = 'export.xls';
// Creating workbook
$workbook = new Spreadsheet_Excel_Writer();
// Setting workbook version 8
$workbook->setVersion(8);
// Sending headers to browser
$workbook->send('export.xls');
// Adding worksheet

$worksheet =& $workbook->addWorksheet('company');
$format_right =& $workbook->addFormat();
$format_right->setAlign('right');
$format_center =& $workbook->addFormat();
$format_center->setAlign('center');
$format_left =& $workbook->addFormat();
$format_left->setAlign('left');
// Setting worksheet encoding to UTF-8
$worksheet->setInputEncoding('UTF-8');
$worksheet->setColumn(0,1,40);
$worksheet->setColumn(2,2,10);
$worksheet->setColumn(3,3,20);
$worksheet->setColumn(4,6,40);
// Data input
// Header of a tables

$worksheet->write(0, 0, gettext('User name'),$format_center);
$worksheet->write(0, 1, gettext('project_name'),$format_center);
$worksheet->write(0, 2, gettext('hours'),$format_center);
$worksheet->write(0, 3, gettext('project_index'),$format_center);
$worksheet->write(0, 4, gettext('project_owner'),$format_center);
$worksheet->write(0, 5, gettext('proj_type'),$format_center);
$worksheet->write(0, 6, gettext('user_group'),$format_center);


$hours = new Stats;
$user  =   new Users;
$project = new Projects;
$groups =   new Groups;	
$s=1;

foreach($groups->getOwnersGroup($user_index) as $vars){
	foreach ($groups->getGroupUsers($vars['id']) as $num=>$value){
		foreach($hours->getPrjHoursPerDayByUser($start,$finish,'All',$value['id']) as $uid=>$value){
			foreach($value as $pid=>$data){
				$proj_type = array_keys($data);
				
			$worksheet->write($s, 0, $user->getRealName($uid));
			$worksheet->write($s, 1, $project->getProjectName($pid));
			$worksheet->write($s, 2, $data[$proj_type['0']]);
			$worksheet->write($s, 3, $project->getProjectIndex($pid),$format_center);
			$worksheet->write($s, 4, $project->getProjOwner($pid),$format_center);
			$worksheet->write($s, 5, $proj_type['0'],$format_center);
			$worksheet->write($s, 6, $user->getUserGroup($uid),$format_center);
				
				
		
						
					$s++;	
			}
		}
	}
}









// Sending the file
header("Content-Disposition: attachment; filename=export.xls");
header("Content-Type: application/octet-stream");
header("Content-Length: размер файла");
$workbook->close();
}
?>
Return current item: Opensheet