diff options
Diffstat (limited to 'picture.go')
-rw-r--r-- | picture.go | 47 |
1 files changed, 19 insertions, 28 deletions
@@ -48,7 +48,6 @@ func parseFormatPictureSet(formatSet string) (*formatPicture, error) { // package main // // import ( -// "fmt" // _ "image/gif" // _ "image/jpeg" // _ "image/png" @@ -59,23 +58,19 @@ func parseFormatPictureSet(formatSet string) (*formatPicture, error) { // func main() { // f := excelize.NewFile() // // Insert a picture. -// err := f.AddPicture("Sheet1", "A2", "./image1.jpg", "") -// if err != nil { -// fmt.Println(err) +// if err := f.AddPicture("Sheet1", "A2", "image.jpg", ""); err != nil { +// println(err.Error()) // } // // Insert a picture scaling in the cell with location hyperlink. -// err = f.AddPicture("Sheet1", "D2", "./image1.png", `{"x_scale": 0.5, "y_scale": 0.5, "hyperlink": "#Sheet2!D8", "hyperlink_type": "Location"}`) -// if err != nil { -// fmt.Println(err) +// if err := f.AddPicture("Sheet1", "D2", "image.png", `{"x_scale": 0.5, "y_scale": 0.5, "hyperlink": "#Sheet2!D8", "hyperlink_type": "Location"}`); err != nil { +// println(err.Error()) // } // // Insert a picture offset in the cell with external hyperlink, printing and positioning support. -// err = f.AddPicture("Sheet1", "H2", "./image3.gif", `{"x_offset": 15, "y_offset": 10, "hyperlink": "https://github.com/360EntSecGroup-Skylar/excelize", "hyperlink_type": "External", "print_obj": true, "lock_aspect_ratio": false, "locked": false, "positioning": "oneCell"}`) -// if err != nil { -// fmt.Println(err) +// if err := f.AddPicture("Sheet1", "H2", "image.gif", `{"x_offset": 15, "y_offset": 10, "hyperlink": "https://github.com/360EntSecGroup-Skylar/excelize", "hyperlink_type": "External", "print_obj": true, "lock_aspect_ratio": false, "locked": false, "positioning": "oneCell"}`); err != nil { +// println(err.Error()) // } -// err = f.SaveAs("./Book1.xlsx") -// if err != nil { -// fmt.Println(err) +// if err := f.SaveAs("Book1.xlsx"); err != nil { +// println(err.Error()) // } // } // @@ -109,7 +104,6 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error { // package main // // import ( -// "fmt" // _ "image/jpeg" // "io/ioutil" // @@ -119,17 +113,15 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error { // func main() { // f := excelize.NewFile() // -// file, err := ioutil.ReadFile("./image1.jpg") +// file, err := ioutil.ReadFile("image.jpg") // if err != nil { -// fmt.Println(err) +// println(err.Error()) // } -// err = f.AddPictureFromBytes("Sheet1", "A2", "", "Excel Logo", ".jpg", file) -// if err != nil { -// fmt.Println(err) +// if err := f.AddPictureFromBytes("Sheet1", "A2", "", "Excel Logo", ".jpg", file); err != nil { +// println(err.Error()) // } -// err = f.SaveAs("./Book1.xlsx") -// if err != nil { -// fmt.Println(err) +// if err := f.SaveAs("Book1.xlsx"); err != nil { +// println(err.Error()) // } // } // @@ -430,19 +422,18 @@ func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string { // embed in XLSX by given worksheet and cell name. This function returns the // file name in XLSX and file contents as []byte data types. For example: // -// f, err := excelize.OpenFile("./Book1.xlsx") +// f, err := excelize.OpenFile("Book1.xlsx") // if err != nil { -// fmt.Println(err) +// println(err.Error()) // return // } // file, raw, err := f.GetPicture("Sheet1", "A2") // if err != nil { -// fmt.Println(err) +// println(err.Error()) // return // } -// err = ioutil.WriteFile(file, raw, 0644) -// if err != nil { -// fmt.Println(err) +// if err := ioutil.WriteFile(file, raw, 0644); err != nil { +// println(err.Error()) // } // func (f *File) GetPicture(sheet, cell string) (string, []byte, error) { |