本文整理汇总了PHP中Spreadsheet_Excel_Writer::setVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Spreadsheet_Excel_Writer::setVersion方法的具体用法?PHP Spreadsheet_Excel_Writer::setVersion怎么用?PHP Spreadsheet_Excel_Writer::setVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spreadsheet_Excel_Writer
的用法示例。
在下文中一共展示了Spreadsheet_Excel_Writer::setVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function Pman_Core_SimpleExcel($data, $cfg)
{
// print_r($cfg);exit;
require_once 'Spreadsheet/Excel/Writer.php';
// Creating a workbook
$outfile2 = $this->tempName('xls');
// var_dump($outfile2);
$workbook = new Spreadsheet_Excel_Writer($outfile2);
//$workbook = new Spreadsheet_Excel_Writer();
$workbook->setVersion(8);
// sending HTTP headers
$this->workbook = $workbook;
$formats = array();
$cfg['formats'] = isset($cfg['formats']) ? $cfg['formats'] : array();
foreach ($cfg['formats'] as $f => $fcfg) {
$this->formats[$f] =& $workbook->addFormat();
foreach ((array) $fcfg as $k => $v) {
$this->formats[$f]->{'set' . $k}($v);
}
}
if (!empty($cfg['workbook'])) {
$this->buildPage(array(), $data, $cfg);
} elseif (!empty($cfg['workbooks'])) {
foreach ($cfg['workbooks'] as $i => $wcfg) {
$this->buildPage(array(), $data[$i], $wcfg);
}
}
// if workbooks == false - > the user can call buildpage..
if (!empty($cfg['leave_open'])) {
$this->outfile2 = $outfile2;
return;
}
$workbook->close();
$this->outfile2 = $outfile2;
}
示例2: xls
/**
* создает файл в формате XLS (Microsoft Excel) на основе переданных данных
*
* @param array $data содержимое ячеек таблицы
* @param string $name имя отчета
* @return string содержимое файла
*/
public function xls(&$data, $name)
{
$fileName = date("Y-m-d_H-i-s");
$workBook = new Spreadsheet_Excel_Writer();
$workBook->setTempDir(BASEPATH . 'cache/');
$workBook->setVersion(8);
$workBook->send(__("report") . "_{$fileName}.xls");
$formatBold =& $workBook->addFormat();
$formatBold->setBold();
$formatTitle =& $workBook->addFormat();
$formatTitle->setBold();
$formatTitle->setColor('black');
$formatTitle->setPattern(1);
$formatTitle->setFgColor('gray');
$formatTitle->setAlign('merge');
$workSheet =& $workBook->addWorksheet('Report');
$workSheet->setInputEncoding('utf-8');
$row_count = 0;
foreach ($data as $row) {
$col_count = 0;
foreach ($row as $column) {
$workSheet->write($row_count, $col_count, $column, $row_count ? $formatBold : $formatTitle);
$col_count++;
}
$row_count++;
}
// ширина столбцов
// $workSheet->setColumn(0, 0, 30);
// $workSheet->setColumn(2, 2, 30);
$workBook->close();
}
示例3: export_xls
private function export_xls($fileName = null, $data = null, $fields = array())
{
$fileName = 'fengjie';
$data = array(array(1, 1, 1), array(1, 1, 1));
$this->layout = 'ajax';
$this->autoLayout = false;
// return;
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$workbook->send($fileName . '.xls');
$workbook->setVersion(8);
$worksheet =& $workbook->addWorksheet('My first worksheet');
$worksheet->setInputEncoding('UTF-8');
$j = 0;
foreach ($fields as $field) {
$worksheet->write(0, $j, $field);
}
$i = 1;
foreach ($data as $row) {
$j = 0;
foreach ($row as $value) {
$worksheet->write($i, $j, $value);
$j++;
}
$i++;
}
$workbook->close();
}
示例4: post
function post($fname)
{
$ml = (int) ini_get('suhosin.post.max_value_length');
if (empty($_POST['_json'])) {
header("HTTP/1.0 400 Internal Server Error");
die($ml ? "Suhosin Patch enabled - try and disable it!!!" : 'no JSON sent');
}
if (empty($_POST['_json'])) {
header("HTTP/1.0 400 Internal Server Error");
die("Missing json attribute");
}
$json = json_decode($_POST['_json']);
require_once 'Spreadsheet/Excel/Writer.php';
// Creating a workbook
$outfile2 = $this->tempName('xls');
// var_dump($outfile2);
$workbook = new Spreadsheet_Excel_Writer($outfile2);
//$workbook = new Spreadsheet_Excel_Writer();
$workbook->setVersion(8);
// sending HTTP headers
$worksheet = $workbook->addWorksheet("Sheet 1");
if (is_a($worksheet, 'PEAR_Error')) {
die($worksheet->toString());
}
//print_R($worksheet);
$worksheet->setInputEncoding('UTF-8');
for ($r = 0; $r < count($json); $r++) {
$row = $json[$r];
for ($c = 0; $c < count($row); $c++) {
$worksheet->write($r, $c, $row[$c]);
}
}
$workbook->close();
require_once 'File/Convert.php';
$fc = new File_Convert($outfile2, "application/vnd.ms-excel");
$fn = $fc->convert("application/vnd.ms-excel");
$fc->serve('attachment', 'excel-' . date('Y-m-d-H-i-s') . '.xls');
// can fix IE Mess
unlink($outfile2);
}
示例5: column
get_lang('TotalTimeSpentInTheCourse'),
get_lang('AverageTimePerStudentInCourse'),
get_lang('NumberOfDocumentsInLearnpath'),
get_lang('NumberOfExercisesInLearnpath'),
get_lang('NumberOfLinksInLearnpath'),
get_lang('NumberOfForumsInLearnpath'),
get_lang('NumberOfAssignmentsInLearnpath'),
get_lang('NumberOfAnnouncementsInCourse'),
);
if (isset($_GET['export'])) {
global $charset;
$workbook = new Spreadsheet_Excel_Writer();
$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->send($filename);
$workbook->setVersion(8); // BIFF8
$worksheet =& $workbook->addWorksheet('Report');
//$worksheet->setInputEncoding(api_get_system_encoding());
$worksheet->setInputEncoding($charset);
$line = 0;
$column = 0; //skip the first column (row titles)
foreach($headers as $header) {
$worksheet->write($line,$column, $header);
$column++;
}
$line++;
foreach ($array as $row) {
$column = 0;
foreach ($row as $item) {
示例6: export_complete_report_xls
function export_complete_report_xls($filename, $array)
{
global $charset;
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->send($filename);
$workbook->setVersion(8);
// BIFF8
$worksheet =& $workbook->addWorksheet('Report');
//$worksheet->setInputEncoding(api_get_system_encoding());
$worksheet->setInputEncoding($charset);
/*
$line = 0;
$column = 1; // Skip the first column (row titles)
foreach ($array as $elem) {
$worksheet->write($line, $column, $elem);
$column++;
}
$workbook->close();*/
exit;
}
示例7: exportToXls
public static function exportToXls($data, $file = false, $alignments = array())
{
require_once 'Spreadsheet/Excel/Writer.php';
$workBook = new Spreadsheet_Excel_Writer($file);
$workBook->setTempDir(G_UPLOADPATH);
$workBook->setVersion(8);
$workSheet =& $workBook->addWorksheet('info');
$workSheet->setInputEncoding('utf-8');
$columnIndex = 0;
foreach (current($data) as $key => $value) {
$maxColumnWidths[$columnIndex][] = mb_strlen($key);
$alignments[$columnIndex] ? $align = $alignments[$columnIndex] : ($align = 'left');
$workSheet->write(0, $columnIndex++, $key, $workBook->addFormat(array('HAlign' => $align, 'Size' => 11, 'Bold' => 1)));
}
$rowIndex = 1;
foreach ($data as $rowData) {
$columnIndex = 0;
foreach ($rowData as $cell) {
$maxColumnWidths[$columnIndex][] = mb_strlen($cell);
if ($alignments[$columnIndex]) {
$align = $alignments[$columnIndex];
$workSheet->write($rowIndex, $columnIndex++, $cell, $workBook->addFormat(array('HAlign' => $align)));
} else {
$workSheet->write($rowIndex, $columnIndex++, $cell);
}
}
$rowIndex++;
}
foreach ($maxColumnWidths as $columnIndex => $widths) {
$workSheet->setColumn($columnIndex, $columnIndex, max($widths) + 2);
}
$workBook->close();
if (!$file) {
$workBook->send('export.xls');
}
}
示例8: _xls
private static function _xls()
{
$t = $GLOBALS["t"];
require "lib/spreadsheet/Writer.php";
$xls = new Spreadsheet_Excel_Writer();
$xls->setTempDir(SIMPLE_CACHE . "/output/");
$xls->setVersion(8);
$sheet = $xls->addWorksheet($t["title"]);
$sheet->setInputEncoding('utf-8');
$sheet->freezePanes(array(1, 0, 1, 0));
$bold = $xls->addFormat();
$bold->setBold();
$normal = $xls->addFormat();
$normal->setVAlign("top");
$normal->setTextWrap();
$data = self::_build_data(true);
$row = 0;
$col = 0;
if (count($data) > 0) {
$col = 0;
$sheet->setColumn(0, count($data[0]) - 1, 15);
foreach ($data[0] as $field) {
if (empty($field["name"])) {
continue;
}
$sheet->write($row, $col++, $field["displayname"], $bold);
}
$row++;
foreach ($data as $asset) {
$col = 0;
foreach ($asset as $aval) {
if (!isset($aval["filter"])) {
continue;
}
$sheet->write($row, $col++, trim(strip_tags($aval["filter"])), $normal);
}
$row++;
}
} else {
$header = self::_build_fields();
$col = 0;
$sheet->setColumn(0, count($header) - 1, 15);
foreach ($header as $field) {
$sheet->write($row, $col++, $field, $bold);
}
}
$xls->close();
}
示例9: count
/**
* Quite similar to display_complete_report(), returns an HTML string
* that can be used in a csv file
* @todo consider merging this function with display_complete_report
* @return string The contents of a csv file
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version February 2007
*/
static function export_complete_report_xls($filename, $user_id = 0)
{
require_once api_get_path(LIBRARY_PATH) . 'pear/Spreadsheet_Excel_Writer/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->send($filename);
$workbook->setVersion(8);
// BIFF8
$worksheet =& $workbook->addWorksheet('Report 1');
$worksheet->setInputEncoding(api_get_system_encoding());
$line = 0;
$column = 1;
// Skip the first column (row titles)
// Show extra fields blank space (enough for extra fields on next line)
$display_extra_user_fields = false;
//if (!empty($_REQUEST['fields_filter'])) {
// Show user fields section with a big th colspan that spans over all fields
$extra_user_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false, true);
$num = count($extra_user_fields);
for ($i = 0; $i < $num; $i++) {
$worksheet->write($line, $column, '');
$column++;
}
$display_extra_user_fields = true;
//}
// Database table definitions
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$course_id = api_get_course_int_id();
// First line (questions)
$sql = "SELECT questions.question_id, questions.type, questions.survey_question, count(options.question_option_id) as number_of_options\n\t\t\t\tFROM {$table_survey_question} questions LEFT JOIN {$table_survey_question_option} options\n\t\t\t\t ON questions.question_id = options.question_id AND options.c_id = {$course_id}\n\t\t\t\tWHERE questions.survey_id = '" . Database::escape_string($_GET['survey_id']) . "' AND\n\t\t\t\tquestions.c_id = {$course_id}\n\t\t\t\tGROUP BY questions.question_id\n\t\t\t\tORDER BY questions.sort ASC";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
// We show the questions if
// 1. there is no question filter and the export button has not been clicked
// 2. there is a quesiton filter but the question is selected for display
if (!$_POST['submit_question_filter'] || is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) {
// We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
if ($row['number_of_options'] == 0 && $row['type'] == 'open') {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES));
$column++;
} else {
for ($ii = 0; $ii < $row['number_of_options']; $ii++) {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES));
$column++;
}
}
}
}
}
$line++;
$column = 1;
// Show extra field values
if ($display_extra_user_fields) {
// Show the fields names for user fields
foreach ($extra_user_fields as &$field) {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES));
$column++;
}
}
// Getting all the questions and options (second line)
$sql = "SELECT \tsurvey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type,\n\t\t\t\t\t\tsurvey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort\n\t\t\t\tFROM {$table_survey_question} survey_question\n\t\t\t\tLEFT JOIN {$table_survey_question_option} survey_question_option\n\t\t\t\tON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = {$course_id}\n\t\t\t\tWHERE survey_question.survey_id = '" . Database::escape_string($_GET['survey_id']) . "' AND\n\t\t\t\tsurvey_question.c_id = {$course_id}\n\t\t\t\tORDER BY survey_question.sort ASC, survey_question_option.sort ASC";
$result = Database::query($sql);
$possible_answers = array();
$possible_answers_type = array();
while ($row = Database::fetch_array($result)) {
// We show the options if
// 1. there is no question filter and the export button has not been clicked
// 2. there is a quesiton filter but the question is selected for display
if (!$_POST['submit_question_filter'] || is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) {
// We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES));
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
$possible_answers_type[$row['question_id']] = $row['type'];
$column++;
}
}
}
// Getting all the answers of the users
$line++;
$column = 0;
$old_user = '';
$answers_of_user = array();
$sql = "SELECT * FROM {$table_survey_answer} WHERE c_id = {$course_id} AND survey_id='" . Database::escape_string($_GET['survey_id']) . "' ";
if ($user_id != 0) {
$sql .= "AND user='" . Database::escape_string($user_id) . "' ";
}
$sql .= "ORDER BY user ASC";
$open_question_iterator = 1;
//.........这里部分代码省略.........
示例10: cw_xls_get_serials
function cw_xls_get_serials($product_id, $serials)
{
global $config, $tables;
$xls = new Spreadsheet_Excel_Writer();
$xls->send("price_list.xls");
$xls->setVersion(8);
$format_header =& $xls->addFormat();
$format_header->setBold();
$sheet =& $xls->addWorksheet(cw_get_langvar_by_name('lbl_serial_numbers', null, false, true));
$sheet->setInputEncoding('UTF-8');
$header = array();
$header[] = array(cw_get_langvar_by_name('lbl_sku', null, false, true));
$header[] = array(cw_get_langvar_by_name('lbl_serial_number', null, false, true));
cw_xls_write_row($sheet, $format_header, 0, $header);
$sheet->setColumn(0, count($header), 20);
$product = cw_query_first("select productcode from {$tables['products']} where product_id='{$product_id}'");
if ($serials) {
$index = 1;
foreach ($serials as $serial) {
$body = array();
$body[] = array($product['productcode']);
$body[] = array($serial['sn']);
cw_xls_write_row($sheet, 0, $index, $body);
$index++;
}
}
$xls->close();
exit(0);
}
示例11: catch
$graph->yTitle = _USERS;
$graph->title = _USERSEPERUSERTYPE;
echo json_encode($graph);
exit;
}
} catch (Exception $e) {
handleAjaxExceptions($e);
}
} catch (Exception $e) {
handleNormalFlowExceptions($e);
}
if (isset($_GET['excel'])) {
require_once 'Spreadsheet/Excel/Writer.php';
$workBook = new Spreadsheet_Excel_Writer();
$workBook->setTempDir(G_UPLOADPATH);
$workBook->setVersion(8);
$formatExcelHeaders =& $workBook->addFormat(array('Size' => 14, 'Bold' => 1, 'HAlign' => 'left'));
$headerFormat =& $workBook->addFormat(array('border' => 0, 'bold' => '1', 'size' => '11', 'color' => 'black', 'fgcolor' => 22, 'align' => 'center'));
$formatContent =& $workBook->addFormat(array('HAlign' => 'left', 'Valign' => 'top', 'TextWrap' => 1));
$headerBigFormat =& $workBook->addFormat(array('HAlign' => 'center', 'FgColor' => 22, 'Size' => 16, 'Bold' => 1));
$titleCenterFormat =& $workBook->addFormat(array('HAlign' => 'center', 'Size' => 11, 'Bold' => 1));
$titleLeftFormat =& $workBook->addFormat(array('HAlign' => 'left', 'Size' => 11, 'Bold' => 1));
$fieldLeftFormat =& $workBook->addFormat(array('HAlign' => 'left', 'Size' => 10));
$fieldRightFormat =& $workBook->addFormat(array('HAlign' => 'right', 'Size' => 10));
$fieldCenterFormat =& $workBook->addFormat(array('HAlign' => 'center', 'Size' => 10));
//first tab
$workSheet =& $workBook->addWorksheet("System info");
$workSheet->setInputEncoding('utf-8');
$workSheet->setColumn(0, 0, 5);
$workSheet->write(1, 1, _BASICINFO . " (" . formatTimestamp($from) . " - " . formatTimestamp($to) . ")", $headerFormat);
$workSheet->mergeCells(1, 1, 1, 2);
示例12: getSmartyTpl
public function getSmartyTpl()
{
$currentUser = $this->getCurrentUser();
$smarty = $this->getSmartyVar();
$ranges = $this->getRanges();
$smarty->assign("T_GRADEBOOK_BASEURL", $this->moduleBaseUrl);
$smarty->assign("T_GRADEBOOK_BASELINK", $this->moduleBaseLink);
if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
$currentLesson = $this->getCurrentLesson();
$currentLessonID = $currentLesson->lesson['id'];
$lessonUsers = $currentLesson->getUsers('student');
// get all students that have this lesson
$lessonColumns = $this->getLessonColumns($currentLessonID);
$allUsers = $this->getLessonUsers($currentLessonID, $lessonColumns);
$gradeBookLessons = $this->getGradebookLessons($currentUser->getLessons(false, 'professor'), $currentLessonID);
} else {
if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
$currentLesson = $this->getCurrentLesson();
$currentLessonID = $currentLesson->lesson['id'];
}
}
if (isset($_GET['import_grades']) && eF_checkParameter($_GET['import_grades'], 'id') && in_array($_GET['import_grades'], array_keys($lessonColumns))) {
$object = eF_getTableData("module_gradebook_objects", "creator", "id=" . $_GET['import_grades']);
//if($object[0]['creator'] != $_SESSION['s_login']){
if ($currentUser->getRole($this->getCurrentLesson()) != 'professor') {
eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_GRADEBOOK_NOACCESS));
exit;
}
$result = eF_getTableData("module_gradebook_objects", "refers_to_type, refers_to_id", "id=" . $_GET['import_grades']);
$type = $result[0]['refers_to_type'];
$id = $result[0]['refers_to_id'];
$oid = $_GET['import_grades'];
foreach ($lessonUsers as $userLogin => $value) {
$this->importGrades($type, $id, $oid, $userLogin);
}
} else {
if (isset($_GET['delete_column']) && eF_checkParameter($_GET['delete_column'], 'id') && in_array($_GET['delete_column'], array_keys($lessonColumns))) {
$object = eF_getTableData("module_gradebook_objects", "creator", "id=" . $_GET['delete_column']);
//if($object[0]['creator'] != $_SESSION['s_login']){
if ($currentUser->getRole($this->getCurrentLesson()) != 'professor') {
eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_GRADEBOOK_NOACCESS));
exit;
}
eF_deleteTableData("module_gradebook_objects", "id=" . $_GET['delete_column']);
eF_deleteTableData("module_gradebook_grades", "oid=" . $_GET['delete_column']);
} else {
if (isset($_GET['compute_score_grade']) && $_GET['compute_score_grade'] == '1') {
foreach ($allUsers as $uid => $student) {
$this->computeScoreGrade($lessonColumns, $ranges, $student['users_LOGIN'], $uid);
}
} else {
if (isset($_GET['export_excel']) && ($_GET['export_excel'] == 'one' || $_GET['export_excel'] == 'all')) {
require_once 'Spreadsheet/Excel/Writer.php';
$workBook = new Spreadsheet_Excel_Writer();
$workBook->setTempDir(G_UPLOADPATH);
$workBook->setVersion(8);
$workBook->send('GradeBook.xls');
if ($_GET['export_excel'] == 'one') {
$workSheet =& $workBook->addWorksheet($currentLesson->lesson['name']);
$this->professorLessonToExcel($currentLessonID, $currentLesson->lesson['name'], $workBook, $workSheet);
} else {
if ($_GET['export_excel'] == 'all') {
$professorLessons = $currentUser->getLessons(false, 'professor');
foreach ($professorLessons as $key => $value) {
$subLesson = new EfrontLesson($key);
$subLessonUsers = $subLesson->getUsers('student');
// get all students that have this lesson
$result = eF_getTableData("module_gradebook_users", "count(uid) as total_users", "lessons_ID=" . $key);
if ($result[0]['total_users'] != 0) {
// module installed for this lesson
$workSheet =& $workBook->addWorksheet($subLesson->lesson['name']);
$this->professorLessonToExcel($key, $subLesson->lesson['name'], $workBook, $workSheet);
}
}
}
}
$workBook->close();
exit;
} else {
if (isset($_GET['export_student_excel']) && ($_GET['export_student_excel'] == 'current' || $_GET['export_student_excel'] == 'all')) {
require_once 'Spreadsheet/Excel/Writer.php';
$workBook = new Spreadsheet_Excel_Writer();
$workBook->setTempDir(G_UPLOADPATH);
$workBook->setVersion(8);
$workBook->send('GradeBook.xls');
if ($_GET['export_student_excel'] == 'current') {
$workSheet =& $workBook->addWorksheet($currentLesson->lesson['name']);
$this->studentLessonToExcel($currentLessonID, $currentLesson->lesson['name'], $currentUser, $workBook, $workSheet);
} else {
if ($_GET['export_student_excel'] == 'all') {
$studentLessons = $currentUser->getLessons(false, 'student');
foreach ($studentLessons as $key => $value) {
// Is GradeBook installed for this lesson ?
$installed = eF_getTableData("module_gradebook_users", "*", "lessons_ID=" . $key . " and users_LOGIN='" . $currentUser->user['login'] . "'");
if (sizeof($installed) != 0) {
$subLesson = new EfrontLesson($key);
$workSheet =& $workBook->addWorksheet($subLesson->lesson['name']);
$this->studentLessonToExcel($key, $subLesson->lesson['name'], $currentUser, $workBook, $workSheet);
}
}
//.........这里部分代码省略.........
示例13: array
$temp2 = array();
$query = 'SELECT num_cre_reg, num_cre_pass,avg_grade_term, num_cre_all,avg_grade_all FROM term_stat WHERE student_id="' . $sid . '" AND term_name = "' . $term['term_name'] . '"';
//echo $query;
$stats = mysql_query($query);
$stat = mysql_fetch_array($stats);
$temp2['num_cre_reg'] = $stat['num_cre_reg'];
$temp2['num_cre_pass'] = $stat['num_cre_pass'];
$temp2['avg_grade_term'] = $stat['avg_grade_term'];
$temp2['num_cre_all'] = $stat['num_cre_all'];
$temp2['avg_grade_all'] = $stat['avg_grade_all'];
$term_result[$term['term_name']] = array('detail' => $temp, 'stat' => $temp2, 'ten_hk' => $tenhk);
//var_dump($term_result);
}
//var_dump($term_result);
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setVersion(8, 'utf-8');
$worksheet1 =& $workbook->addWorksheet($sid);
$worksheet1->setInputEncoding('utf-8');
$worksheet1->hideScreenGridlines();
$worksheet1->freezePanes(array(4, 0));
$worksheet1->setHeader('Truong Dai hoc Bach Khoa Tp.HCM');
$worksheet1->setFooter(date('d/m/Y'));
$worksheet1->centerVertically();
$cur_row = 0;
$bitmap = "../file/bk_hcm.bmp";
$format =& $workbook->addFormat(array('color' => 'black', 'bold' => 1, 'FontFamily' => 'Arial', 'align' => 'merge', 'size' => 15, 'vAlign' => 'vcenter'));
$worksheet1->setRow(0, 40);
//$worksheet1->set
$worksheet1->insertBitmap(0, 0, $bitmap, 0, 0, 0.7, 0.7);
$cur_row++;
$worksheet1->write(0, 1, 'Truong Dai hoc Bach Khoa Tp. Ho Chi Minh', $format);
示例14: export
public function export($mode = null)
{
if ($this->survey->isDeleted()) {
return null;
}
$exportResult = array('headers' => array(), 'content' => "");
ob_start();
$exportoutput = "";
$tokenTableExists = $this->survey->getDbConnection()->schema->getTable('tokens_' . $this->survey->sid) !== null;
$aTokenFieldNames = array();
if ($tokenTableExists) {
$aTokenFieldNames = static::getTokenFieldsAndNames($this->survey);
$attributeFieldAndNames = static::getTokenFieldsAndNames($this->survey, true);
$attributeFields = array_keys($attributeFieldAndNames);
}
require_once Yii::getPathOfAlias('ext.excelWriter') . "/Writer.php";
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setVersion(8);
// Inform the module that our data will arrive as UTF-8.
// Set the temporary directory to avoid PHP error messages due to open_basedir restrictions and calls to tempnam("", ...)
if (!empty($tempdir)) {
$workbook->setTempDir($tempdir);
}
$exportResult['headers'][] = "Content-type: application/vnd.ms-excel";
$exportResult['headers'][] = "Content-Disposition: attachment; filename=\"results-survey" . $this->survey->sid . ".xls\"";
$exportResult['headers'][] = "Expires: 0";
$exportResult['headers'][] = "Cache-Control: must-revalidate, post-check=0,pre-check=0";
$exportResult['headers'][] = "Pragma: public";
// $workbook->send('results-survey'.$this->survey->sid.'.xls');
// Creating the first worksheet
$query = "SELECT * FROM lime_surveys_languagesettings WHERE surveyls_survey_id=" . $this->survey->sid;
// $result = db_execute_assoc($query) or safe_die("Couldn't get privacy data<br />$query<br />".$connect->ErrorMsg());
// $row = $result->FetchRow();
$row = $this->survey->getDbConnection()->createCommand($query)->queryRow();
$row['surveyls_title'] = substr(str_replace(array('*', ':', '/', '\\', '?', '[', ']'), array(' '), $row['surveyls_title']), 0, 31);
// Remove invalid characters
$sheet =& $workbook->addWorksheet($row['surveyls_title']);
// do not translate/change this - the library does not support any special chars in sheet name
$sheet->setInputEncoding('utf-8');
$separator = "~|";
$exportResult['headers'][] = "Cache-Control: must-revalidate, post-check=0, pre-check=0";
$exportResult['headers'][] = "Pragma: public";
// Export Language is set by default to surveybaselang
// * the explang language code is used in SQL queries
// * the alang object is used to translate headers and hardcoded answers
// In the future it might be possible to 'post' the 'export language' from
// the exportresults form
// $explang = 'ru';
// $elang=new limesurvey_lang($explang);
//STEP 1: First line is column headings
$fieldmap = static::createFieldMap($this->survey, 'full');
if ($this->survey->savetimings === "Y") {
//Append survey timings to the fieldmap array
$fieldmap = $fieldmap + static::createTimingsFieldMap($this->survey, 'full');
}
//Get the fieldnames from the survey table for column headings
$surveytable = "lime_survey_{$this->survey->sid}";
// if (isset($_POST['colselect']))
// {
// $selectfields="";
// foreach($_POST['colselect'] as $cs)
// {
// if (!isset($fieldmap[$cs]) && !isset($aTokenFieldNames[$cs]) && $cs != 'completed') continue; // skip invalid field names to prevent SQL injection
// if ($tokenTableExists && $cs == 'token')
// {
// // We shouldnt include the token field when we are joining with the token field
// }
// elseif ($cs === 'id')
// {
// $selectfields.= db_quote_id($surveytable) . '.' . db_quote_id($cs) . ", ";
// }
// elseif ($cs != 'completed')
// {
// $selectfields.= db_quote_id($cs).", ";
// }
// else
// {
// $selectfields.= "CASE WHEN $surveytable.submitdate IS NULL THEN 'N' ELSE 'Y' END AS completed, ";
// }
// }
// $selectfields = mb_substr($selectfields, 0, strlen($selectfields)-2);
// }
// else
// {
$selectfields = "{$surveytable}.*, CASE WHEN {$surveytable}.submitdate IS NULL THEN 'N' ELSE 'Y' END AS completed";
// }
$dquery = "SELECT {$selectfields}";
/*if ($tokenTableExists && $this->survey->anonymized =='N' && isset($_POST['attribute_select']) && is_array($_POST['attribute_select']))
{
if (in_array('first_name',$_POST['attribute_select']))
{
$dquery .= ", lime_tokens_$surveyid.firstname";
}
if (in_array('last_name',$_POST['attribute_select']))
{
$dquery .= ", lime_tokens_$surveyid.lastname";
}
if (in_array('email_address',$_POST['attribute_select']))
{
$dquery .= ", lime_tokens_$surveyid.email";
//.........这里部分代码省略.........
示例15: BackupExcel
/**
* @param string $filename Filename (needed for unit testing)
*/
public function BackupExcel($filename = '')
{
// Creating a workbook
if ($filename) {
//$workbook = new Spreadsheet_Excel_Writer(_DIR_TMP.$filename);
$workbook = new Spreadsheet_Excel_Writer($this->GetTmpDir() . $filename);
} else {
//$workbook = new Spreadsheet_Excel_Writer(_DIR_TMP.'products_'.date("d-m-Y_H-i-s").'.xls');
$workbook = new Spreadsheet_Excel_Writer($this->GetTmpDir() . 'products_' . date("d-m-Y_H-i-s") . '.xls');
}
$workbook->setVersion(8);
// Let's create catalogue worksheet:
$this->addWorksheet($workbook);
// Let's send the file
$workbook->close();
}