function create_result_xls($headline = '') { require_once "vendor/write_excel/OLEwriter.php"; require_once "vendor/write_excel/BIFFwriter.php"; require_once "vendor/write_excel/Worksheet.php"; require_once "vendor/write_excel/Workbook.php"; global $_fullname_sql, $SEM_TYPE, $SEM_CLASS, $TMP_PATH; if (!$headline) { $headline = _("Stud.IP Veranstaltungen") . ' - ' . $GLOBALS['UNI_NAME_CLEAN']; } if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) { if (!is_object($this->sem_tree)) { $the_tree = TreeAbstract::GetInstance("StudipSemTree", false); } else { $the_tree = $this->sem_tree->tree; } list($group_by_data, $sem_data) = $this->get_result(); $tmpfile = $TMP_PATH . '/' . md5(uniqid('write_excel', 1)); // Creating a workbook $workbook = new Workbook($tmpfile); $head_format = $workbook->addformat(); $head_format->set_size(12); $head_format->set_bold(); $head_format->set_align("left"); $head_format->set_align("vcenter"); $head_format_merged = $workbook->addformat(); $head_format_merged->set_size(12); $head_format_merged->set_bold(); $head_format_merged->set_align("left"); $head_format_merged->set_align("vcenter"); $head_format_merged->set_merge(); $head_format_merged->set_text_wrap(); $caption_format = $workbook->addformat(); $caption_format->set_size(10); $caption_format->set_align("left"); $caption_format->set_align("vcenter"); $caption_format->set_bold(); //$caption_format->set_text_wrap(); $data_format = $workbook->addformat(); $data_format->set_size(10); $data_format->set_align("left"); $data_format->set_align("vcenter"); $caption_format_merged = $workbook->addformat(); $caption_format_merged->set_size(10); $caption_format_merged->set_merge(); $caption_format_merged->set_align("left"); $caption_format_merged->set_align("vcenter"); $caption_format_merged->set_bold(); // Creating the first worksheet $worksheet1 = $workbook->addworksheet(_("Veranstaltungen")); $worksheet1->set_row(0, 20); $worksheet1->write_string(0, 0, $headline, $head_format); $worksheet1->set_row(1, 20); $worksheet1->write_string(1, 0, sprintf(_(" %s Veranstaltungen gefunden %s, Gruppierung: %s"), count($sem_data), $this->sem_browse_data['sset'] ? _("(Suchergebnis)") : "", $this->group_by_fields[$this->sem_browse_data['group_by']]['name']), $caption_format); $worksheet1->write_blank(0, 1, $head_format); $worksheet1->write_blank(0, 2, $head_format); $worksheet1->write_blank(0, 3, $head_format); $worksheet1->write_blank(1, 1, $head_format); $worksheet1->write_blank(1, 2, $head_format); $worksheet1->write_blank(1, 3, $head_format); $worksheet1->set_column(0, 0, 70); $worksheet1->set_column(0, 1, 25); $worksheet1->set_column(0, 2, 25); $worksheet1->set_column(0, 3, 50); $row = 2; foreach ($group_by_data as $group_field => $sem_ids) { switch ($this->sem_browse_data["group_by"]) { case 0: $headline = $this->search_obj->sem_dates[$group_field]['name']; break; case 1: if ($the_tree->tree_data[$group_field]) { $headline = $the_tree->getShortPath($group_field); } else { $headline = _("keine Studienbereiche eingetragen"); } break; case 3: $headline = $SEM_TYPE[$group_field]["name"] . " (" . $SEM_CLASS[$SEM_TYPE[$group_field]["class"]]["name"] . ")"; break; default: $headline = $group_field; break; } ++$row; $worksheet1->write_string($row, 0, $headline, $caption_format); $worksheet1->write_blank($row, 1, $caption_format); $worksheet1->write_blank($row, 2, $caption_format); $worksheet1->write_blank($row, 3, $caption_format); ++$row; if (is_array($sem_ids['Seminar_id'])) { while (list($seminar_id, ) = each($sem_ids['Seminar_id'])) { $sem_name = key($sem_data[$seminar_id]["Name"]); $seminar_number = key($sem_data[$seminar_id]['VeranstaltungsNummer']); $sem_number_start = key($sem_data[$seminar_id]["sem_number"]); $sem_number_end = key($sem_data[$seminar_id]["sem_number_end"]); if ($sem_number_start != $sem_number_end) { $sem_name .= " (" . $this->search_obj->sem_dates[$sem_number_start]['name'] . " - "; $sem_name .= ($sem_number_end == -1 ? _("unbegrenzt") : $this->search_obj->sem_dates[$sem_number_end]['name']) . ")"; } elseif ($this->sem_browse_data["group_by"]) { $sem_name .= " (" . $this->search_obj->sem_dates[$sem_number_start]['name'] . ")"; } //create Turnus field $seminar_obj = new Seminar($seminar_id); // is this sem a studygroup? $studygroup_mode = SeminarCategories::GetByTypeId($seminar_obj->getStatus())->studygroup_mode; if ($studygroup_mode) { $sem_name = $seminar_obj->getName() . ' (' . _("Studiengruppe"); if ($seminar_obj->admission_prelim) { $sem_name .= ', ' . _("Zutritt auf Anfrage"); } $sem_name .= ')'; } $worksheet1->write_string($row, 0, $sem_name, $data_format); $temp_turnus_string = $seminar_obj->getFormattedTurnus(true); //Shorten, if string too long (add link for details.php) if (strlen($temp_turnus_string) > 245) { $temp_turnus_string = substr($temp_turnus_string, 0, strpos(substr($temp_turnus_string, 245, strlen($temp_turnus_string)), ",") + 246); $temp_turnus_string .= " ... (" . _("mehr") . ")"; } $worksheet1->write_string($row, 1, $seminar_number, $data_format); $worksheet1->write_string($row, 2, $temp_turnus_string, $data_format); $doz_name = array(); $c = 0; reset($sem_data[$seminar_id]['fullname']); foreach ($sem_data[$seminar_id]['username'] as $anzahl1) { if ($c == 0) { list($d_name, $anzahl2) = each($sem_data[$seminar_id]['fullname']); $c = $anzahl2 / $anzahl1; $doz_name = array_merge($doz_name, array_fill(0, $c, $d_name)); } --$c; } $doz_position = array_keys($sem_data[$seminar_id]['position']); if (is_array($doz_name)) { if (count($doz_position) != count($doz_name)) { $doz_position = range(1, count($doz_name)); } array_multisort($doz_position, $doz_name); $worksheet1->write_string($row, 3, join(', ', $doz_name), $data_format); } ++$row; } } } $workbook->close(); } return $tmpfile; }