<?php /** * Example page for how to use the Excel Writer XML * @package ExcelWriterXML * @subpackage examples * @filesource */ /** * Include the required Class file */ include ('ExcelWriterXML.php'); /** * @source */ $xml = new ExcelWriterXML (); $xml->docAuthor ( 'Robert F Greer' ); $format = $xml->addStyle ( 'StyleHeader' ); $format->fontBold (); $format->alignRotate ( 45 ); $sheet = $xml->addSheet ( 'My Sheet' ); $sheet->writeString ( 1, 1, 'Header', 'StyleHeader' ); $sheet->writeString ( 2, 1, 'Test String', 'StyleHeader' ); $xml->sendHeaders (); $xml->writeData (); ?>
public final function exportdata($sql = ' select \'测试成功\' ', $titles = array('测试导出'), $sheetname = '导出') { require BASE_PATH . '/include/ExcelWriterXML.php'; $xml = new ExcelWriterXML($sheetname . '.xls'); $xml->docAuthor('hcsoft'); $format = $xml->addStyle('StyleHeader'); $format->fontBold(); $format->alignRotate(45); $sheet = $xml->addSheet($sheetname); foreach ($titles as $i => $v) { $sheet->writeString(1, $i + 1, $v); } $conn = (require BASE_DATA_PATH . '/../core/framework/db/mssqlpdo.php'); //查询sql try { $stmt = $conn->query($sql); $rowindex = 2; while ($row = $stmt->fetch(PDO::FETCH_NUM)) { foreach ($row as $i => $v) { $sheet->writeString($rowindex, $i + 1, strval($v)); } $rowindex = $rowindex + 1; } } catch (Exception $e) { $sheet->writeString(2, 1, '导出异常!请与系统管理员联系!异常信息:' + $e->getMessage()); } $xml->sendHeaders(); $xml->writeData(); die; }
* Add some general properties to the document */ $xml->docTitle ( 'My Demo Doc' ); $xml->docAuthor ( 'Robert F Greer' ); $xml->docCompany ( 'Greers.Org' ); $xml->docManager ( 'Wife' ); /** * Choose to show any formatting/input errors on a seperate sheet */ $xml->showErrorSheet ( true ); /** * Show the style options */ $format1 = $xml->addStyle ( 'left_rotate60_big' ); $format1->alignRotate ( 60 ); $format1->alignHorizontal ( 'Left' ); $format1->fontSize ( '18' ); $format2 = $xml->addStyle ( 'verticaltext_left' ); $format2->alignVerticaltext ( 45 ); $format2->alignHorizontal ( 'Left' ); $format3 = $xml->addStyle ( 'wraptext_top' ); $format3->alignWraptext (); $format3->alignVertical ( 'Top' ); /** * Create a new sheet with the XML document */
if ($result['crontab_postback']) { $global_notifications[] = 'CRONTAB_POSTBACK_NOT_INSTALLED'; } if ($result['api_connect']) { $global_notifications[] = 'API_CONNECT_ERROR'; } $global_ntf_cnt = count($global_notifications); } if ($_REQUEST['export'] == 1) { $arr_currencies_list = get_active_currencies(); $selected_currency = current($arr_currencies_list); $arr_report_data = prepare_report('main-report', $_REQUEST + array('report_params' => array('act' => 'reports'))); if ($_REQUEST['export'] == 1) { require_once _TRACK_SHOW_COMMON_PATH . '/lib/excel_writer/ExcelWriterXML.php'; $xml = new ExcelWriterXML('report.xls'); $boldFormat = $xml->addStyle('StyleHeader'); $boldFormat->fontBold(); $sheet = $xml->addSheet('Report'); $sheet->cellWidth(1, 1, 100); $sheet->writeString(1, 1, 'Значение', 'StyleHeader'); $sheet->writeString(1, 2, 'Переходов', 'StyleHeader'); $sheet->writeString(1, 3, 'Действий', 'StyleHeader'); $sheet->writeString(1, 4, 'Продаж', 'StyleHeader'); $sheet->writeString(1, 5, 'Лидов', 'StyleHeader'); $sheet->writeString(1, 6, 'Конверсия в действия', 'StyleHeader'); $sheet->writeString(1, 7, 'Конверсия в продажи', 'StyleHeader'); $sheet->writeString(1, 8, 'Конверсия в лиды', 'StyleHeader'); $sheet->writeString(1, 9, 'Затраты', 'StyleHeader'); $sheet->writeString(1, 10, 'Прибыль', 'StyleHeader'); $sheet->writeString(1, 11, 'EPC', 'StyleHeader'); $sheet->writeString(1, 12, 'ROI', 'StyleHeader');