function template_preprocess_views_export_xls_view_xls in Views Excel Export 6
Same name and namespace in other branches
- 7 views_export_xls.module \template_preprocess_views_export_xls_view_xls()
Preprocess xls output template.
File
- ./
views_export_xls.module, line 26 - Gives the ability to export to excel
Code
function template_preprocess_views_export_xls_view_xls(&$vars) {
$view = $vars['view'];
$fields =& $view->field;
drupal_set_header('Cache-Control: max-age=60, must-revalidate');
$filename = strtr($vars['options']['filename'], array(
'%view' => check_plain($view->name),
));
$rows = $vars['rows'];
$vars['header'] = array();
foreach ($fields as $key => $field) {
if (empty($field->options['exclude'])) {
$vars['header'][$key] = check_plain($field
->label());
}
}
$vars['themed_rows'] = array();
foreach ($rows as $num => $row) {
$items = array();
foreach ($fields as $key => $field) {
if (empty($field->options['exclude'])) {
$items[$key] = strip_tags($view->style_plugin->rendered_fields[$num][$key]);
}
}
$vars['themed_rows'][$num] = $items;
}
$vars['file_name'] = $filename;
}