本文整理汇总了PHP中Export类的典型用法代码示例。如果您正苦于以下问题:PHP Export类的具体用法?PHP Export怎么用?PHP Export使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Export类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export
function export($from, $to)
{
$productId = $this->common->getCurrentProduct()->id;
$productName = $this->common->getCurrentProduct()->name;
$data = $this->device->getDeviceTypeDetail($productId);
$this->load->library('export');
$export = new Export();
//设定文件名
$export->setFileName($productName . '_' . $from . '_' . $to . '.csv');
//输出列名第一种方法
$fields = array();
foreach ($data->list_fields() as $field) {
array_push($fields, $field);
}
$export->setTitle($fields);
//输出列名第二种方法
// $excel_title = array (iconv("UTF-8", "GBK", "设备型号"),iconv("UTF-8", "GBK", "总数"),iconv("UTF-8", "GBK", "用户比例") );
// $export->setTitle ($excel_title );
//输出内容
foreach ($data->result() as $row) {
$export->addRow($row);
}
$export->export();
die;
}
示例2: actionIndex
public function actionIndex()
{
//registering js file
Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.modules.export.assets') . '/js/jquery-ui.1.10.4.js'));
$models = Yii::app()->controller->module->allowedModels;
if ($models == NULL) {
foreach (glob('./protected/models/*.php') as $filename) {
$modelname = str_replace(array("./protected/models/", ".php"), "", $filename);
$models[$modelname]['label'] = $modelname;
}
}
$modelsArray = array();
foreach ($models as $mindex => $smodel) {
$modelsArray[$mindex] = isset($smodel['label']) ? $smodel['label'] : $mindex;
}
if (isset($_POST['export-database'])) {
if (isset($_POST['reqColumns']) and count($_POST['reqColumns']) > 0) {
$model = $_POST['model'];
$format = 'csv';
if (in_array($model, array_keys($modelsArray))) {
$export = new Export();
if (!$export->exportdb($format, $model, $_POST['reqColumns'])) {
$this->redirect(array('index'));
}
} else {
Yii::app()->user->setFlash('exporterror', 'You are not allowed to access this model !!');
$this->redirect(array('index'));
}
} else {
Yii::app()->user->setFlash('exporterror', 'Choose columns to export !!');
$this->redirect(array('index'));
}
}
$this->render('index', array('modelsArray' => $modelsArray));
}
示例3: export
function export($from, $to)
{
$this->load->library('export');
$productId = $this->common->getCurrentProduct()->id;
$productName = $this->common->getCurrentProduct()->name;
$data = $this->os->getTotalUserPercentByOS($productId);
$export = new Export();
//设定文件名
$export->setFileName($productName . '.csv');
// //输出列名第一种方法
$fields = array();
foreach ($data->list_fields() as $field) {
array_push($fields, $field);
}
$export->setTitle($fields);
//输出列名第二种方法
// $excel_title = array (iconv("UTF-8", "GBK", "操作系统版本"),iconv("UTF-8", "GBK", "用户比例") );
// $export->setTitle ($excel_title );
//输出内容
foreach ($data->result() as $row) {
$export->addRow($row);
}
$export->export();
die;
}
示例4: trigger_salsa_db_date
function trigger_salsa_db_date($jaguar_model, $date)
{
global $DB;
foreach ($jaguar_model as $jaguar) {
$row = $DB->query('select * from export where model = "' . $jaguar . '" ')->fetch_array(MYSQLI_ASSOC);
$export = new Export($row);
$export->reset_export_date($date);
}
}
示例5: loadModel
/**
* @param $id
* @return Export
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Export::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, Yii::t('YmlModule.default', 'Page not found!'));
}
return $model;
}
示例6: actionView
public function actionView($id)
{
$model = Export::model()->findByPk($id);
if (false === $model) {
throw new CHttpException(404);
}
$criteria = new CDbCriteria();
$criteria->compare('t.status', Product::STATUS_ACTIVE);
if (!empty($model->categories)) {
$criteria->addInCondition('t.category_id', (array) $model->categories);
}
if (!empty($model->brands)) {
$criteria->addInCondition('t.producer_id', (array) $model->brands);
}
$dataProvider = new CActiveDataProvider('Product', ['criteria' => $criteria]);
$offers = new CDataProviderIterator($dataProvider, 100);
ContentType::setHeader(ContentType::TYPE_XML);
$this->renderPartial('view', ['model' => $model, 'currencies' => Yii::app()->getModule('store')->getCurrencyList(), 'categories' => StoreCategory::model()->published()->findAll(), 'offers' => $offers]);
}
示例7: actionView
public function actionView($id)
{
/* @var $model Export */
$model = Export::model()->findByPk($id);
if (!$model) {
throw new CHttpException(404);
}
$cacheKey = $this->cacheKey . $model->id;
if (!($xml = Yii::app()->getCache()->get($cacheKey))) {
$xml = $this->getXmlHead();
$xml .= CHtml::openTag('yml_catalog', ['date' => date('Y-m-d H:i')]);
$xml .= CHtml::openTag('shop');
$xml .= $this->getShopInfo($model->shop_name, $model->shop_company, $model->shop_url ?: Yii::app()->getBaseUrl(true), $model->shop_platform, $model->shop_version, $model->shop_agency, $model->shop_email, $model->shop_cpa);
$xml .= $this->getCurrenciesElement([['id' => 'RUR', 'rate' => 1]]);
$xml .= $this->getCategoriesElement();
$xml .= $this->getOffersElement($model->categories, $model->brands);
$xml .= CHtml::closeTag('shop');
$xml .= CHtml::closeTag('yml_catalog');
Yii::app()->getCache()->set($cacheKey, $xml, 60 * 60);
}
header("Content-type: text/xml");
echo $xml;
Yii::app()->end();
}
示例8: export
private function export($res)
{
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=persons_list_' . date('Ymd') . '.csv');
$contents = array();
$title = array();
$fp = fopen('php://output', 'w');
fputs($fp, $bom = chr(0xef) . chr(0xbb) . chr(0xbf));
$k = 0;
foreach ($res as $row) {
$fields = \Export::person_field($row);
foreach ($fields as $field => $val) {
$title[$k][] = preg_replace('/_[0-9]+$/', '', $field);
$contents[$k][] = $val;
}
if ($k == 0) {
fputcsv($fp, $title[$k]);
}
fputcsv($fp, $contents[$k]);
++$k;
}
fclose($fp);
exit;
}
示例9: get_lang
$tool_name = get_lang('ImportGlossary');
break;
case 'changeview':
$tool_name = get_lang('List');
break;
}
if (isset($_GET['action']) && $_GET['action'] == 'export') {
$data = GlossaryManager::get_glossary_data(0, GlossaryManager::get_number_glossary_terms(api_get_session_id()), 0, 'ASC');
usort($data, "sorter");
$list = array();
$list[] = array('term', 'definition');
foreach ($data as $line) {
$list[] = array($line[0], $line[1]);
}
$filename = 'glossary_course_' . api_get_course_id();
Export::export_table_csv_utf8($list, $filename);
}
if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') {
GlossaryManager::export_to_pdf();
}
Display::display_header($tool_name);
// Tool introduction
Display::display_introduction_section(TOOL_GLOSSARY);
if (isset($_GET['action']) && $_GET['action'] == 'changeview' and in_array($_GET['view'], array('list', 'table'))) {
$_SESSION['glossary_view'] = $_GET['view'];
} else {
if (!isset($_SESSION['glossary_view'])) {
$_SESSION['glossary_view'] = 'table';
//Default option
}
}
示例10: destroy
public function destroy($export_id)
{
$export = Export::findOrFail($export_id);
$export->delete();
return Redirect::to(action('ExportsController@index'))->with('message', ['content' => 'Export verwijderd.', 'class' => 'danger']);
}
示例11: array
} else {
$csv_header[] = array(get_lang('LastName'), get_lang('FirstName'), get_lang('FirstLogin'), get_lang('LastConnexion'));
}
}
$form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH) . 'mySpace/student.php');
$form = Tracking::setUserSearchForm($form);
$form->setDefaults($params);
if ($export_csv) {
// send the csv file if asked
$content = $table->get_table_data();
foreach ($content as &$row) {
unset($row[4]);
}
$csv_content = array_merge($csv_header, $content);
ob_end_clean();
Export::arrayToCsv($csv_content, 'reporting_student_list');
exit;
} else {
Display::display_header($nameTools);
echo $actions;
$page_title = get_lang('Students');
echo Display::page_subheader($page_title);
if (isset($active)) {
if ($active) {
$activeLabel = get_lang('ActiveUsers');
} else {
$activeLabel = get_lang('InactiveUsers');
}
echo Display::page_subheader2($activeLabel);
}
$form->display();
示例12: get_lang
$extra = '<div style="text-align:center"><h2>' . get_lang('GroupList') . '</h2></div>';
$extra .= '<strong>' . get_lang('Course') . ': </strong>' . $courseInfo['title'] . ' (' . $courseInfo['code'] . ')';
$content = $extra . $content;
$pdf->content_to_pdf($content, null, null, api_get_course_id());
break;
case 'export':
$groupId = isset($_GET['id']) ? intval($_GET['id']) : null;
$data = GroupManager::exportCategoriesAndGroupsToArray($groupId, true);
switch ($_GET['type']) {
case 'csv':
Export::export_table_csv($data);
exit;
break;
case 'xls':
if (!empty($data)) {
Export::export_table_xls($data);
exit;
}
break;
}
break;
}
}
/* Header */
$interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') {
// So we are not in learnpath tool
if (!$is_allowed_in_course) {
api_not_allowed(true);
}
if (!api_is_allowed_to_edit(false, true)) {
示例13: switch
switch ($exportFormat) {
case 'xls':
//TODO add date if exists
$file_name = !empty($action) ? $action : 'company_report';
$browser = new Browser();
if ($browser->getPlatform() == Browser::PLATFORM_WINDOWS) {
Export::export_table_xls_html($array, $file_name, 'ISO-8859-15');
} else {
Export::export_table_xls_html($array, $file_name);
}
break;
case 'csv':
default:
//TODO add date if exists
$file_name = !empty($action) ? $action : 'company_report';
Export::arrayToCsv($array, $file_name);
break;
}
exit;
}
$i = 0;
if (!empty($result)) {
foreach ($result as $row) {
// if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235
if (!isset($row['id']) || isset($row['id']) && $row['id'] == '') {
$response->rows[$i]['id'] = $i;
} else {
$response->rows[$i]['id'] = $row['id'];
}
$array = array();
foreach ($columns as $col) {
示例14: attendance_sheet_export_to_pdf
//.........这里部分代码省略.........
} else {
if (!empty($student_id)) {
$user_id = intval($student_id);
} else {
$user_id = api_get_user_id();
}
$data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, $user_id);
$data_array['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id);
$data_array['user_id'] = $user_id;
}
$data_array['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
//Set headers pdf
$courseCategory = CourseManager::get_course_category($courseInfo['category_code']);
$teacherInfo = CourseManager::get_teacher_list_from_course_code($courseInfo['real_id']);
$teacherName = null;
foreach ($teacherInfo as $dados) {
if ($teacherName != null) {
$teacherName = $teacherName . " / ";
}
$teacherName .= $dados['firstname'] . " " . $dados['lastname'];
}
// Get data table - Marco - ordenacao fixa - just fullname
$data_table = array();
$head_table = array('#', get_lang('Name'));
foreach ($data_array['attendant_calendar'] as $class_day) {
//$head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_SHORT).' <br />'.api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT);
$head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_NUMBER_NO_YEAR);
}
$data_table[] = $head_table;
$dataClass = array();
$max_dates_per_page = 10;
$data_attendant_calendar = $data_array['attendant_calendar'];
$data_users_presence = $data_array['users_presence'];
$count = 1;
if (!empty($data_array['users_in_course'])) {
foreach ($data_array['users_in_course'] as $user) {
$cols = 1;
$result = array();
$result['count'] = $count;
$result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']);
foreach ($data_array['attendant_calendar'] as $class_day) {
if ($class_day['done_attendance'] == 1) {
if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1) {
$result[$class_day['id']] = get_lang('UserAttendedSymbol');
} else {
$result[$class_day['id']] = get_lang('UserNotAttendedSymbol');
}
} else {
$result[$class_day['id']] = " ";
}
$cols++;
}
$count++;
$data_table[] = $result;
}
}
$max_cols_per_page = 12;
//10 dates + 2 name and number
$max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2;
//10
$rows = count($data_table);
if ($cols > $max_cols_per_page) {
$number_tables = round(($cols - 2) / $max_dates_per_page);
$headers = $data_table[0];
$all = array();
$tables = array();
$changed = 1;
for ($i = 0; $i <= $rows; $i++) {
$row = $data_table[$i];
$key = 1;
$max_dates_per_page = 10;
$item = $data_table[$i];
$count_j = 0;
if (!empty($item)) {
foreach ($item as $value) {
if ($count_j >= $max_dates_per_page) {
$key++;
$max_dates_per_page = $max_dates_per_page_original * $key;
//magic hack
$tables[$key][$i][] = $tables[1][$i][0];
$tables[$key][$i][] = $tables[1][$i][1];
}
$tables[$key][$i][] = $value;
$count_j++;
}
}
}
$content = null;
if (!empty($tables)) {
foreach ($tables as $sub_table) {
$content .= Export::convert_array_to_html($sub_table) . '<br /><br />';
}
}
} else {
$content .= Export::convert_array_to_html($data_table, array('header_attributes' => array('align' => 'center')));
}
$params = array('filename' => get_lang('Attendance') . '-' . api_get_local_time(), 'pdf_title' => $courseInfo['title'], 'course_code' => $courseInfo['code'], 'add_signatures' => true, 'orientation' => 'landscape', 'pdf_teachers' => $teacherName, 'pdf_course_category' => $courseCategory['name'], 'format' => 'A4-L', 'orientation' => 'L');
Export::export_html_to_pdf($content, $params);
exit;
}
示例15: getLpStats
//.........这里部分代码省略.........
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$output .= '<td>
<img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
</td>';
} else {
$output .= '<td>
<a href="../exercice/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
<img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
</a></td>';
}
} else {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$output .= '<td>
<img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
} else {
$output .= '<td>
<a href="../exercice/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
<img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
}
}
}
$output .= '</tr>';
$n++;
}
}
$output .= '<tr><td colspan="12"> </td></tr>';
}
}
}
}
$total_time += $time_for_total;
// QUIZZ IN LP
$a_my_id = array();
if (!empty($my_lp_id)) {
$a_my_id[] = $my_lp_id;
}
}
}
// NOT Extend all "left green cross"
if (!empty($a_my_id)) {
if ($extendedAttempt) {
// "Right green cross" extended
$total_score = self::get_avg_student_score($user_id, $course_id, $a_my_id, $session_id, false, false);
} else {
// "Left green cross" extended
$total_score = self::get_avg_student_score($user_id, $course_id, $a_my_id, $session_id, false, true);
}
} else {
// Extend all "left green cross"
$total_score = self::get_avg_student_score($user_id, $course_id, array($lp_id), $session_id, false, false);
}
$total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
$total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
} else {
if (is_numeric($total_score)) {
$final_score = $total_score . '%';
} else {
$final_score = $total_score;
}
}
$progress = learnpath::getProgress($lp_id, $user_id, $course_id, $session_id);
if ($counter % 2 == 0) {
$oddclass = 'row_odd';
} else {
$oddclass = 'row_even';
}
$action = null;
if ($type == 'classic') {
$action = '<td></td>';
}
$output .= '<tr class="' . $oddclass . '">
<td></td>
<td colspan="4">
<i>' . get_lang('AccomplishedStepsTotal') . '</i>
</td>
<td colspan="2">' . $progress . '%</td>
<td colspan="2">
' . $final_score . '
</td>
<td colspan="2">' . $total_time . '</div>
' . $action . '
</tr>';
$output .= '
</tbody>
</table>
</div>
';
if (!empty($export_csv)) {
$temp = array('', '', '', '');
$csv_content[] = $temp;
$temp = array(get_lang('AccomplishedStepsTotal'), '', $final_score, $total_time);
$csv_content[] = $temp;
ob_end_clean();
Export::arrayToCsv($csv_content, 'reporting_learning_path_details');
exit;
}
return $output;
}