1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
excelexporter.php
См. документацию.
1<?php
2
4
13
14final class ExcelExporter
15{
16 public const REQUEST_PARAM_NAME = 'mode';
17 public const REQUEST_PARAM_VALUE = 'excel';
18
19 public function isExportRequest(?HttpRequest $request = null): bool
20 {
21 $request ??= Context::getCurrent()->getRequest();
22
23 return $request->get(self::REQUEST_PARAM_NAME) === self::REQUEST_PARAM_VALUE;
24 }
25
26 public function getControl(?HttpRequest $request = null): BaseButton
27 {
31 $request ??= Context::getCurrent()->getRequest();
32
33 $uri = new Uri($request->getRequestUri());
34 $uri->addParams([
35 self::REQUEST_PARAM_NAME => self::REQUEST_PARAM_VALUE,
36 // for disable composite
37 'ncc' => 1,
38 ]);
39
40 $button = new BaseButton();
41 $button->setLink((string)$uri);
42 $button->setText(Loc::getMessage('MAIN_GRID_EXPORT_EXCEL_BUTTON_TEXT'));
43
44 return $button;
45 }
46
47 public function process(Grid $grid, string $fileName = 'export'): void
48 {
49 global $APPLICATION;
50
54
55 $APPLICATION->RestartBuffer();
56
57 $grid->getSettings()->setMode(Settings::MODE_EXCEL);
58
59 try
60 {
61 ob_start();
62 $APPLICATION->IncludeComponent(
63 'bitrix:main.ui.grid',
64 'excel',
66 );
67 $content = ob_get_contents();
68 }
69 finally
70 {
71 ob_end_clean();
72 }
73
74 header('Content-Type: application/vnd.ms-excel');
75 header('Content-Disposition: filename="' . $fileName . '.xls"');
76
77 echo $content;
78
79 die();
80 }
81}
global $APPLICATION
Определения include.php:80
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static get(Grid $grid, array $additionParams=[])
Определения componentparams.php:19
isExportRequest(?HttpRequest $request=null)
Определения excelexporter.php:19
getSettings()
Определения grid.php:122
const MODE_EXCEL
Определения settings.php:10
Определения uri.php:17
$content
Определения commerceml.php:144
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
Определения urlrewrite.php:61
Определения culture.php:9
$fileName
Определения quickway.php:305
die
Определения quickway.php:367