diff options
| author | xuri <xuri.me@gmail.com> | 2018-09-14 00:24:49 +0800 |
|---|---|---|
| committer | xuri <xuri.me@gmail.com> | 2018-09-14 00:24:49 +0800 |
| commit | 6ced438f39030e8a9a521548d4112dd002dc2ebe (patch) | |
| tree | ef5f2d12a849d68085a7286a2b983f3ad4369d11 /sheet.go | |
| parent | 4f47737d64fc9d9108675cbc1e73ae93c2d723a9 (diff) | |
New function `AddPictureFromBytes()` has been added, this resolve #259 and close #271.
Diffstat (limited to 'sheet.go')
| -rw-r--r-- | sheet.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -13,6 +13,7 @@ import ( "encoding/json" "encoding/xml" "errors" + "io/ioutil" "os" "path" "strconv" @@ -370,7 +371,7 @@ func (f *File) getSheetMap() map[string]string { } // SetSheetBackground provides a function to set background picture by given -// worksheet name. +// worksheet name and file path. func (f *File) SetSheetBackground(sheet, picture string) error { var err error // Check picture exists first. @@ -384,7 +385,8 @@ func (f *File) SetSheetBackground(sheet, picture string) error { pictureID := f.countMedia() + 1 rID := f.addSheetRelationships(sheet, SourceRelationshipImage, "../media/image"+strconv.Itoa(pictureID)+ext, "") f.addSheetPicture(sheet, rID) - f.addMedia(picture, ext) + file, _ := ioutil.ReadFile(picture) + f.addMedia(file, ext) f.setContentTypePartImageExtensions() return err } |
