本文整理汇总了PHP中PHPExcel_Worksheet::setCellValueExplicit方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet::setCellValueExplicit方法的具体用法?PHP PHPExcel_Worksheet::setCellValueExplicit怎么用?PHP PHPExcel_Worksheet::setCellValueExplicit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet
的用法示例。
在下文中一共展示了PHPExcel_Worksheet::setCellValueExplicit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _readLabel
/**
* Read LABEL record
* This record represents a cell that contains a string. In
* BIFF8 it is usually replaced by the LABELSST record.
* Excel still uses this record, if it copies unformatted
* text cells to the clipboard.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readLabel()
{
$length = $this->_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = $this->_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to column
$column = $this->_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
if (!is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) {
// offset: 4; size: 2; XF index
$xfIndex = $this->_GetInt2d($recordData, 4);
// add cell value
// todo: what if string is very long? continue record
if ($this->_version == self::XLS_BIFF8) {
$string = $this->_readUnicodeStringLong(substr($recordData, 6));
$value = $string['value'];
} else {
$string = $this->_readByteStringLong(substr($recordData, 6));
$value = $string['value'];
}
$this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $value, PHPExcel_Cell_DataType::TYPE_STRING);
// add cell style
if (!$this->_readDataOnly) {
$this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
示例2: writeDCInvContent
/**
* Write the content of the "DC Inventory" worksheet
*
* @param PHPExcel_Worksheet $worksheet
* @param array $sheetProps properties of the worksheet
* @param array $invData array with the inventory data
*/
function writeDCInvContent($worksheet, $sheetProps, $invData)
{
$colIdx = $sheetProps['ColIdx'];
// first line is the header for the worksheet
$worksheet->fromArray($invData, null, 'A2');
ReportStats::get()->report('Info', 'Number of Inventory entries ' . count($invData));
$highestRow = count($invData);
foreach ($sheetProps['ExpStr'] as $colName) {
$colLetter = $colIdx[$colName][1];
for ($row = 0; $row < $highestRow; $row++) {
$worksheet->setCellValueExplicit($colLetter . ($row + 2), $invData[$row][$colName], PHPExcel_Cell_DataType::TYPE_STRING);
}
}
// unset($invData);
}
示例3: _set_row
/**
* Sets cells of a single row
*
* @param int $row
* @param mixed $cell_values
* @param boolean $header
* @return Worksheet
*/
private function _set_row($row, &$data, $header = FALSE)
{
$column = 0;
$format = NULL;
$type = PHPExcel_Cell_DataType::TYPE_STRING;
foreach ($this->columns as $key => $name) {
$value = NULL;
if (is_array($data)) {
$value = $data[$key];
} elseif (is_object($data)) {
if (method_exists($data, $key)) {
$value = $data->{$key}();
} elseif (isset($data->{$key})) {
$value = $data->{$key};
}
}
// Determine cell type and format
if ($header === FALSE) {
$type = Arr::get($this->types, $key);
}
// Set cell value
$coordinates = PHPExcel_Cell::stringFromColumnIndex($column) . $row;
if ($type !== NULL) {
$this->_worksheet->setCellValueExplicit($coordinates, $value, $type);
} else {
$this->_worksheet->setCellValue($coordinates, $value);
}
$column++;
}
return $this;
}
示例4: _set_row
/**
* Sets cells of a single row
*
* @param int $row
* @param mixed $cell_values
* @param boolean $header
* @return Worksheet
*/
private function _set_row($row, &$data, $header = FALSE)
{
$column = 0;
$type = PHPExcel_Cell_DataType::TYPE_STRING;
foreach (array_keys($this->columns) as $key) {
$value = NULL;
if (is_array($data)) {
$value = isset($data[$key]) ? $data[$key] : '';
} elseif (is_object($data)) {
if (method_exists($data, $key)) {
$value = $data->{$key}();
} elseif (isset($data->{$key})) {
$value = $data->{$key};
}
}
// Determine cell type and format
if ($header === FALSE) {
$type = Arr::get($this->types, $key);
}
$coordinates = PHPExcel_Cell::stringFromColumnIndex($column) . $row;
// Options
if (is_array($value)) {
$options = array_slice($value, 1);
$validation = $this->_worksheet->getCell($coordinates)->getDataValidation();
$validation->setType(PHPExcel_Cell_DataValidation::TYPE_LIST);
$validation->setAllowBlank(TRUE);
$validation->setShowDropDown(TRUE);
$validation->setFormula1('"' . join(',', $options) . '"');
$value = $value[0];
}
// Set cell value
if ($type !== NULL) {
$this->_worksheet->setCellValueExplicit($coordinates, $value, $type);
} else {
$this->_worksheet->setCellValue($coordinates, $value);
}
$column++;
}
return $this;
}