excelize icon indicating copy to clipboard operation
excelize copied to clipboard

How do I locate a picture in a cell?请问如何定位到单元格中的图片?

Open 3xxx opened this issue 2 years ago • 3 comments

  1. Do you have "usedrange" like "vba"? getrows can't get consecutive empty cells? 1.请问有类似vba那种,取得使用单元格的区域usedrange?我看到issue里好像连续空单元格getrows就取不到么?

  2. I inserted an image in cell B2, how can I use a loop to find it in cell B2? 2.在B2单元格插入了图片,我要怎么利用循环查出它在B2?

thank you.

3xxx avatar May 01 '22 11:05 3xxx

Thanks for your issue. As the documentation noticed, only the tail continuously empty cell will be skipped, and currently just support to get pictures by known specified cel.

xuri avatar May 01 '22 11:05 xuri

你可以使用此函数 func (f *File) GetPicture(sheet, cell string) (string, []byte, error) 来进行判断 若同时存在文件名 及 二进制数据 那么就可以初步判断是图片 目前查源码仅支持如下图片格式 map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff", ".emf": ".emf"}

Wlhet avatar May 12 '22 06:05 Wlhet

你可以使用此函数 func (f *File) GetPicture(sheet, cell string) (string, []byte, error) 来进行判断 若同时存在文件名 及 二进制数据 那么就可以初步判断是图片 目前查源码仅支持如下图片格式 map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff", ".emf": ".emf"}

谢谢。它这个只能在指定单元格获取图片,也就是只能通过循环所有单元格范围了。

							axis, err := excelize.CoordinatesToCellName(j+1, i+1)
							if err != nil {
								logs.Error(err)
							}
							// fmt.Printf("%s\n", axis)
							_, raw, err := f.GetPicture(sheetlist[iii], axis)
							if err != nil {
								logs.Error(err)
							}
							if len(raw) > 0 {

3xxx avatar May 23 '22 12:05 3xxx