本文整理汇总了PHP中PHPExcel_Cell::setValueBinder方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Cell::setValueBinder方法的具体用法?PHP PHPExcel_Cell::setValueBinder怎么用?PHP PHPExcel_Cell::setValueBinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Cell
的用法示例。
在下文中一共展示了PHPExcel_Cell::setValueBinder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: format
/**
* Format a recordset
*
* @param Garp_Model $model
* @param array $rowset
* @return string
*/
public function format(Garp_Model $model, array $rowset)
{
$phpexcel = new PHPExcel();
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder());
// set metadata
$props = $phpexcel->getProperties();
if (Garp_Auth::getInstance()->isLoggedIn()) {
$userData = Garp_Auth::getInstance()->getUserData();
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
if ($bootstrap) {
$view = $bootstrap->getResource('view');
$userName = $view->fullName($userData);
$props->setCreator($userName)->setLastModifiedBy($userName);
}
}
$props->setTitle('Garp content export – ' . $model->getName());
if (count($rowset)) {
$this->_addContent($phpexcel, $model, $rowset);
}
/**
* Hm, PHPExcel seems to only be able to write to a file (instead of returning
* an XLS binary string). Therefore, we save a temporary file, read its contents
* and return those, after which we unlink the temp file.
*/
$tmpFileName = APPLICATION_PATH . '/data/logs/tmp.xls';
$writer = PHPExcel_IOFactory::createWriter($phpexcel, 'Excel5');
$writer->save($tmpFileName);
$contents = file_get_contents($tmpFileName);
unlink($tmpFileName);
return $contents;
}
示例2: __construct
public function __construct($config = array())
{
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder());
if (isset($config['cacheMethod'])) {
$this->_cacheMethod = $config['cacheMethod'];
}
$this->_setCache();
parent::__construct();
}
示例3: getTemplate
/**
* Return the template
* @param string $templateFileName
* @return PHPExcel
*/
protected function getTemplate($templateFileName)
{
$startTime = microtime(true);
require_once __DIR__ . '/PHPExcel/PHPExcel.php';
require_once __DIR__ . '/PHPExcel/PHPExcel/Cell/AdvancedValueBinder.php';
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder());
$this->logger->log(LOG_INFO, 'getTemplate()');
$this->logger->step(R3_PAES_READ_TEMPLATE, null, null);
$this->xls = PHPExcel_IOFactory::load($templateFileName);
$this->logger->log(LOG_INFO, sprintf('getTemplate() - Done [%.2fsec]', microtime(true) - $startTime));
}
示例4: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*
* @throws \Cake\Core\Exception\Exception
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
if (isset($viewOptions['name']) && $viewOptions['name'] == 'Error') {
$this->subDir = null;
$this->layoutPath = null;
$response->type('html');
return;
}
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$this->PhpExcel = new \PHPExcel();
}
示例5: file_to_obj_php_excel
function file_to_obj_php_excel($inputFileName)
{
$CI =& get_instance();
PHPExcel_Shared_File::setUseUploadTempDirectory(true);
if ($CI->config->item('spreadsheet_format') == 'XLSX') {
$objReader = new PHPExcel_Reader_Excel2007();
} else {
$objReader = new PHPExcel_Reader_CSV();
PHPExcel_Cell::setValueBinder(new TextValueBinder());
}
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($inputFileName);
return $objPHPExcel;
}
示例6: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*
* @throws \Cake\Core\Exception\Exception
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
if (isset($viewOptions['templatePath']) && $viewOptions['templatePath'] == 'Error') {
$this->layoutPath = null;
$this->subDir = null;
$response->type('html');
return;
}
// intitialize PHPExcel-Object
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$this->PHPExcel = new \PHPExcel();
$this->currentSheetIndex = 0;
}
示例7: prepareEntityData
/**
* reads a file PHPExcel can understand and converts a contained worksheet into an array
* which can be used to build entities. If the File contains more than one worksheet and it is not named like the Controller
* you have to provide the name of the workshhet to load in the options array.
* If you set $options['append'] to true, the primary key will be deleted.
* @todo Find a way to make to handle primary keys anmed other than id.
*
* @param string $file name of Excel-File with full path. Must be of a readable Filetype (xls, xlsx, csv, ods)
* @param array $options Override Worksheet name, set append Mode
* @return array . The Array has the same structure as provided by request->data
* @throws MissingTableClassException
*/
public function prepareEntityData($file = null, array $options = [])
{
/** load and configure PHPExcelReader * */
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$fileType = \PHPExcel_IOFactory::identify($file);
$PhpExcelReader = \PHPExcel_IOFactory::createReader($fileType);
$PhpExcelReader->setReadDataOnly(true);
if ($fileType !== 'CSV') {
// csv-files have only one 'worksheet'
/** identify worksheets in file * */
$worksheets = $PhpExcelReader->listWorksheetNames($file);
$worksheetToLoad = null;
if (count($worksheets) === 1) {
$worksheetToLoad = $worksheets[0];
//first option: if there is only one worksheet, use it
} elseif (isset($options['worksheet'])) {
$worksheetToLoad = $options['worksheet'];
//second option: desired worksheet was provided as option
} else {
$worksheetToLoad = $this->_registry->getController()->name;
//last option: try to load worksheet with the name of current controller
}
if (!in_array($worksheetToLoad, $worksheets)) {
throw new MissingTableClassException(__('No proper named worksheet found'));
}
/** load the sheet and convert data to an array */
$PhpExcelReader->setLoadSheetsOnly($worksheetToLoad);
}
$PhpExcel = $PhpExcelReader->load($file);
$data = $PhpExcel->getSheet(0)->toArray();
/** convert data for building entities */
$result = [];
$properties = array_shift($data);
//first row columns are the properties
foreach ($data as $row) {
$record = array_combine($properties, $row);
if (isset($record['modified'])) {
unset($record['modified']);
}
if (isset($options['type']) && $options['type'] == 'append' && isset($record['id'])) {
unset($record['id']);
}
$result[] = $record;
}
/** log in debug mode */
$this->log(count($result) . ' records were extracted from File ' . $file, 'debug');
return $result;
}
示例8: report
public function report($dates, $officials)
{
$results = new AvailReporterResults();
// For wrapping text
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$this->wb = $wb = new \PHPExcel();
$ws = $wb->getSheet();
$ws->setTitle('RefAvail');
$ws->getCell('A1')->setValue('Referee Name');
$ws->getCell('B1')->setValue('Referee Info');
$ws->getColumnDimension('A')->setWidth(20);
$ws->getColumnDimension('B')->setWidth(20);
$col = 'C';
foreach ($dates as $date) {
$dt = \DateTime::createFromFormat('Y-m-d', $date);
$ws->getCell($col . '1')->setValue($dt->format('D M d'));
$ws->getColumnDimension($col)->setWidth(25);
$col++;
}
$row = 2;
foreach ($officials as $official) {
$ws->getCell('A' . $row)->setValue($official['name']);
$info = sprintf("F: %s\n%s\n%s\nR: %s", $official['city'], $official['cell'], $official['home'], $official['rank']);
$ws->getCell('B' . $row)->setValue($info);
$col = 'C';
foreach ($dates as $date) {
$cr = $col . $row;
$avail = implode("\n", $official['avail'][$date]);
$ws->getCell($cr)->setValue($avail);
if ($avail === 'Blocked ALL DAY') {
$style = $ws->getStyle($cr);
$fill = $style->getFill();
$fill->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
$fill->getStartColor()->setARGB('FFFF6666');
}
if ($avail === 'Open All Day') {
$style = $ws->getStyle($cr);
$fill = $style->getFill();
$fill->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
$fill->getStartColor()->setARGB('FFCCFFCC');
}
$col++;
}
$row++;
}
$wb->setActiveSheetIndex(0);
return $results;
}
示例9: setData
/**
* Set data to active sheet.
*
* @param array $data
* @param array $title
* @param PHPExcel_Chart $charts
*/
public function setData($data, $title = array(), $charts = null)
{
if (!empty($title)) {
array_unshift($data, $title);
}
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_RCUPValueBinder());
$this->objPHPExcel->getActiveSheet()->fromArray($data);
if (!empty($charts)) {
if (!is_array($charts)) {
$charts = array($charts);
}
foreach ($charts as $chart) {
$this->objPHPExcel->getActiveSheet()->addChart($chart);
}
}
}
示例10: download
public function download($export_type, $offset = null, $rows = null, $min_id = null, $max_id = null)
{
// we use our own error handler
global $registry;
$registry = $this->registry;
set_error_handler('error_handler_for_export_import', E_ALL);
register_shutdown_function('fatal_error_shutdown_handler_for_export_import');
// Use the PHPExcel package from http://phpexcel.codeplex.com/
$cwd = getcwd();
chdir(DIR_SYSTEM . 'PHPExcel');
require_once 'Classes/PHPExcel.php';
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_ExportImportValueBinder());
chdir($cwd);
// find out whether all data is to be downloaded
$all = !isset($offset) && !isset($rows) && !isset($min_id) && !isset($max_id);
// Memory Optimization
if ($this->config->get('export_import_settings_use_export_cache')) {
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
$cacheSettings = array('memoryCacheSize' => '16MB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
}
try {
// set appropriate timeout limit
set_time_limit(1800);
$languages = $this->getLanguages();
$default_language_id = $this->getDefaultLanguageId();
// create a new workbook
$workbook = new PHPExcel();
// set some default styles
$workbook->getDefaultStyle()->getFont()->setName('Arial');
$workbook->getDefaultStyle()->getFont()->setSize(10);
//$workbook->getDefaultStyle()->getAlignment()->setIndent(0.5);
$workbook->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$workbook->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$workbook->getDefaultStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
// pre-define some commonly used styles
$box_format = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F0F0F0')));
$text_format = array('numberformat' => array('code' => PHPExcel_Style_NumberFormat::FORMAT_TEXT));
$price_format = array('numberformat' => array('code' => '######0.00'), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT));
$weight_format = array('numberformat' => array('code' => '##0.00'), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT));
// create the worksheets
$worksheet_index = 0;
switch ($export_type) {
case 'c':
// creating the Categories worksheet
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('Categories');
$this->populateCategoriesWorksheet($worksheet, $languages, $box_format, $text_format, $offset, $rows, $min_id, $max_id);
$worksheet->freezePaneByColumnAndRow(1, 2);
// creating the CategoryFilters worksheet
if ($this->existFilter()) {
$workbook->createSheet();
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('CategoryFilters');
$this->populateCategoryFiltersWorksheet($worksheet, $languages, $default_language_id, $box_format, $text_format, $min_id, $max_id);
$worksheet->freezePaneByColumnAndRow(1, 2);
}
break;
case 'p':
// creating the Products worksheet
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('Products');
$this->populateProductsWorksheet($worksheet, $languages, $default_language_id, $price_format, $box_format, $weight_format, $text_format, $offset, $rows, $min_id, $max_id);
$worksheet->freezePaneByColumnAndRow(1, 2);
// creating the AdditionalImages worksheet
$workbook->createSheet();
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('AdditionalImages');
$this->populateAdditionalImagesWorksheet($worksheet, $box_format, $text_format, $min_id, $max_id);
$worksheet->freezePaneByColumnAndRow(1, 2);
// creating the Specials worksheet
$workbook->createSheet();
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('Specials');
$this->populateSpecialsWorksheet($worksheet, $default_language_id, $price_format, $box_format, $text_format, $min_id, $max_id);
$worksheet->freezePaneByColumnAndRow(1, 2);
// creating the Discounts worksheet
$workbook->createSheet();
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('Discounts');
$this->populateDiscountsWorksheet($worksheet, $default_language_id, $price_format, $box_format, $text_format, $min_id, $max_id);
$worksheet->freezePaneByColumnAndRow(1, 2);
// creating the Rewards worksheet
$workbook->createSheet();
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('Rewards');
$this->populateRewardsWorksheet($worksheet, $default_language_id, $box_format, $text_format, $min_id, $max_id);
$worksheet->freezePaneByColumnAndRow(1, 2);
// creating the ProductOptions worksheet
$workbook->createSheet();
$workbook->setActiveSheetIndex($worksheet_index++);
$worksheet = $workbook->getActiveSheet();
$worksheet->setTitle('ProductOptions');
//.........这里部分代码省略.........
示例11: getPhpExcelObject
/**
* Returns an initialized PHPExcel object
*
* @return \PHPExcel
*/
private function getPhpExcelObject()
{
require_once ROOT . DS . 'vendor' . DS . 'phpoffice' . DS . 'phpexcel' . DS . 'Classes' . DS . 'PHPExcel.php';
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$objPHPExcel = new \PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
return $objPHPExcel;
}
示例12: change_xlsx
function change_xlsx($file, $docname, $leadData, $ddtype)
{
//@file_put_contents("now-wc.txt","point2:change_xlsx:".$docname,FILE_APPEND);
if (is_file('files/' . $docname)) {
unlink('files/' . $docname);
}
//if (!copy($file, 'files/'.$docname)) { } else {
if (!copy($file, $docname)) {
} else {
//продолжаем обработку
//работа с xlsx
ini_set('include_path', ini_get('include_path') . ';../PHPExcel-1.8/Classes/');
require_once './PHPExcel-1.8/Classes/PHPExcel.php';
require_once './PHPExcel-1.8/Classes/PHPExcel/Writer/Excel2007.php';
require_once './PHPExcel-1.8/Classes/PHPExcel/IOFactory.php';
require_once './PHPExcel-1.8/Classes/PHPExcel/Cell/AdvancedValueBinder.php';
require_once './PHPExcel-1.8/Classes/PHPExcel/Writer/IWriter.php';
$objPHPExcel = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$filenamestr = $docname;
//$filenamestr = "invoice1.xlsx";
$objPHPExcel = $objReader->load($filenamestr);
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder());
// Add some data
//insert row
//$objPHPExcel->getActiveSheet()->insertNewRowBefore(7, 2);
//объединить ячейки
//$objPHPExcel->getActiveSheet()->mergeCells('A18:E22');
$objPHPExcel->setActiveSheetIndex(0);
$dname = "";
if ($ddtype == 'tradeact') {
$dname = 'Акт';
} else {
$dname = 'Счет';
}
$strB11val = $dname . " №" . $leadData['ddnumber'] . ' от ' . $leadData['ddate'];
$objPHPExcel->getActiveSheet()->SetCellValue('B11', $strB11val);
$objPHPExcel->getActiveSheet()->SetCellValue('G17', "" . $leadData['recieve']);
$objPHPExcel->getActiveSheet()->SetCellValue('G19', "" . $leadData['recieve']);
$mainarr = explode("!-!", $leadData['alltoinvioce']);
$i = 0;
$inum = 22;
foreach ($mainarr as $elementarr) {
if ("" . $elementarr === "") {
} else {
$inum = 22 + $i;
$objPHPExcel->getActiveSheet()->insertNewRowBefore($inum, 1);
//1 row before22
$strB = 'B' . $inum;
$strBVal = "" . ($i + 1);
$strC = 'C' . $inum;
$strCVal = "" . $elementarr;
$strW = 'W' . $inum;
$strX = 'X' . $inum;
$strY = 'Y' . $inum;
$strZ = 'Z' . $inum;
$strAA = 'AA' . $inum;
$objPHPExcel->getActiveSheet()->SetCellValue($strB, $strBVal);
$objPHPExcel->getActiveSheet()->SetCellValue($strC, $strCVal);
$objPHPExcel->getActiveSheet()->SetCellValue($strX, '');
$objPHPExcel->getActiveSheet()->SetCellValue($strY, '');
$objPHPExcel->getActiveSheet()->SetCellValue($strZ, '');
$objPHPExcel->getActiveSheet()->SetCellValue($strAA, '');
//слипляем 2 строчки
$objPHPExcel->getActiveSheet()->mergeCells($strC . ':' . $strW);
$i++;
}
}
//стили таблички
$styleArray = array('borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FFFF0000'))));
$stylerange = 'B23:AA' . $i;
$objPHPExcel->getActiveSheet()->getStyle($stylerange)->applyFromArray($styleArray);
//стили таблички ===============
$inum = 22 + $i + 4;
$strB = 'B' . $inum;
$objPHPExcel->getActiveSheet()->SetCellValue($strB, 'Всего наименований ' . $i . ', на сумму');
$inum = 22 + $i + 5;
$strB = 'B' . $inum;
$objPHPExcel->getActiveSheet()->SetCellValue($strB, '');
// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle('invoice');
// Save Excel 2007 file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save("files/" . $docname);
unset($objPHPExcel);
unset($objReader);
if (is_file($docname)) {
unlink($docname);
}
}
}
示例13: setColWidth
public static function setColWidth(&$objPHPExcel, $width, $col, $sheet = 0)
{
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$objPHPExcel->setActiveSheetIndex($sheet)->getColumnDimension($col)->setWidth($width);
}
示例14: setValueBinder
/**
* function setValueBinder() = Set the 'default' value binder to be used by objects generated
* whose file handler was instantiated by this factory class
* Cyril Ogana - 2012-07-17
* @param string $binderName This is the name of the value binder to activate
* @return void
* @access public
*/
public function setValueBinder($binderName = 'default')
{
if (!is_string($binderName) || !array_key_exists($binderName, self::$valueBinders)) {
return false;
}
\PHPExcel_Cell::setValueBinder(new self::$valueBinders[$binderName]());
self::$valueBinder = $binderName;
//append binder name to static property
return true;
}
示例15: writeXlsx
/**
* Create sheet from query and dump named file to browser.
* @param $query the query.
*/
function writeXlsx($query)
{
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder());
$objPHPExcel = new PHPExcel();
if (!isset($this->rowParser)) {
$this->rowParser = new DefaultRowParser();
}
$objPHPExcel->getProperties()->setCreator($this->creator);
$objPHPExcel->getProperties()->setLastModifiedBy($this->author);
$objPHPExcel->getProperties()->setTitle($this->title);
$objPHPExcel->getProperties()->setSubject($this->subject);
$objPHPExcel->getProperties()->setDescription($this->description);
$objPHPExcel->getProperties()->setKeywords($this->keywords);
$objPHPExcel->getProperties()->setCategory($this->catagory);
global $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$resultSet = $this->dbConn->Execute($query);
if ($resultSet === false) {
die("<br>Cannot get spreadsheet data with <pre>" . $query . "</pre> reason " . $this->dbConn->ErrorMsg() . "<br>");
}
//echo $query;
//$colcount = $resultSet->FieldCount();
// start writing in 3rd row, top isf for title and link.
$row = 3;
$this->tableHeader = $this->rowParser->parseToTableHeader($resultSet);
$headCount = count($this->tableHeader);
$headerStyles = array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'rotation' => 0, 'color' => array('argb' => 'FFC0C0C0')));
for ($i = 0; $i < $headCount; $i++) {
$name = $this->tableHeader[$i];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, $row, $name);
$coor = XLSWriter::cellCoordinate($i, $row);
$objPHPExcel->getActiveSheet()->getStyle($coor)->applyFromArray($headerStyles);
}
$row++;
// get types
$this->columnTypes = $this->rowParser->parseTypes($resultSet);
$XlsTypes = array();
//error_log('there are ' . count($this->columnTypes) . ' types from db =' . print_r($this->columnTypes, true), 0);
for ($i = 0; $i < count($this->columnTypes); $i++) {
$ftype = PHPExcel_Cell_DataType::TYPE_NUMERIC;
//error_log("found type = {$this->columnTypes[$i]} for column {$i}", 0);
switch ($this->columnTypes[$i]) {
case 'char':
case 'bpchar':
case 'varchar':
case 'text':
case 'date':
$ftype = PHPExcel_Cell_DataType::TYPE_STRING;
break;
case 'int2':
case 'int4':
case 'int8':
case '_numeric':
case 'numeric':
case 'float8':
$ftype = PHPExcel_Cell_DataType::TYPE_NUMERIC;
break;
default:
$ftype = PHPExcel_Cell_DataType::TYPE_STRING;
break;
}
$XlsTypes[] = $ftype;
}
$cellStyleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'rotation' => 0, 'color' => array('argb' => 'FF0000')));
$oldValue = '';
if ($this->firstWeightColumn > 0) {
// add weights row
$this->weigthsRow = $row;
$coor = XLSWriter::cellCoordinate($this->firstWeightColumn - 1, $row);
$objPHPExcel->getActiveSheet()->setCellValue($coor, 'Weights', PHPExcel_Cell_DataType::TYPE_STRING);
$objPHPExcel->getActiveSheet()->getStyle($coor)->applyFromArray($headerStyles);
$weightSum = 0;
$w = 0;
${$weightLast} = count($this->weights) - 1;
for (; $w < count($this->weights); $w++) {
$coor = XLSWriter::cellCoordinate($this->firstWeightColumn + $w, $row);
$weightSum += $this->weights[$w];
$objPHPExcel->getActiveSheet()->setCellValue($coor, $this->weights[$w], PHPExcel_Cell_DataType::TYPE_NUMERIC);
$objPHPExcel->getActiveSheet()->getStyle($coor)->applyFromArray($headerStyles);
}
$coor = XLSWriter::cellCoordinate($this->weightedSumsColumn, $row);
$wBegin = XLSWriter::cellCoordinate($this->firstWeightColumn, $row);
$wEnd = XLSWriter::cellCoordinate($this->firstWeightColumn + ${$weightLast}, $row);
$formula = "=SUM({$wBegin}:{$wEnd})";
$objPHPExcel->getActiveSheet()->setCellValue($coor, $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
$objPHPExcel->getActiveSheet()->getStyle($coor)->applyFromArray($headerStyles);
$coor = XLSWriter::cellCoordinate($this->weightedSumsColumn, $row - 1);
$objPHPExcel->getActiveSheet()->setCellValue($coor, 'Total WT', PHPExcel_Cell_DataType::TYPE_STRING);
$objPHPExcel->getActiveSheet()->getStyle($coor)->applyFromArray($headerStyles);
$row++;
}
while (!$resultSet->EOF) {
$rowData = $this->rowParser->parse($resultSet);
$headCount = count($this->tableHeader);
//$resultSet->FieldCount();
$changeColor = false;
//.........这里部分代码省略.........