MCPcopy
hub / github.com/qax-os/excelize / AddPicture

Method AddPicture

picture.go:195–207  ·  view source on GitHub ↗

AddPicture provides the method to add picture in a sheet by given picture format set (such as offset, scale, aspect ratio setting and print settings) and file path, supported image types: BMP, EMF, EMZ, GIF, ICO, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ. This function is concurrency-safe. Note t

(sheet, cell, name string, opts *GraphicOptions)

Source from the content-addressed store, hash-verified

193// size with cells). If you don't set this parameter, the default positioning
194// is to move and size with cells.
195func (f *File) AddPicture(sheet, cell, name string, opts *GraphicOptions) error {
196 var err error
197 // Check picture exists first.
198 if _, err = os.Stat(name); os.IsNotExist(err) {
199 return err
200 }
201 ext, ok := supportedImageTypes[strings.ToLower(path.Ext(name))]
202 if !ok {
203 return ErrImgExt
204 }
205 file, _ := os.ReadFile(filepath.Clean(name))
206 return f.AddPictureFromBytes(sheet, cell, &Picture{Extension: ext, File: file, Format: opts})
207}
208
209// AddPictureFromBytes provides the method to add picture in a sheet by given
210// picture format set (such as offset, scale, aspect ratio setting and print

Callers 12

TestGetPictureFunction · 0.95
TestDrawingResizeFunction · 0.95
TestGetPictureCellsFunction · 0.95
TestGetCellImagesFunction · 0.95
TestNewFileFunction · 0.95
prepareTestBook3Function · 0.95
TestAdjustDrawingsFunction · 0.95
TestAddPictureFunction · 0.80
TestAddPictureErrorsFunction · 0.80
TestDeletePictureFunction · 0.80
prepareTestBook1Function · 0.80
TestConcurrencyFunction · 0.80

Calls 1

AddPictureFromBytesMethod · 0.95

Tested by 12

TestGetPictureFunction · 0.76
TestDrawingResizeFunction · 0.76
TestGetPictureCellsFunction · 0.76
TestGetCellImagesFunction · 0.76
TestNewFileFunction · 0.76
prepareTestBook3Function · 0.76
TestAdjustDrawingsFunction · 0.76
TestAddPictureFunction · 0.64
TestAddPictureErrorsFunction · 0.64
TestDeletePictureFunction · 0.64
prepareTestBook1Function · 0.64
TestConcurrencyFunction · 0.64