本文整理汇总了PHP中PHPExcel_Shared_XMLWriter::writeRawData方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Shared_XMLWriter::writeRawData方法的具体用法?PHP PHPExcel_Shared_XMLWriter::writeRawData怎么用?PHP PHPExcel_Shared_XMLWriter::writeRawData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Shared_XMLWriter
的用法示例。
在下文中一共展示了PHPExcel_Shared_XMLWriter::writeRawData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _writeBubbles
/**
* Write Bubble Chart Details
*
* @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @throws PHPExcel_Writer_Exception
*/
private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet)
{
if (is_null($plotSeriesValues)) {
return;
}
$objWriter->startElement('c:bubbleSize');
$objWriter->startElement('c:numLit');
$objWriter->startElement('c:formatCode');
$objWriter->writeRawData('General');
$objWriter->endElement();
$objWriter->startElement('c:ptCount');
$objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
$objWriter->endElement();
$dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) {
if (is_array($dataValues)) {
foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $plotSeriesKey);
$objWriter->startElement('c:v');
$objWriter->writeRawData(1);
$objWriter->endElement();
$objWriter->endElement();
}
}
}
$objWriter->endElement();
$objWriter->endElement();
$objWriter->startElement('c:bubble3D');
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
}
示例2: _writeDefinedNameForPrintArea
/**
* Write Defined Name for PrintTitles
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Worksheet $pSheet
* @param int $pSheetId
* @throws PHPExcel_Writer_Exception
*/
private function _writeDefinedNameForPrintArea(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
{
// definedName for PrintArea
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
$objWriter->startElement('definedName');
$objWriter->writeAttribute('name', '_xlnm.Print_Area');
$objWriter->writeAttribute('localSheetId', $pSheetId);
// Setting string
$settingString = '';
// Print area
$printArea = PHPExcel_Cell::splitRange($pSheet->getPageSetup()->getPrintArea());
$chunks = array();
foreach ($printArea as $printAreaRect) {
$printAreaRect[0] = PHPExcel_Cell::absoluteReference($printAreaRect[0]);
$printAreaRect[1] = PHPExcel_Cell::absoluteReference($printAreaRect[1]);
$chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect);
}
$objWriter->writeRawData(implode(',', $chunks));
$objWriter->endElement();
}
}
示例3: writeRichTextForCharts
/**
* Write Rich Text
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param string|PHPExcel_RichText $pRichText text string or Rich text
* @param string $prefix Optional Namespace prefix
* @throws PHPExcel_Writer_Exception
*/
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix = null)
{
if (!$pRichText instanceof PHPExcel_RichText) {
$textRun = $pRichText;
$pRichText = new PHPExcel_RichText();
$pRichText->createTextRun($textRun);
}
if ($prefix !== null) {
$prefix .= ':';
}
// Loop through rich text elements
$elements = $pRichText->getRichTextElements();
foreach ($elements as $element) {
// r
$objWriter->startElement($prefix . 'r');
// rPr
$objWriter->startElement($prefix . 'rPr');
// Bold
$objWriter->writeAttribute('b', $element->getFont()->getBold() ? 1 : 0);
// Italic
$objWriter->writeAttribute('i', $element->getFont()->getItalic() ? 1 : 0);
// Underline
$underlineType = $element->getFont()->getUnderline();
switch ($underlineType) {
case 'single':
$underlineType = 'sng';
break;
case 'double':
$underlineType = 'dbl';
break;
}
$objWriter->writeAttribute('u', $underlineType);
// Strikethrough
$objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike');
// rFont
$objWriter->startElement($prefix . 'latin');
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
$objWriter->endElement();
// Superscript / subscript
// if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
// $objWriter->startElement($prefix.'vertAlign');
// if ($element->getFont()->getSuperScript()) {
// $objWriter->writeAttribute('val', 'superscript');
// } elseif ($element->getFont()->getSubScript()) {
// $objWriter->writeAttribute('val', 'subscript');
// }
// $objWriter->endElement();
// }
//
$objWriter->endElement();
// t
$objWriter->startElement($prefix . 't');
// $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
$objWriter->endElement();
$objWriter->endElement();
}
}
示例4: writeDocPropsCustom
/**
* Write docProps/custom.xml to XML format
*
* @param PHPExcel $pPHPExcel
*
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function writeDocPropsCustom(PHPExcel $pPHPExcel = null)
{
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
if (empty($customPropertyList)) {
return;
}
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// cp:coreProperties
$objWriter->startElement('Properties');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
foreach ($customPropertyList as $key => $customProperty) {
$propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
$propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);
$objWriter->startElement('property');
$objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
$objWriter->writeAttribute('pid', $key + 2);
$objWriter->writeAttribute('name', $customProperty);
switch ($propertyType) {
case 'i':
$objWriter->writeElement('vt:i4', $propertyValue);
break;
case 'f':
$objWriter->writeElement('vt:r8', $propertyValue);
break;
case 'b':
$objWriter->writeElement('vt:bool', $propertyValue ? 'true' : 'false');
break;
case 'd':
$objWriter->startElement('vt:filetime');
$objWriter->writeRawData(date(DATE_W3C, $propertyValue));
$objWriter->endElement();
break;
default:
$objWriter->writeElement('vt:lpwstr', $propertyValue);
break;
}
$objWriter->endElement();
}
$objWriter->endElement();
// Return
return $objWriter->getData();
}
示例5: _writeCatAx
/**
* Write Category Axis
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Chart_PlotArea $plotArea
* @param PHPExcel_Chart_Title $xAxisLabel
* @param string $groupType Chart type
* @param string $id1
* @param string $id2
* @param boolean $isMultiLevelSeries
*
* @throws PHPExcel_Writer_Exception
*/
private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries)
{
$objWriter->startElement('c:catAx');
if ($id1 > 0) {
$objWriter->startElement('c:axId');
$objWriter->writeAttribute('val', $id1);
$objWriter->endElement();
}
$objWriter->startElement('c:scaling');
$objWriter->startElement('c:orientation');
$objWriter->writeAttribute('val', "minMax");
$objWriter->endElement();
$objWriter->endElement();
$objWriter->startElement('c:delete');
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
$objWriter->startElement('c:axPos');
$objWriter->writeAttribute('val', "b");
$objWriter->endElement();
if (!is_null($xAxisLabel)) {
$objWriter->startElement('c:title');
$objWriter->startElement('c:tx');
$objWriter->startElement('c:rich');
$objWriter->startElement('a:bodyPr');
$objWriter->endElement();
$objWriter->startElement('a:lstStyle');
$objWriter->endElement();
$objWriter->startElement('a:p');
$objWriter->startElement('a:r');
$caption = $xAxisLabel->getCaption();
if (is_array($caption)) {
$caption = $caption[0];
}
$objWriter->startElement('a:t');
// $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption));
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
$layout = $xAxisLabel->getLayout();
$this->_writeLayout($layout, $objWriter);
$objWriter->startElement('c:overlay');
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
$objWriter->endElement();
}
$objWriter->startElement('c:numFmt');
$objWriter->writeAttribute('formatCode', "General");
$objWriter->writeAttribute('sourceLinked', 1);
$objWriter->endElement();
$objWriter->startElement('c:majorTickMark');
$objWriter->writeAttribute('val', "out");
$objWriter->endElement();
$objWriter->startElement('c:minorTickMark');
$objWriter->writeAttribute('val', "none");
$objWriter->endElement();
$objWriter->startElement('c:tickLblPos');
$objWriter->writeAttribute('val', "nextTo");
$objWriter->endElement();
if ($id2 > 0) {
$objWriter->startElement('c:crossAx');
$objWriter->writeAttribute('val', $id2);
$objWriter->endElement();
$objWriter->startElement('c:crosses');
$objWriter->writeAttribute('val', "autoZero");
$objWriter->endElement();
}
$objWriter->startElement('c:auto');
$objWriter->writeAttribute('val', 1);
$objWriter->endElement();
$objWriter->startElement('c:lblAlgn');
$objWriter->writeAttribute('val', "ctr");
$objWriter->endElement();
$objWriter->startElement('c:lblOffset');
$objWriter->writeAttribute('val', 100);
$objWriter->endElement();
if ($isMultiLevelSeries) {
$objWriter->startElement('c:noMultiLvlLbl');
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
}
$objWriter->endElement();
}
示例6: writeRichText
/**
* Write Rich Text
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_RichText $pRichText Rich text
* @throws Exception
*/
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null)
{
// Loop through rich text elements
$elements = $pRichText->getRichTextElements();
foreach ($elements as $element) {
// r
$objWriter->startElement('r');
// rPr
if ($element instanceof PHPExcel_RichText_Run) {
// rPr
$objWriter->startElement('rPr');
// rFont
$objWriter->startElement('rFont');
$objWriter->writeAttribute('val', $element->getFont()->getName());
$objWriter->endElement();
// Bold
$objWriter->startElement('b');
$objWriter->writeAttribute('val', $element->getFont()->getBold() ? 'true' : 'false');
$objWriter->endElement();
// Italic
$objWriter->startElement('i');
$objWriter->writeAttribute('val', $element->getFont()->getItalic() ? 'true' : 'false');
$objWriter->endElement();
// Superscript / subscript
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
$objWriter->startElement('vertAlign');
if ($element->getFont()->getSuperScript()) {
$objWriter->writeAttribute('val', 'superscript');
} else {
if ($element->getFont()->getSubScript()) {
$objWriter->writeAttribute('val', 'subscript');
}
}
$objWriter->endElement();
}
// Strikethrough
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', $element->getFont()->getStrikethrough() ? 'true' : 'false');
$objWriter->endElement();
// Color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
$objWriter->endElement();
// Size
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', $element->getFont()->getSize());
$objWriter->endElement();
// Underline
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $element->getFont()->getUnderline());
$objWriter->endElement();
$objWriter->endElement();
}
// t
$objWriter->startElement('t');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
$objWriter->endElement();
$objWriter->endElement();
}
}
示例7: _writeBubbles
/**
* Write Bubble Chart Details
*
* @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @throws Exception
*/
private function _writeBubbles($plotSeriesValues, $objWriter)
{
if (is_null($plotSeriesValues)) {
return;
}
$objWriter->startElement('c:bubbleSize');
$objWriter->startElement('c:numLit');
$objWriter->startElement('c:formatCode');
$objWriter->writeRawData('General');
$objWriter->endElement();
$objWriter->startElement('c:ptCount');
$objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
$objWriter->endElement();
foreach ($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $plotSeriesKey);
$objWriter->startElement('c:v');
$objWriter->writeRawData(1);
$objWriter->endElement();
$objWriter->endElement();
}
$objWriter->endElement();
$objWriter->endElement();
$objWriter->startElement('c:bubble3D');
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
}