• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/grid/export/excelexporter.php
  • Класс: BitrixMainGridExportExcelExporter
  • Вызов: ExcelExporter::process
public function process(Grid $grid, string $fileName = 'export'): void
{
	global $APPLICATION;

	/**
	 * @var CMain $APPLICATION
	 */

	$APPLICATION->RestartBuffer();

	$grid->getSettings()->setMode(Settings::MODE_EXCEL);

	try
	{
		ob_start();
		$APPLICATION->IncludeComponent(
			'bitrix:main.ui.grid',
			'excel',
			ComponentParams::get($grid)
		);
		$content = ob_get_contents();
	}
	finally
	{
		ob_end_clean();
	}

	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: filename="' . $fileName . '.xls"');

	echo $content;

	die();
}