本文整理汇总了PHP中Spreadsheet_Excel_Writer::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Spreadsheet_Excel_Writer::close方法的具体用法?PHP Spreadsheet_Excel_Writer::close怎么用?PHP Spreadsheet_Excel_Writer::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spreadsheet_Excel_Writer
的用法示例。
在下文中一共展示了Spreadsheet_Excel_Writer::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createXLSAdv
function createXLSAdv(&$rows, $row_labels = null, $row_headers = null, $title = null)
{
ob_clean();
ob_start();
require_once JPATH_COMPONENT_SITE . DS . 'libraries' . DS . 'pear' . DS . 'PEAR.php';
require_once JPATH_COMPONENT_SITE . DS . 'libraries' . DS . 'Excel' . DS . 'Writer.php';
// Creating a workbook
$workbook = new Spreadsheet_Excel_Writer();
$worksheet = $workbook->addWorksheet($title);
$BIFF = new Spreadsheet_Excel_Writer_BIFFwriter();
$format = new Spreadsheet_Excel_Writer_Format($BIFF);
$format->setBold(1);
$format->setAlign('center');
for ($k = 0; $k < count($row_labels); $k++) {
$worksheet->write(0, $k, $row_headers[$row_labels[$k]], $format);
}
for ($i = 0; $i < count($rows); $i++) {
for ($k = 0; $k < count($row_labels); $k++) {
$worksheet->write($i + 1, $k, $rows[$i][$row_labels[$k]]);
}
}
$workbook->close();
$attachment = ob_get_contents();
@ob_end_clean();
echo $attachment;
}
示例2: exportList
function exportList($params = array())
{
require_once 'Spreadsheet/Excel/Writer.php';
$records = $this->getList($params);
$workbook = new Spreadsheet_Excel_Writer();
$workbook->send('export.xls');
$worksheet =& $workbook->addWorksheet('Report');
$worksheet->write(0, 0, 'User');
$worksheet->write(0, 1, 'Date');
$worksheet->write(0, 2, 'Time');
$worksheet->write(0, 3, 'ID');
$worksheet->write(0, 4, 'Panel');
$row = 0;
foreach ($records as $record) {
$row++;
$date = $record->rdate;
$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$day = substr($date, 6, 2);
$time = str_pad($record->rtime, 6, '0', STR_PAD_LEFT);
$hour = substr($time, 0, 2);
$min = substr($time, 2, 2);
$sec = substr($time, 4, 2);
$worksheet->write($row, 0, $record->LN . ', ' . $record->FN);
$worksheet->write($row, 1, "{$month}/{$day}/{$year}");
$worksheet->write($row, 2, "{$hour}:{$min}:{$sec}");
$worksheet->write($row, 3, $record->CardNumber);
$worksheet->write($row, 4, $record->panel);
}
$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: WriteToXLS
public function WriteToXLS($filename)
{
$xls = new Spreadsheet_Excel_Writer($filename);
$sheet = $xls->addWorksheet('auto2you.ru');
$sheet->setColumn(0, 0, 130);
$sheet->setColumn(1, 1, 20);
$sheet->setColumn(2, 2, 15);
$sheet->setColumn(3, 3, 30);
$titleFormat = $xls->addFormat();
$titleFormat->setFontFamily('Helvetica');
$titleFormat->setBold();
$titleFormat->setAlign('center');
$itemFormat = $xls->addFormat();
$titles = array('Имя', 'Город', 'Телефон', 'E-mail');
foreach ($titles as $ind => $title) {
$sheet->write(0, $ind, $title, $titleFormat);
}
$ind = 1;
foreach ($this->data as $item) {
$sheet->write($ind, 0, $item['name'], $itemFormat);
$sheet->write($ind, 1, $item['city'], $itemFormat);
$sheet->write($ind, 2, $item['phone'], $itemFormat);
$sheet->write($ind, 3, $item['email'], $itemFormat);
$ind++;
}
$xls->close();
}
示例5: 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();
}
示例6: output
public static function output($table, $name = '')
{
error_reporting(0);
if (!is_object($table) && !is_array($table)) {
exit;
}
if ($name == '') {
$name = 'output' . Invocation::next();
}
if (!preg_match('/^.*\\.xls$/i', $name)) {
$name .= '.xls';
}
$fileName = PHPExt::getTempDir() . '/' . $name;
$workbook = new Spreadsheet_Excel_Writer($fileName);
$worksheet =& $workbook->addWorksheet(basename($name));
$rowIdx = 0;
if ($table instanceof DBTable || is_array($table)) {
foreach ($table as $row) {
if ($rowIdx == 0) {
foreach (array_keys($row) as $col => $heading) {
$worksheet->write($rowIdx, $col, $heading);
}
$rowIdx++;
}
foreach (array_values($row) as $col => $val) {
$worksheet->write($rowIdx, $col, $val);
}
$rowIdx++;
}
} else {
if ($table instanceof PDOStatement) {
while ($row = $table->fetch(DB::FETCH_ASSOC)) {
if ($rowIdx == 0) {
foreach (array_keys($row) as $col => $heading) {
$worksheet->write($rowIdx, $col, $heading);
}
$rowIdx++;
}
foreach (array_values($row) as $col => $val) {
$worksheet->write($rowIdx, $col, $val);
}
$rowIdx++;
}
}
}
$workbook->close();
$workbook->send($name);
$fp = fopen($fileName, 'rb');
fpassthru($fp);
fclose($fp);
unlink($fileName);
exit;
}
示例7: group_get_members
public function group_get_members($pGroup)
{
if (!$pGroup instanceof koala_group) {
throw new Exception("parameter is not an instance of koala_group", E_PARAM);
}
if (!$pGroup->is_admin(lms_steam::get_current_user())) {
throw new Exception("no admin rights.operation canceled.");
}
$cache = get_cache_function($pGroup->get_id(), CACHE_LIFETIME_STATIC);
switch (get_class($pGroup)) {
case "koala_group_course":
$group_name = $pGroup->get_course_id() . " - " . $pGroup;
$members = $cache->call("lms_steam::group_get_members", $pGroup->steam_group_learners->get_id());
break;
default:
$members = $cache->call("lms_steam::group_get_members", $pGroup->get_id());
break;
}
// INITIALIZATION
$course_id = $pLmsGroupCourse->get_course_id();
$course_name = $pLmsGroupCourse->get_course_dsc_short();
$semester = $pLmsGroupCourse->get_semester();
$excel = new Spreadsheet_Excel_Writer();
$excel->send($course_id . "_" . $semester->get_name());
$sheet =& $excel->addWorksheet(gettext("participants"));
// WRITE EXCEL SHEET
$sheet->writeString(0, 0, $course_id . " - " . $course_name());
$sheet->writeSting(1, 0, $semester->get_name());
$sheet->writeString(3, 0, gettext("student id"));
$sheet->writeString(3, 1, gettext("forename"));
$sheet->writeString(3, 2, gettext("surname"));
$no_members = count($members);
if ($no_members > 0) {
$row = 5;
for ($i = $start; $i < $end; $i++) {
$member = $members[$i];
$sheet->writeString($row, 1, $member["USER_FIRSTNAME"]);
$sheet->writeString($row, 2, $member["USER_FULLNAME"]);
$sheet->writeString($row, 3, $member["USER_EMAIL"]);
$sheet->writeString($row, 4, $member["USER_PROFILE_FACULTY"]);
$row++;
}
}
$excel->close();
}
示例8: assertSameAsInFixture
protected function assertSameAsInFixture($filename, Spreadsheet_Excel_Writer $workbook)
{
$this->assertEmpty($workbook->_filename, "Testing with fixtures works only for standard output");
// we have to fix timestamp for fixtures to work
$workbook->_timestamp = 1000000000;
// somewhere in 2001
ob_start();
$workbook->close();
$data = ob_get_clean();
$fullPath = self::FIXTURES_PATH . $filename;
if ($this->shouldUpdateFixtures()) {
file_put_contents($fullPath, $data);
}
if (!is_file($fullPath)) {
$this->fail("Fixture {$filename} not found");
}
// TODO: should we save data for future analysis?
//file_put_contents("{$fullPath}.work", $data);
$this->assertEquals(file_get_contents($fullPath), $data, "Output differs for {$filename}");
}
示例9: xls
/**
* Genera un reporte en Excel
*
* @param array $result
* @param array $sumArray
* @param string $title
* @param array $weightArray
* @param array $headerArray
*/
function xls($result, $sumArray, $title, $weightArray, $headerArray)
{
error_reporting(0);
$file = md5(uniqid());
$config = Config::read('config');
$active_app = Router::get_application();
$workbook = new Spreadsheet_Excel_Writer("public/temp/{$file}.xls");
$worksheet =& $workbook->addWorksheet();
$titulo_verdana =& $workbook->addFormat(array('fontfamily' => 'Verdana', 'size' => 20));
$titulo_verdana2 =& $workbook->addFormat(array('fontfamily' => 'Verdana', 'size' => 18));
$workbook->setCustomColor(12, 0xf2, 0xf2, 0xf2);
$column_title =& $workbook->addFormat(array('fontfamily' => 'Verdana', 'size' => 12, 'fgcolor' => 12, 'border' => 1, 'bordercolor' => 'black', "halign" => 'center'));
$column =& $workbook->addFormat(array('fontfamily' => 'Verdana', 'size' => 11, 'border' => 1, 'bordercolor' => 'black'));
$column_centered =& $workbook->addFormat(array('fontfamily' => 'Verdana', 'size' => 11, 'border' => 1, 'bordercolor' => 'black', "halign" => 'center'));
$worksheet->write(0, 0, strtoupper($config->{$active_app}->name), $titulo_verdana);
$worksheet->write(1, 0, "REPORTE DE " . strtoupper($title), $titulo_verdana2);
$worksheet->write(2, 0, "FECHA " . date("Y-m-d"), $titulo_verdana2);
for ($i = 0; $i <= count($headerArray) - 1; $i++) {
$worksheet->setColumn($i, $i, $weightArray[$i]);
$worksheet->write(4, $i, $headerArray[$i], $column_title);
}
$l = 5;
foreach ($result as $row) {
for ($i = 0; $i <= count($row) - 1; $i++) {
if (!is_numeric($row[$i])) {
$worksheet->writeString($l, $i, $row[$i], $column);
} else {
$worksheet->writeString($l, $i, $row[$i], $column_centered);
}
}
$l++;
}
$workbook->close();
error_reporting(E_ALL ^ E_STRICT);
if (isset($raw_output)) {
print "<script type='text/javascript'> window.open('" . KUMBIA_PATH . "temp/" . $file . ".xls', null); </script>";
} else {
Generator::forms_print("<script type='text/javascript'> window.open('" . KUMBIA_PATH . "temp/" . $file . ".xls', null); </script>");
}
}
示例10: 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);
}
示例11: renderXls
function renderXls()
{
$workbook = new Spreadsheet_Excel_Writer();
// sending HTTP headers
$workbook->send($this->getKursus()->getKursusNavn());
// Creating a worksheet
$worksheet = $workbook->addWorksheet('Deltagere');
$format_bold = $workbook->addFormat();
$format_bold->setBold();
$format_bold->setSize(8);
$format_italic = $workbook->addFormat();
$format_italic->setItalic();
$format_italic->setSize(8);
$format =& $workbook->addFormat();
$format->setSize(8);
$i = 0;
$worksheet->write($i, 0, 'Vejle Idrætshøjskole: ' . $this->getKursus()->getKursusNavn(), $format_bold);
$i = 2;
foreach ($this->getKursus()->getTilmeldinger() as $deltager) {
$worksheet->write($i, 0, $deltager->get('navn'), $style);
$worksheet->write($i, 1, $deltager->get('cpr'), $style);
$i++;
}
$worksheet->hideGridLines();
// Let's send the file
$data = $workbook->close();
$response = new k_HttpResponse(200, $data);
$response->setEncoding(NULL);
$response->setContentType("application/excel");
/*
$response->setHeader("Content-Length", strlen($data));
$response->setHeader("Content-Disposition", "attachment;filename=\"\"");
$response->setHeader("Content-Transfer-Encoding", "binary");
$response->setHeader("Cache-Control", "Public");
$response->setHeader("Pragma", "public");
*/
throw $response;
}
示例12: 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');
}
}
示例13: export_complete_report_xls
function export_complete_report_xls($filename, $array)
{
global $charset, $global, $filter_score;
$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)
if ($global) {
$worksheet->write($line, $column, get_lang('Courses'));
$column++;
$worksheet->write($line, $column, get_lang('Exercises'));
$column++;
$worksheet->write($line, $column, get_lang('ExamTaken'));
$column++;
$worksheet->write($line, $column, get_lang('ExamNotTaken'));
$column++;
$worksheet->write($line, $column, sprintf(get_lang('ExamPassX'), $filter_score) . '%');
$column++;
$worksheet->write($line, $column, get_lang('ExamFail'));
$column++;
$worksheet->write($line, $column, get_lang('TotalStudents'));
$column++;
$line++;
foreach ($array as $row) {
$column = 0;
foreach ($row as $item) {
$worksheet->write($line, $column, html_entity_decode(strip_tags($item)));
$column++;
}
$line++;
}
$line++;
} else {
$worksheet->write($line, $column, get_lang('Exercises'));
$column++;
$worksheet->write($line, $column, get_lang('User'));
$column++;
$worksheet->write($line, $column, get_lang('Percentage'));
$column++;
$worksheet->write($line, $column, get_lang('Status'));
$column++;
$worksheet->write($line, $column, get_lang('Attempts'));
$column++;
$line++;
foreach ($array as $row) {
$column = 0;
$worksheet->write($line, $column, html_entity_decode(strip_tags($row['exercise'])));
$column++;
foreach ($row['users'] as $key => $user) {
$column = 1;
$worksheet->write($line, $column, html_entity_decode(strip_tags($user)));
$column++;
foreach ($row['results'][$key] as $result_item) {
$worksheet->write($line, $column, html_entity_decode(strip_tags($result_item)));
$column++;
}
$line++;
}
}
$line++;
}
$workbook->close();
exit;
}
示例14: export
//.........这里部分代码省略.........
$title =& $workbook->addFormat();
$title->setBold();
$title->setAlign('center');
$title->setBottom(2);
// Let's add the field names to the title line.
// Leave out a few.
$x = 0;
$worksheet->setRow(0, 18.75);
foreach ($fields as $field) {
$exclude_this = array_key_exists($field, $field_exclusions);
if ($exclude_this && $field_exclusions[$field] == true) {
// do nothing
} else {
$worksheet->write(0, $x, ucwords(str_replace('_', ' ', $field)), $title);
$x++;
}
}
// Now here comes the data.
$y = 1;
while ($model->fetch()) {
$item = $model->toArray();
// For reference while we're working with things.
$original_item = array();
$original_item = $item;
$x = 0;
$worksheet->setRow($y, 18.75);
foreach ($fields as $field) {
$exclude_this = array_key_exists($field, $field_exclusions);
if ($exclude_this && $field_exclusions[$field] == true) {
// do nothing
} else {
// Look for foreign keys and replace if assigned.
foreach ($foreign_keys as $foreign_key => $foreign_key_value) {
if ($field == $foreign_key) {
$fk_model_name = $foreign_key_value[0];
$fk_model_headline = $foreign_key_value[1];
$fk_model = NModel::factory($fk_model_name);
if ($fk_model && $fk_model->get($item[$field])) {
$item[$field] = $fk_model->{$fk_model_headline};
}
unset($fk_model);
}
}
//Look for bitmask fields and replace with string value instead of numeric total
if (is_array($model->bitmask_fields) && count($model->bitmask_fields)) {
$bitmask_keys = array_keys($model->bitmask_fields);
if (in_array($field, $bitmask_keys)) {
$bitmask_total = $item[$field];
$value_str = '';
$i = 0;
foreach ($model->bitmask_fields[$field] as $bit => $val) {
if ($bit & $bitmask_total) {
if ($i > 0) {
$value_str .= ', ';
}
$value_str .= $val;
$i++;
}
}
$item[$field] = $value_str;
}
}
// Any extra fields get dealt with here.
if (isset($model->excel_extra_fields)) {
foreach ($model->excel_extra_fields as $key => $value) {
if ($field == $key) {
$extra_name = $value[0];
$extra_attribute = $value[1];
$extra_key = $value[2];
$extra_info = NModel::factory($extra_name);
if (method_exists($extra_info, $extra_attribute)) {
$item[$field] = $extra_info->{$extra_attribute}($original_item["{$extra_key}"]);
} else {
$extra_info->get($original_item["{$extra_key}"]);
$item[$field] = $extra_info->{$extra_attribute};
}
unset($extra_info);
}
}
}
// If it's an uploaded file, put the address in the conf.php before it so that it
// turns into a link in Excel.
if (eregi(UPLOAD_DIR, $item[$field])) {
$item[$field] = PUBLIC_SITE . ereg_replace("^/", "", $item[$field]);
}
$worksheet->write($y, $x, $this->convert_characters($item[$field]));
$x++;
}
}
$y++;
unset($original_item);
unset($item);
}
// sending HTTP headers
$xls_filename = $model_name . '_entries.xls';
$workbook->send($xls_filename);
$workbook->close();
}
}
}
示例15: _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();
}