@@ -110,41 +110,46 @@ func parseGraphicOptions(opts *GraphicOptions) *GraphicOptions {
110
110
// }
111
111
// }
112
112
//
113
- // The optional parameter "AutoFit" specifies if you make image size auto-fits the
114
- // cell, the default value of that is 'false' .
113
+ // The optional parameter "AltText" is used to add alternative text to a graph
114
+ // object .
115
115
//
116
- // The optional parameter "Hyperlink" specifies the hyperlink of the image.
116
+ // The optional parameter "PrintObject" indicates whether the graph object is
117
+ // printed when the worksheet is printed, the default value of that is 'true'.
117
118
//
118
- // The optional parameter "HyperlinkType" defines two types of
119
- // hyperlink "External" for website or "Location" for moving to one of the
120
- // cells in this workbook. When the "HyperlinkType" is "Location",
121
- // coordinates need to start with "#".
119
+ // The optional parameter "Locked" indicates whether lock the graph object.
120
+ // Locking an object has no effect unless the sheet is protected.
122
121
//
123
- // The optional parameter "Positioning" defines two types of the position of an
124
- // image in an Excel spreadsheet, "oneCell" (Move but don't size with
125
- // cells) or "absolute" (Don't move or size with cells). If you don't set this
126
- // parameter, the default positioning is move and size with cells.
122
+ // The optional parameter "LockAspectRatio" indicates whether lock aspect ratio
123
+ // for the graph object, the default value of that is 'false'.
127
124
//
128
- // The optional parameter "PrintObject" indicates whether the image is printed
129
- // when the worksheet is printed , the default value of that is 'true '.
125
+ // The optional parameter "AutoFit" specifies if you make graph object size
126
+ // auto-fits the cell , the default value of that is 'false '.
130
127
//
131
- // The optional parameter "LockAspectRatio" indicates whether lock aspect
132
- // ratio for the image , the default value of that is 'false' .
128
+ // The optional parameter "OffsetX" specifies the horizontal offset of the graph
129
+ // object with the cell , the default value of that is 0 .
133
130
//
134
- // The optional parameter "Locked" indicates whether lock the image. Locking
135
- // an object has no effect unless the sheet is protected .
131
+ // The optional parameter "OffsetY" specifies the vertical offset of the graph
132
+ // object with the cell, the default value of that is 0 .
136
133
//
137
- // The optional parameter "OffsetX " specifies the horizontal offset of the
138
- // image with the cell , the default value of that is 0 .
134
+ // The optional parameter "ScaleX " specifies the horizontal scale of graph
135
+ // object , the default value of that is 1.0 which presents 100% .
139
136
//
140
- // The optional parameter "ScaleX " specifies the horizontal scale of images ,
137
+ // The optional parameter "ScaleY " specifies the vertical scale of graph object ,
141
138
// the default value of that is 1.0 which presents 100%.
142
139
//
143
- // The optional parameter "OffsetY " specifies the vertical offset of the
144
- // image with the cell, the default value of that is 0 .
140
+ // The optional parameter "Hyperlink " specifies the hyperlink of the graph
141
+ // object .
145
142
//
146
- // The optional parameter "ScaleY" specifies the vertical scale of images,
147
- // the default value of that is 1.0 which presents 100%.
143
+ // The optional parameter "HyperlinkType" defines two types of
144
+ // hyperlink "External" for website or "Location" for moving to one of the
145
+ // cells in this workbook. When the "HyperlinkType" is "Location",
146
+ // coordinates need to start with "#".
147
+ //
148
+ // The optional parameter "Positioning" defines 3 types of the position of a
149
+ // graph object in a spreadsheet: "oneCell" (Move but don't size with
150
+ // cells), "twoCell" (Move and size with cells), and "absolute" (Don't move or
151
+ // size with cells). If you don't set this parameter, the default positioning
152
+ // is to move and size with cells.
148
153
func (f * File ) AddPicture (sheet , cell , name string , opts * GraphicOptions ) error {
149
154
var err error
150
155
// Check picture exists first.
@@ -330,6 +335,9 @@ func (f *File) addDrawingPicture(sheet, drawingXML, cell, ext string, rID, hyper
330
335
if err != nil {
331
336
return err
332
337
}
338
+ if opts .Positioning != "" && inStrSlice (supportedPositioning , opts .Positioning , true ) == - 1 {
339
+ return ErrParameterInvalid
340
+ }
333
341
width , height := img .Width , img .Height
334
342
if opts .AutoFit {
335
343
if width , height , col , row , err = f .drawingResize (sheet , cell , float64 (width ), float64 (height ), opts ); err != nil {
0 commit comments