本文整理汇总了PHP中PHPExcel_Worksheet_Drawing::setOffsetY方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet_Drawing::setOffsetY方法的具体用法?PHP PHPExcel_Worksheet_Drawing::setOffsetY怎么用?PHP PHPExcel_Worksheet_Drawing::setOffsetY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Worksheet_Drawing
的用法示例。
在下文中一共展示了PHPExcel_Worksheet_Drawing::setOffsetY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExportExcelRecord
function ExportExcelRecord($arrdata, $datatype, $numberRow, $objPHPExcel, $pageObj)
{
global $cCharset, $locale_info;
$col = -1;
$objASIndex = $objPHPExcel->setActiveSheetIndex(0);
$objASheet = $objPHPExcel->getActiveSheet();
$rowDim = $objASIndex->getRowDimension($numberRow + 1);
foreach ($arrdata as $field => $data) {
$col++;
$colLetter = PHPExcel_Cell::stringFromColumnIndex($col);
$colDim = $objASIndex->getColumnDimension($colLetter);
if ($datatype[$field] == "binary") {
if (!$data) {
continue;
}
if (!function_exists("imagecreatefromstring")) {
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, "LONG BINARY DATA - CANNOT BE DISPLAYED");
continue;
}
$error_handler = set_error_handler("empty_error_handler");
$gdImage = imagecreatefromstring($data);
if ($error_handler) {
set_error_handler($error_handler);
}
if ($gdImage) {
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setImageResource($gdImage);
$objDrawing->setCoordinates($colLetter . ($row + 1));
$objDrawing->setWorksheet($objASheet);
$width = $objDrawing->getWidth() * 0.143;
$height = $objDrawing->getHeight() * 0.75;
if ($rowDim->getRowHeight() < $height) {
$rowDim->setRowHeight($height);
}
$colDimSh = $objASheet->getColumnDimension($colLetter);
$colDimSh->setAutoSize(false);
if ($colDim->getWidth() < $width) {
$colDim->setWidth($width);
}
}
} elseif ($datatype[$field] == "file") {
$arr = my_json_decode($row[$field]);
if (count($arr) == 0) {
$data = PHPExcel_Shared_String::ConvertEncoding($data, 'UTF-8', $cCharset);
if ($data == "<img src=\"images/no_image.gif\" />") {
$arr[] = array("name" => "images/no_image.gif");
} else {
if (substr($data, 0, 1) == '=') {
$data = '="' . str_replace('"', '""', $data) . '"';
}
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, $data);
continue;
}
}
$offsetY = 0;
$height = 0;
foreach ($arr as $img) {
if (!file_exists($img["name"]) || !$img["name"]) {
$data = PHPExcel_Shared_String::ConvertEncoding($data, 'UTF-8', $cCharset);
if (substr($data, 0, 1) == '=') {
$data = '="' . str_replace('"', '""', $data) . '"';
}
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, $data);
continue;
}
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setPath($img["name"]);
$objDrawing->setCoordinates($colLetter . ($numberRow + 1));
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objDrawing->setOffsetY($offsetY);
$width = $objDrawing->getWidth() * 0.143;
$height = $height + $objDrawing->getHeight() * 0.75;
$offsetY = $offsetY + $objDrawing->getHeight();
if ($rowDim->getRowHeight() < $height) {
$rowDim->setRowHeight($height);
}
$colDimSh = $objASheet->getColumnDimension($colLetter);
$colDimSh->setAutoSize(false);
if ($colDim->getWidth() < $width) {
$colDim->setWidth($width);
}
}
} else {
$data = PHPExcel_Shared_String::ConvertEncoding($data, 'UTF-8', $cCharset);
if (substr($data, 0, 1) == '=') {
$data = '="' . str_replace('"', '""', $data) . '"';
}
$objASIndex->setCellValueByColumnAndRow($col, $numberRow + 1, $data);
if ($datatype[$field] == "date") {
$objStyle = $objASIndex->getStyle($colLetter . ($numberRow + 1));
$objNumFrm = $objStyle->getNumberFormat();
$objNumFrm->setFormatCode($locale_info["LOCALE_SSHORTDATE"] . " hh:mm:ss");
}
}
}
}
示例2: load
//.........这里部分代码省略.........
$relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels' )); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsVML->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$drawings[(string) $ele["Id"]] = self::dir_add($vmlRelationship, $ele["Target"]);
}
}
// Fetch VML document
$vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship));
$vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$hfImages = array();
$shapes = $vmlDrawing->xpath('//v:shape');
foreach ($shapes as $shape) {
$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$imageData = $shape->xpath('//v:imagedata');
$imageData = $imageData[0];
$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
$style = self::toCSSArray( (string)$shape['style'] );
$hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing();
if (isset($imageData['title'])) {
$hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );
}
$hfImages[ (string)$shape['id'] ]->setPath("zip://$pFilename#" . $drawings[(string)$imageData['relid']], false);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
$hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
$hfImages[ (string)$shape['id'] ]->setHeight($style['height']);
$hfImages[ (string)$shape['id'] ]->setOffsetX($style['margin-left']);
$hfImages[ (string)$shape['id'] ]->setOffsetY($style['margin-top']);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(true);
}
$docSheet->getHeaderFooter()->setImages($hfImages);
}
}
}
}
// ----: Make sure drawings and graph are loaded differently!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
$drawings[(string) $ele["Id"]] = self::dir_add("$dir/$fileWorksheet", $ele["Target"]);
}
}
if ($xmlSheet->drawing && !$this->_readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) {
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$images = array();
if ($relsDrawing && $relsDrawing->Relationship) {
foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);
}
}
}
示例3: addImage
function addImage($objPHPExcel)
{
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objDrawing->setName("name");
$objDrawing->setDescription("Description");
// $objDrawing->setPath('../img/logo-set1.png');
$objDrawing->setPath('../img/LogoBSW.png');
$objDrawing->setCoordinates('A1');
$objDrawing->setOffsetX(5);
$objDrawing->setWidth(115);
$objDrawing->setOffsetY(5);
}
示例4: getTeaserImage
private function getTeaserImage(Teasers $teaser)
{
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName($teaser->title);
$path = Yii::app()->params->imageBasePath . DIRECTORY_SEPARATOR . $teaser->picture;
if (!file_exists($path)) {
$path = $path = Yii::app()->params->imageBasePath . DIRECTORY_SEPARATOR . 'notfound.png';
}
$objDrawing->setPath($path);
$objDrawing->setWidthAndHeight(95, 95);
$objDrawing->setOffsetX(10);
$objDrawing->setOffsetY(2);
return $objDrawing;
}
示例5: _excel_add_image
private function _excel_add_image($sheet, $image, &$i)
{
if (!(string) $image) {
return --$i ? '' : '';
}
download_web_file($image->url('350x230p'), $filepath = FCPATH . implode(DIRECTORY_SEPARATOR, array_merge(Cfg::system('orm_uploader', 'uploader', 'temp_directory'), array((string) $image))));
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setPath($filepath);
$j = $j = (ceil($i / 3) - 1) * 7 + 1;
$objDrawing->setCoordinates(($i % 3 < 2 ? $i % 3 < 1 ? 'G' : 'A' : 'D') . $j);
$objDrawing->setOffsetX(20);
$objDrawing->setOffsetY(8);
$objDrawing->setWidth(175);
$objDrawing->setWorksheet($sheet);
return $filepath;
}
示例6: postAction
//.........这里部分代码省略.........
if (++$counter_test < 30000) {
$product->load($productId);
$style_number = str_replace('"', '', $product->getSku());
$image_link = $product->getImage();
$description = htmlspecialchars(iconv("UTF-8", "UTF-8//IGNORE", $product->getDescription()));
$product->setCustomerGroupId(2);
$wholesale = number_format($product->getPriceModel()->getFinalPrice(1, $product), 2);
$price_temp = round($product->getPrice(), 2);
$price = round($product->getPrice(), 2);
$special_price = number_format($product->getSpecialPrice(), 2);
$qty = $product->getStockItem()->getQty();
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(190);
//Infromation 1
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $style_number);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getAlignment()->setIndent(9);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('000000');
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i . ':G' . $i)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i . ':G' . $i)->getFill()->getStartColor()->setARGB('FFFFFF');
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->applyFromArray($styleThinBlackBorderOutline);
//Extra Block
$objPHPExcel->getActiveSheet()->getStyle('D' . $i)->applyFromArray($styleThinBlackBorderOutline);
$objPHPExcel->getActiveSheet()->getStyle('E' . $i)->applyFromArray($styleThinBlackBorderOutline);
$objPHPExcel->getActiveSheet()->getStyle('F' . $i)->applyFromArray($styleThinBlackBorderOutline);
$objPHPExcel->getActiveSheet()->getStyle('G' . $i)->applyFromArray($styleThinBlackBorderOutline);
//2
$objPHPExcel->getActiveSheet()->getStyle('B' . $i)->applyFromArray($styleThinBlackBorderOutline);
$objDrawing = new PHPExcel_Worksheet_Drawing();
if (file_exists('./media/catalog/product' . $image_link)) {
if ($product->getImage() == 'no_selection') {
$objDrawing->setPath('./images/logo.png');
$objDrawing->setOffsetX(5);
$objDrawing->setOffsetY(50);
} else {
$objDrawing->setPath('./media/catalog/product' . $image_link);
$objDrawing->setOffsetX(5);
$objDrawing->setOffsetY(5);
}
} else {
$objDrawing->setPath('./images/logo.png');
$objDrawing->setOffsetX(5);
$objDrawing->setOffsetY(50);
}
$objDrawing->setCoordinates('B' . $i);
//$objDrawing->setHeight(190);
//$objDrawing->setWidth(340);
$objDrawing->setResizeProportional(true);
$objDrawing->setWidthAndHeight(340, 210);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//3 Cell
$objPHPExcel->getActiveSheet()->getStyle('C' . $i)->applyFromArray($styleThinBlackBorderOutline);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $description);
$objPHPExcel->getActiveSheet()->getStyle('C' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C' . $i)->getFont()->setName('Arial')->setSize(10)->getColor()->setRGB('000000');
$objPHPExcel->getActiveSheet()->getStyle('C' . $i)->getFont()->setBold(true);
//4 Cell
$objPHPExcel->getActiveSheet()->getStyle('D' . $i)->applyFromArray($styleThinBlackBorderOutline);
if ($price_temp == '0') {
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, '');
} else {
$objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getNumberFormat()->applyFromArray(array('code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD));
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $price_temp);
}
$objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getAlignment()->setIndent(9);
示例7: exportExcel
public function exportExcel($conf = array())
{
$data = $conf['data'];
$name = $conf['filename'] . '-' . date('Y-m-d H-i-s');
$field = explode(',', $conf['field'][0]);
$fieldtitle = explode(',', $conf['field'][1]);
$objPHPExcel = new \PHPExcel();
//以下是一些设置 ,什么作者 标题啊之类的
$objPHPExcel->getProperties()->setCreator("ainiku")->setLastModifiedBy("ainiku")->setTitle("feilv export")->setSubject("feilv export")->setDescription("bakdata")->setKeywords("excel")->setCategory("result file");
//设置表头
$obj = $objPHPExcel->setActiveSheetIndex(0);
$fieldnum = count($fieldtitle);
$j = 65;
foreach ($fieldtitle as $v) {
//
$obj->setCellValue(chr($j++) . '1', ' ' . $v);
}
//Set border colors 设置边框颜色
//$obj->freezePane(chr(65).'1:'.chr($j).'1');
$objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getLeft()->getColor()->setARGB('FF993300');
$objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getTop()->getColor()->setARGB('FF993300');
$objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getBottom()->getColor()->setARGB('FF993300');
$objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getRight()->getColor()->setARGB('FF993300');
//Set border colors 设置背景颜色
//$objPHPExcel->getActiveSheet()->getStyle(chr(65).'1:'.chr($j).'1')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
//$objPHPExcel->getActiveSheet()->getStyle(chr(65).'1:'.chr($j).'1')->getFill()->getStartColor()->setARGB('FFededed');
//以下就是对处理Excel里的数据, 横着取数据,主要是这一步,其他基本都不要改
// 固定第一行
$obj->freezePane('A1');
$fieldnum = count($field);
foreach ($data as $k => $v) {
$num = $k + 2;
$temfield = $field;
$j = 'A';
$i = 0;
//$obj=$objPHPExcel->setActiveSheetIndex(0);
for ($i; $i < $fieldnum; $i++) {
$temstr = array_shift($temfield);
if (substr($temstr, 0, 1) == "'") {
$temstr = str_replace("'", '', $temstr);
$obj->setCellValue($j . $num, ' ' . $v[$temstr]);
} else {
if (substr($temstr, 0, 5) == "#pic#") {
//插入图片
$temstr = str_replace("#pic#", '', $temstr);
$img = new \PHPExcel_Worksheet_Drawing();
$img->setPath($v[$temstr]);
//写入图片路径
$img->setHeight(100);
//写入图片高度
$img->setWidth(100);
//写入图片宽度
$img->setOffsetX(1);
//写入图片在指定格中的X坐标值
$img->setOffsetY(1);
//写入图片在指定格中的Y坐标值
$img->setRotation(1);
//设置旋转角度
$img->getShadow()->setVisible(true);
//
$img->getShadow()->setDirection(50);
//
$img->setCoordinates($j . $num);
//设置图片所在表格位置
//$objPHPExcel->getColumnDimension("$letter[$i]")->setWidth(20);
$obj->getDefaultRowDimension()->setRowHeight(100);
$img->setWorksheet($obj);
//把图片写到当前的表格中
//$objActSheet->getCell('E26')->getHyperlink()->setUrl( 'http://www.phpexcel.net'); //超链接url地址
//$objActSheet->getCell('E26')->getHyperlink()->setTooltip( 'Navigate to website'); //鼠标移上去连接提示信息
//$obj->setCellValue($j.$num, $img);
} else {
if (substr($temstr, 0, 6) == "#link#") {
$temstr = str_replace("#link#", '', $temstr);
$obj->setCellValue($j . $num, $v[$temstr]);
$obj->getCell($j . $num)->getHyperlink()->setUrl($v[$temstr]);
//超链接url地址
$obj->getCell($j . $num)->getHyperlink()->setTooltip($v[$temstr]);
//鼠标移上去连接提
} else {
$obj->setCellValue($j . $num, $v[$temstr]);
}
}
}
$j++;
}
}
$objPHPExcel->getActiveSheet()->setTitle('User');
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $name . '.xls"');
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
示例8: load
//.........这里部分代码省略.........
$vmlRelationship = self::dir_add("{$dir}/{$fileWorksheet}", $ele["Target"]);
}
}
if ($vmlRelationship != '') {
// Fetch linked images
$relsVML = simplexml_load_string($zip->getFromName(dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels'));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsVML->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$drawings[(string) $ele["Id"]] = self::dir_add($vmlRelationship, $ele["Target"]);
}
}
// Fetch VML document
$vmlDrawing = simplexml_load_string($zip->getFromName($vmlRelationship));
$vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$hfImages = array();
$shapes = $vmlDrawing->xpath('//v:shape');
foreach ($shapes as $shape) {
$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$imageData = $shape->xpath('//v:imagedata');
$imageData = $imageData[0];
$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
$style = self::toCSSArray((string) $shape['style']);
$hfImages[(string) $shape['id']] = new PHPExcel_Worksheet_HeaderFooterDrawing();
if (isset($imageData['title'])) {
$hfImages[(string) $shape['id']]->setName((string) $imageData['title']);
}
$hfImages[(string) $shape['id']]->setPath("zip://{$pFilename}#" . $drawings[(string) $imageData['relid']], false);
$hfImages[(string) $shape['id']]->setResizeProportional(false);
$hfImages[(string) $shape['id']]->setWidth($style['width']);
$hfImages[(string) $shape['id']]->setHeight($style['height']);
$hfImages[(string) $shape['id']]->setOffsetX($style['margin-left']);
$hfImages[(string) $shape['id']]->setOffsetY($style['margin-top']);
$hfImages[(string) $shape['id']]->setResizeProportional(true);
}
$docSheet->getHeaderFooter()->setImages($hfImages);
}
}
}
}
// TODO: Make sure drawings and graph are loaded differently!
if ($zip->locateName(dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($zip->getFromName(dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels"));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
$drawings[(string) $ele["Id"]] = self::dir_add("{$dir}/{$fileWorksheet}", $ele["Target"]);
}
}
if ($xmlSheet->drawing && !$this->_readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) {
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($zip->getFromName(dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels"));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$images = array();
if ($relsDrawing && $relsDrawing->Relationship) {
foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);
}
}
}
$xmlDrawing = simplexml_load_string($zip->getFromName($fileDrawing))->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
if ($xmlDrawing->oneCellAnchor) {
示例9: mergeArticleRowsToProduct
if ($aid == 0) {
if (isset($article_rowstart)) {
mergeArticleRowsToProduct($article_rowstart, $product_row - 1);
}
//default article
$article_rowstart = $product_row;
$p_image = DIR_WS_IMAGES . $p->image;
if (is_file($p_image)) {
//add product image
$img_path = thumbimage($p_image, $pi_width, $pi_height, 1, 1, DIR_WS_IMAGES . 'imagecache');
$obj_excel_draw = new PHPExcel_Worksheet_Drawing();
$obj_excel_draw->setWorksheet($obj_ws_summary);
$obj_excel_draw->setPath($img_path);
$obj_excel_draw->setCoordinates('B' . $product_row);
$obj_excel_draw->setOffsetX($img_offset);
$obj_excel_draw->setOffsetY($img_offset);
}
$no = $product_counter;
$pid = $p->id;
$pcode = $p->code;
} else {
$no = '';
$pid = '';
$pcode = '';
}
$obj_ws_summary->setCellValue('A' . $product_row, $no);
//Image is already added above
$obj_ws_summary->setCellValue('C' . $product_row, $pid);
$obj_ws_summary->setCellValueExplicit('D' . $product_row, $pcode, PHPExcel_Cell_DataType::TYPE_STRING);
$obj_ws_summary->setCellValueExplicit('E' . $product_row, $ean, PHPExcel_Cell_DataType::TYPE_STRING);
$obj_ws_summary->setCellValue('F' . $product_row, $size);
示例10: load
//.........这里部分代码省略.........
$vmlRelationship = self::dir_add("{$dir}/{$fileWorksheet}", $ele["Target"]);
}
}
if ($vmlRelationship != '') {
// Fetch linked images
$relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels'));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsVML->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$drawings[(string) $ele["Id"]] = self::dir_add($vmlRelationship, $ele["Target"]);
}
}
// Fetch VML document
$vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship));
$vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$hfImages = array();
$shapes = $vmlDrawing->xpath('//v:shape');
foreach ($shapes as $shape) {
$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$imageData = $shape->xpath('//v:imagedata');
$imageData = $imageData[0];
$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
$style = self::toCSSArray((string) $shape['style']);
$hfImages[(string) $shape['id']] = new PHPExcel_Worksheet_HeaderFooterDrawing();
if (isset($imageData['title'])) {
$hfImages[(string) $shape['id']]->setName((string) $imageData['title']);
}
$hfImages[(string) $shape['id']]->setPath("zip://" . PHPExcel_Shared_File::realpath($pFilename) . "#" . $drawings[(string) $imageData['relid']], false);
$hfImages[(string) $shape['id']]->setResizeProportional(false);
$hfImages[(string) $shape['id']]->setWidth($style['width']);
$hfImages[(string) $shape['id']]->setHeight($style['height']);
$hfImages[(string) $shape['id']]->setOffsetX($style['margin-left']);
$hfImages[(string) $shape['id']]->setOffsetY($style['margin-top']);
$hfImages[(string) $shape['id']]->setResizeProportional(true);
}
$docSheet->getHeaderFooter()->setImages($hfImages);
}
}
}
}
// TODO: Autoshapes from twoCellAnchors!
if ($zip->locateName(dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("{$dir}/{$fileWorksheet}") . "/_rels/" . basename($fileWorksheet) . ".rels"));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
$drawings[(string) $ele["Id"]] = self::dir_add("{$dir}/{$fileWorksheet}", $ele["Target"]);
}
}
if ($xmlSheet->drawing && !$this->_readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) {
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels"));
//~ http://schemas.openxmlformats.org/package/2006/relationships");
$images = array();
if ($relsDrawing && $relsDrawing->Relationship) {
foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);
} elseif ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") {
if ($this->_includeCharts) {
$charts[self::dir_add($fileDrawing, $ele["Target"])] = array('id' => (string) $ele["Id"], 'sheet' => $docSheet->getTitle());
}
}
示例11: insert_image
/**
* Вставить в указанную ячейку изображение
*/
protected function insert_image($img, $activeSheet, $coord)
{
$iDrowing = new PHPExcel_Worksheet_Drawing();
// Указываем путь к файлу изображения
$iDrowing->setPath($this->path . $img['src']);
// Устанавливаем ячейку
$iDrowing->setCoordinates($coord);
// Устанавливаем смещение X и Y
if ($img['offsetX'] > 0) {
$iDrowing->setOffsetX($img['offsetX']);
}
if ($img['offsetY'] > 0) {
$iDrowing->setOffsetY($img['offsetY']);
}
// Устанавливаем размеры изображения width и height
if ($img['width'] > 0) {
$iDrowing->setWidth($img['width']);
}
if ($img['height'] > 0) {
$iDrowing->setHeight($img['height']);
}
//помещаем на лист
$iDrowing->setWorksheet($activeSheet);
}
示例12: generate
//.........这里部分代码省略.........
} else {
$style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
}
$style_overlay['alignment']['vertical'] = $thisvalign;
// set styles for cell
$style_overlay['alignment']['horizontal'] = $thisalign;
$style_overlay['font']['color']['rgb'] = $thiscolor;
$style_overlay['font']['bold'] = $thisbold;
$style_overlay['font']['italic'] = $thisitalic;
$style_overlay['font']['underline'] = $thisunderline == true ? PHPExcel_Style_Font::UNDERLINE_SINGLE : PHPExcel_Style_Font::UNDERLINE_NONE;
$style_overlay['font']['size'] = $thissize;
$style_overlay['font']['name'] = $thisname;
$style_overlay['borders']['top']['style'] = $thisbordertop;
$style_overlay['borders']['bottom']['style'] = $thisborderbottom;
$style_overlay['borders']['left']['style'] = $thisborderleft;
$style_overlay['borders']['right']['style'] = $thisborderright;
$style_overlay['fill']['color']['rgb'] = $thisbg;
if ($thiscolspan == 1) {
$worksheet->getColumnDimension($xcol)->setWidth(25);
}
$worksheet->setCellValue($xcol . $xrow, $thistext);
if (is_array($thisimg) && count($thisimg) > 0) {
$thisCellWidth = $worksheet->getColumnDimension($xcol)->getWidth();
$thisCellHeight = 0;
$offsetY = 5;
foreach ($thisimg as $Vimg) {
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setWorksheet($worksheet);
$objDrawing->setName($Vimg['name']);
$objDrawing->setDescription($Vimg['title']);
$objDrawing->setPath($Vimg['src']);
$objDrawing->setCoordinates($xcol . $xrow);
$objDrawing->setOffsetX(1);
$objDrawing->setOffsetY($offsetY);
$objDrawing->setWidth($Vimg['width']);
$objDrawing->setHeight($Vimg['height']);
$thisCellHeight += $Vimg['height'];
if ($Vimg['width'] > $thisCellWidth) {
$worksheet->getColumnDimension($xcol)->setWidth($Vimg['width'] / 5);
}
if ($Vimg['height'] > 0) {
$worksheet->getRowDimension($xrow)->setRowHeight($thisCellHeight);
}
if ($debug) {
fwrite($handle, "\n Insert Image on " . $xcol . ":" . $xrow . ' src:' . $Vimg['src'] . ' Width:' . $Vimg['width'] . ' Height:' . $Vimg['height'] . ' Offset:' . $offsetY);
}
$offsetY += $Vimg['height'] + 10;
}
}
if ($debug) {
fwrite($handle, "\n" . $xcol . ":" . $xrow . " Rowspan:" . $thisrowspan . " ColSpan:" . $thiscolspan . " Color:" . $thiscolor . " Align:" . $thisalign . " VAlign:" . $thisvalign . " BGColor:" . $thisbg . " Bold:" . $strbold . " Italic:" . $stritalic . " Underline:" . $strunderline . " Font-name:" . $thisname . " Font-size:" . $thissize . " Border-top: " . $strbordertop . " Border-bottom" . $strborderbottom . " Border-left:" . $strborderleft . " Border-right:" . $strborderright . " cellValue: " . $thistext);
}
$worksheet->getStyle($xcol . $xrow)->applyFromArray($style_overlay);
if ($thiscolspan > 1 && $thisrowspan == 1) {
// spans more than 1 column
$lastxcol = $xcol;
for ($j = 1; $j < $thiscolspan; $j++) {
$lastxcol++;
}
$cellRange = $xcol . $xrow . ':' . $lastxcol . $xrow;
if ($debug) {
fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $lastxcol . ":" . $xrow);
}
$worksheet->mergeCells($cellRange);
$worksheet->getStyle($cellRange)->applyFromArray($style_overlay);
$xcol = $lastxcol;
示例13: while
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
->setKeywords("office 2007 openxml php")
->setCategory("Test result file");
// for exl logo
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('PHPExcel logo');
$objDrawing->setDescription('PHPExcel logo');
$objDrawing->setPath('../image/LOGO.png');
$objDrawing->setWidthAndHeight(200,100);
$objDrawing->setResizeProportional(true);
$objDrawing->setCoordinates('E1');
$objDrawing->setOffsetX(6);
$objDrawing->setOffsetY(8);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
/** Create a new PHPExcel object 1.0 */
$activeempname=mysqli_query($con,"SELECT ULD_ID,ULD_WORKER_NAME FROM LMC_USER_LOGIN_DETAILS WHERE ULD_USERNAME='$UserStamp'");
if($row=mysqli_fetch_array($activeempname))
{
$activeemp=$row["ULD_ID"];
}
// COMMOM DATA
if($_REQUEST['option']=='COMMON_DATA')
{
//MEETING TOPIC
$topic=mysqli_query($con,"SELECT MT_TOPIC FROM LMC_MEETING_TOPIC ORDER BY MT_TOPIC ASC");
while($row=mysqli_fetch_array($topic)){
$topicname[]=$row["MT_TOPIC"];
}
示例14: insert_bitmap
/**
* Insert an image in a worksheet.
*
* @param integer $row The row we are going to insert the bitmap into
* @param integer $col The column we are going to insert the bitmap into
* @param string $bitmap The bitmap filename
* @param integer $x The horizontal position (offset) of the image inside the cell.
* @param integer $y The vertical position (offset) of the image inside the cell.
* @param integer $scale_x The horizontal scale
* @param integer $scale_y The vertical scale
*/
public function insert_bitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1)
{
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setPath($bitmap);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($col) . ($row + 1));
$objDrawing->setOffsetX($x);
$objDrawing->setOffsetY($y);
$objDrawing->setWorksheet($this->worksheet);
if ($scale_x != 1) {
$objDrawing->setResizeProportional(false);
$objDrawing->getWidth($objDrawing->getWidth() * $scale_x);
}
if ($scale_y != 1) {
$objDrawing->setResizeProportional(false);
$objDrawing->setHeight($objDrawing->getHeight() * $scale_y);
}
}
示例15: actionExcelDDC
public function actionExcelDDC()
{
date_default_timezone_set('America/Tegucigalpa');
if (isset($_GET['Estudiante'], $_GET['Practica'])) {
$IdEstudiante = $_GET['Estudiante'];
$IdPractica = $_GET['Practica'];
$Estudiante = UsuarioEstudiante::model()->findByPk($IdEstudiante);
$PracticaProfesional = PracticaProfesional::model()->findByPk($IdPractica);
Yii::import('ext.phpexcel.XPHPExcel');
$objPHPExcel = XPHPExcel::createPHPExcel();
$objPHPExcel->getProperties()->setCreator("Henry Arévalo")->setLastModifiedBy("Henry Arévalo")->setTitle("Sistema de Gestión de Prácticas Profesionales")->setSubject("UNITEC")->setDescription("SGPP")->setKeywords("HAF")->setCategory("SGPP");
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop(0.5)->setRight(0.25)->setLeft(0.25)->setBottom(0.5);
// Bordes
$BordesEncabezado = array('borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
// Agregando imagen
$objDrawingPType = new PHPExcel_Worksheet_Drawing();
$objDrawingPType->setWorksheet($objPHPExcel->setActiveSheetIndex(0));
$objDrawingPType->setName("Pareto By Type");
$objDrawingPType->setPath(Yii::app()->basePath . DIRECTORY_SEPARATOR . "../assets/img/logounitec.png");
$objDrawingPType->setCoordinates('H1');
$objDrawingPType->setOffsetX(3);
$objDrawingPType->setOffsetY(0);
$objDrawingPType->setWidthAndHeight(180, 90);
$objDrawingPType->setResizeProportional(true);
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('Lista de Estudiantes');
// COMBINANDO CELDAS
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('C1:H1');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('C2:H2');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B5:D5');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B6:D6');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('E6:G6');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H6:J6');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B7:D7');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('E7:G7');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H7:J7');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B8:D8');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('E8:J8');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B9:D9');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('F9:G9');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('I9:J9');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B10:J10');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B12:J12');
// EMPIEZA EMPRESA INSTITUCIÓN
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B13:J13');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B14:G14');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H14:J14');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B15:G15');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H15:J15');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B16:D16');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('E16:G16');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H16:J16');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B17:D17');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('E17:G17');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H17:J17');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B18:D18');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('E18:G18');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H18:J18');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B19:D19');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('E19:G19');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('H19:J19');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B20:J20');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B22:J28');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B29:J29');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B29:J29');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B31:J42');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B43:J43');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B45:J46');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B49:F49');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('B50:F50');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('G49:J49');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('G50:J50');
// APLICANDO BORDES
$objPHPExcel->getActiveSheet()->getStyle('B6:D7')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('E6:G7')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('H6:J7')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B8:D9')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('E8:J9')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B12:J13')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B14:G15')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('H14:J15')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B16:D17')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B18:D19')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('E16:G17')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('E18:G19')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('H16:J17')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('H18:J19')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B22:J28')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B31:J42')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B45:J46')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('B49:F50')->applyFromArray($BordesEncabezado);
$objPHPExcel->getActiveSheet()->getStyle('G49:J50')->applyFromArray($BordesEncabezado);
// FORMATOS DE TEXTO ( SIZE, FONT , BOLD)
$NegritaTamanioCatorce = array('font' => array('bold' => true, 'size' => 14), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER));
// Negrita tamaño 14
$NormalTamanioDoce = array('font' => array('bold' => true, 'size' => 12), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER));
// Negrita tamaño 12
$NormalTamanioOnce = array('font' => array('bold' => true, 'size' => 11), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT));
// Negrita tamaño 12
$NormalTamanioDiez = array('font' => array('bold' => true, 'size' => 10), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT));
//.........这里部分代码省略.........