.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Excel::Writer::XLSX::Shape 3" .TH Excel::Writer::XLSX::Shape 3 "2015-04-21" "perl v5.12.5" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Shape \- A class for creating Excel Drawing shapes .SH "SYNOPSIS" .IX Header "SYNOPSIS" To create a simple Excel file containing shapes using Excel::Writer::XLSX: .PP .Vb 1 \& #!/usr/bin/perl \& \& use strict; \& use warnings; \& use Excel::Writer::XLSX; \& \& my $workbook = Excel::Writer::XLSX\->new( \*(Aqshape.xlsx\*(Aq ); \& my $worksheet = $workbook\->add_worksheet(); \& \& # Add a default rectangle shape. \& my $rect = $workbook\->add_shape(); \& \& # Add an ellipse with centered text. \& my $ellipse = $workbook\->add_shape( \& type => \*(Aqellipse\*(Aq, \& text => "Hello\enWorld" \& ); \& \& # Add a plus shape. \& my $plus = $workbook\->add_shape( type => \*(Aqplus\*(Aq); \& \& # Insert the shapes in the worksheet. \& $worksheet\->insert_shape( \*(AqB3\*(Aq, $rect ); \& $worksheet\->insert_shape( \*(AqC3\*(Aq, $ellipse ); \& $worksheet\->insert_shape( \*(AqD3\*(Aq, $plus ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Excel::Writer::XLSX::Shape\*(C'\fR module is used to create Shape objects for Excel::Writer::XLSX. .PP A Shape object is created via the Workbook \f(CW\*(C`add_shape()\*(C'\fR method: .PP .Vb 1 \& my $shape_rect = $workbook\->add_shape( type => \*(Aqrect\*(Aq ); .Ve .PP Once the object is created it can be inserted into a worksheet using the \f(CW\*(C`insert_shape()\*(C'\fR method: .PP .Vb 1 \& $worksheet\->insert_shape(\*(AqA1\*(Aq, $shape_rect); .Ve .PP A Shape can be inserted multiple times if required. .PP .Vb 2 \& $worksheet\->insert_shape(\*(AqA1\*(Aq, $shape_rect); \& $worksheet\->insert_shape(\*(AqB2\*(Aq, $shape_rect, 20, 30); .Ve .SH "METHODS" .IX Header "METHODS" .ie n .SS "add_shape( %properties )" .el .SS "add_shape( \f(CW%properties\fP )" .IX Subsection "add_shape( %properties )" The \f(CW\*(C`add_shape()\*(C'\fR Workbook method specifies the properties of the Shape in hash \f(CW\*(C`property => value\*(C'\fR format: .PP .Vb 1 \& my $shape = $workbook\->add_shape( %properties ); .Ve .PP The available properties are shown below. .ie n .SS "insert_shape( $row, $col, $shape, $x, $y, $scale_x, $scale_y )" .el .SS "insert_shape( \f(CW$row\fP, \f(CW$col\fP, \f(CW$shape\fP, \f(CW$x\fP, \f(CW$y\fP, \f(CW$scale_x\fP, \f(CW$scale_y\fP )" .IX Subsection "insert_shape( $row, $col, $shape, $x, $y, $scale_x, $scale_y )" The \f(CW\*(C`insert_shape()\*(C'\fR Worksheet method sets the location and scale of the shape object within the worksheet. .PP .Vb 2 \& # Insert the shape into the worksheet. \& $worksheet\->insert_shape( \*(AqE2\*(Aq, $shape ); .Ve .PP Using the cell location and the \f(CW$x\fR and \f(CW$y\fR cell offsets it is possible to position a shape anywhere on the canvas of a worksheet. .PP A more detailed explanation of the \f(CW\*(C`insert_shape()\*(C'\fR method is given in the main Excel::Writer::XLSX documentation. .SH "SHAPE PROPERTIES" .IX Header "SHAPE PROPERTIES" Any shape property can be queried or modified by the corresponding get/set method: .PP .Vb 3 \& my $ellipse = $workbook\->add_shape( %properties ); \& $ellipse\->set_type( \*(Aqplus\*(Aq ); # No longer an ellipse! \& my $type = $ellipse\->get_type(); # Find out what it really is. .Ve .PP Multiple shape properties may also be modified in one go by using the \f(CW\*(C`set_properties()\*(C'\fR method: .PP .Vb 1 \& $shape\->set_properties( type => \*(Aqellipse\*(Aq, text => \*(AqHello\*(Aq ); .Ve .PP The properties of a shape object that can be defined via \f(CW\*(C`add_shape()\*(C'\fR are shown below. .SS "name" .IX Subsection "name" Defines the name of the shape. This is an optional property and the shape will be given a default name if not supplied. The name is generally only used by Excel Macros to refer to the object. .SS "type" .IX Subsection "type" Defines the type of the object such as \f(CW\*(C`rect\*(C'\fR, \f(CW\*(C`ellipse\*(C'\fR or \f(CW\*(C`triangle\*(C'\fR: .PP .Vb 1 \& my $ellipse = $workbook\->add_shape( type => \*(Aqellipse\*(Aq ); .Ve .PP The default type is \f(CW\*(C`rect\*(C'\fR. .PP The full list of available shapes is shown below. .PP See also the \f(CW\*(C`shapes_all.pl\*(C'\fR program in the \f(CW\*(C`examples\*(C'\fR directory of the distro. It creates an example workbook with all supported shapes labelled with their shape names. .IP "\(bu" 4 Basic Shapes .Sp .Vb 11 \& blockArc can chevron cube decagon \& diamond dodecagon donut ellipse funnel \& gear6 gear9 heart heptagon hexagon \& homePlate lightningBolt line lineInv moon \& nonIsoscelesTrapezoid noSmoking octagon parallelogram pentagon \& pie pieWedge plaque rect round1Rect \& round2DiagRect round2SameRect roundRect rtTriangle smileyFace \& snip1Rect snip2DiagRect snip2SameRect snipRoundRect star10 \& star12 star16 star24 star32 star4 \& star5 star6 star7 star8 sun \& teardrop trapezoid triangle .Ve .IP "\(bu" 4 Arrow Shapes .Sp .Vb 6 \& bentArrow bentUpArrow circularArrow curvedDownArrow \& curvedLeftArrow curvedRightArrow curvedUpArrow downArrow \& leftArrow leftCircularArrow leftRightArrow leftRightCircularArrow \& leftRightUpArrow leftUpArrow notchedRightArrow quadArrow \& rightArrow stripedRightArrow swooshArrow upArrow \& upDownArrow uturnArrow .Ve .IP "\(bu" 4 Connector Shapes .Sp .Vb 3 \& bentConnector2 bentConnector3 bentConnector4 \& bentConnector5 curvedConnector2 curvedConnector3 \& curvedConnector4 curvedConnector5 straightConnector1 .Ve .IP "\(bu" 4 Callout Shapes .Sp .Vb 8 \& accentBorderCallout1 accentBorderCallout2 accentBorderCallout3 \& accentCallout1 accentCallout2 accentCallout3 \& borderCallout1 borderCallout2 borderCallout3 \& callout1 callout2 callout3 \& cloudCallout downArrowCallout leftArrowCallout \& leftRightArrowCallout quadArrowCallout rightArrowCallout \& upArrowCallout upDownArrowCallout wedgeEllipseCallout \& wedgeRectCallout wedgeRoundRectCallout .Ve .IP "\(bu" 4 Flow Chart Shapes .Sp .Vb 10 \& flowChartAlternateProcess flowChartCollate flowChartConnector \& flowChartDecision flowChartDelay flowChartDisplay \& flowChartDocument flowChartExtract flowChartInputOutput \& flowChartInternalStorage flowChartMagneticDisk flowChartMagneticDrum \& flowChartMagneticTape flowChartManualInput flowChartManualOperation \& flowChartMerge flowChartMultidocument flowChartOfflineStorage \& flowChartOffpageConnector flowChartOnlineStorage flowChartOr \& flowChartPredefinedProcess flowChartPreparation flowChartProcess \& flowChartPunchedCard flowChartPunchedTape flowChartSort \& flowChartSummingJunction flowChartTerminator .Ve .IP "\(bu" 4 Action Shapes .Sp .Vb 4 \& actionButtonBackPrevious actionButtonBeginning actionButtonBlank \& actionButtonDocument actionButtonEnd actionButtonForwardNext \& actionButtonHelp actionButtonHome actionButtonInformation \& actionButtonMovie actionButtonReturn actionButtonSound .Ve .IP "\(bu" 4 Chart Shapes .Sp Not to be confused with Excel Charts. .Sp .Vb 1 \& chartPlus chartStar chartX .Ve .IP "\(bu" 4 Math Shapes .Sp .Vb 1 \& mathDivide mathEqual mathMinus mathMultiply mathNotEqual mathPlus .Ve .IP "\(bu" 4 Stars and Banners .Sp .Vb 6 \& arc bevel bracePair bracketPair chord \& cloud corner diagStripe doubleWave ellipseRibbon \& ellipseRibbon2 foldedCorner frame halfFrame horizontalScroll \& irregularSeal1 irregularSeal2 leftBrace leftBracket leftRightRibbon \& plus ribbon ribbon2 rightBrace rightBracket \& verticalScroll wave .Ve .IP "\(bu" 4 Tab Shapes .Sp .Vb 1 \& cornerTabs plaqueTabs squareTabs .Ve .SS "text" .IX Subsection "text" This property is used to make the shape act like a text box. .PP .Vb 1 \& my $rect = $workbook\->add_shape( type => \*(Aqrect\*(Aq, text => "Hello\enWorld" ); .Ve .PP The text is super-imposed over the shape. The text can be wrapped using the newline character \f(CW\*(C`\en\*(C'\fR. .SS "id" .IX Subsection "id" Identification number for internal identification. This number will be auto-assigned, if not assigned, or if it is a duplicate. .SS "format" .IX Subsection "format" Workbook format for decorating the shape text (font family, size, and decoration). .SS "start, start_index" .IX Subsection "start, start_index" Shape indices of the starting point for a connector and the index of the connection. Index numbers are zero-based, start from the top dead centre and are counted clockwise. .PP Indices are typically created for vertices and centre points of shapes. They are the blue connection points that appear when connection shapes are selected manually in Excel. .SS "end, end_index" .IX Subsection "end, end_index" Same as above but for end points and end connections. .SS "start_side, end_side" .IX Subsection "start_side, end_side" This is either the letter \f(CW\*(C`b\*(C'\fR or \f(CW\*(C`r\*(C'\fR for the bottom or right side of the shape to be connected to and from. .PP If the \f(CW\*(C`start\*(C'\fR, \f(CW\*(C`start_index\*(C'\fR, and \f(CW\*(C`start_side\*(C'\fR parameters are defined for a connection shape, the shape will be auto located and linked to the starting and ending shapes respectively. This can be very useful for flow and organisation charts. .SS "flip_h, flip_v" .IX Subsection "flip_h, flip_v" Set this value to 1, to flip the shape horizontally and/or vertically. .SS "rotation" .IX Subsection "rotation" Shape rotation, in degrees, from 0 to 360. .SS "line, fill" .IX Subsection "line, fill" Shape colour for the outline and fill. Colours may be specified as a colour index, or in \s-1RGB\s0 format, i.e. \f(CW\*(C`AA00FF\*(C'\fR. .PP See \f(CW\*(C`COLOURS IN EXCEL\*(C'\fR in the main documentation for more information. .SS "line_type" .IX Subsection "line_type" Line type for shape outline. The default is solid. The list of possible values is: .PP .Vb 1 \& dash, sysDot, dashDot, lgDash, lgDashDot, lgDashDotDot, solid .Ve .SS "valign, align" .IX Subsection "valign, align" Text alignment within the shape. .PP Vertical alignment can be: .PP .Vb 5 \& Setting Meaning \& ======= ======= \& t Top \& ctr Centre \& b Bottom .Ve .PP Horizontal alignment can be: .PP .Vb 6 \& Setting Meaning \& ======= ======= \& l Left \& r Right \& ctr Centre \& just Justified .Ve .PP The default is to centre both horizontally and vertically. .SS "scale_x, scale_y" .IX Subsection "scale_x, scale_y" Scale factor in x and y dimension, for scaling the shape width and height. The default value is 1. .PP Scaling may be set on the shape object or via \f(CW\*(C`insert_shape()\*(C'\fR. .SS "adjustments" .IX Subsection "adjustments" Adjustment of shape vertices. Most shapes do not use this. For some shapes, there is a single adjustment to modify the geometry. For instance, the plus shape has one adjustment to control the width of the spokes. .PP Connectors can have a number of adjustments to control the shape routing. Typically, a connector will have 3 to 5 handles for routing the shape. The adjustment is in percent of the distance from the starting shape to the ending shape, alternating between the x and y dimension. Adjustments may be negative, to route the shape away from the endpoint. .SS "stencil" .IX Subsection "stencil" Shapes work in stencil mode by default. That is, once a shape is inserted, its connection is separated from its master. The master shape may be modified after an instance is inserted, and only subsequent insertions will show the modifications. .PP This is helpful for Org charts, where an employee shape may be created once, and then the text of the shape is modified for each employee. .PP The \f(CW\*(C`insert_shape()\*(C'\fR method returns a reference to the inserted shape (the child). .PP Stencil mode can be turned off, allowing for shape(s) to be modified after insertion. In this case the \f(CW\*(C`insert_shape()\*(C'\fR method returns a reference to the inserted shape (the master). This is not very useful for inserting multiple shapes, since the x/y coordinates also gets modified. .SH "TIPS" .IX Header "TIPS" Use \f(CW\*(C`$worksheet\->hide_gridlines(2)\*(C'\fR to prepare a blank canvas without gridlines. .PP Shapes do not need to fit on one page. Excel will split a large drawing into multiple pages if required. Use the page break preview to show page boundaries superimposed on the drawing. .PP Connected shapes will auto-locate in Excel if you move either the starting shape or the ending shape separately. However, if you select both shapes (lasso or control-click), the connector will move with it, and the shape adjustments will not re-calculate. .SH "EXAMPLE" .IX Header "EXAMPLE" .Vb 1 \& #!/usr/bin/perl \& \& use strict; \& use warnings; \& use Excel::Writer::XLSX; \& \& my $workbook = Excel::Writer::XLSX\->new( \*(Aqshape.xlsx\*(Aq ); \& my $worksheet = $workbook\->add_worksheet(); \& \& # Add a default rectangle shape. \& my $rect = $workbook\->add_shape(); \& \& # Add an ellipse with centered text. \& my $ellipse = $workbook\->add_shape( \& type => \*(Aqellipse\*(Aq, \& text => "Hello\enWorld" \& ); \& \& # Add a plus shape. \& my $plus = $workbook\->add_shape( type => \*(Aqplus\*(Aq); \& \& # Insert the shapes in the worksheet. \& $worksheet\->insert_shape( \*(AqB3\*(Aq, $rect ); \& $worksheet\->insert_shape( \*(AqC3\*(Aq, $ellipse ); \& $worksheet\->insert_shape( \*(AqD3\*(Aq, $plus ); .Ve .PP See also the \f(CW\*(C`shapes_*.pl\*(C'\fR program in the \f(CW\*(C`examples\*(C'\fR directory of the distro. .SH "TODO" .IX Header "TODO" .IP "\(bu" 4 Add shapes which have custom geometries. .IP "\(bu" 4 Provide better integration of workbook formats for shapes. .IP "\(bu" 4 Add further validation of shape properties to prevent creation of workbooks that will not open. .IP "\(bu" 4 Auto connect shapes that are not anchored to cell A1. .IP "\(bu" 4 Add automatic shape connection to shape vertices besides the object centre. .IP "\(bu" 4 Improve automatic shape connection to shapes with concave sides (e.g. chevron). .SH "AUTHOR" .IX Header "AUTHOR" Dave Clarke dclarke@cpan.org .SH "COPYRIGHT" .IX Header "COPYRIGHT" (c) MM-MMXV, John McNamara. .PP All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.