Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3xxx opened this issue May 1, 2022 · 3 comments · Fixed by #1634
Closed

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

3xxx opened this issue May 1, 2022 · 3 comments · Fixed by #1634

Comments

@3xxx
Copy link

3xxx commented May 1, 2022

  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.

@xuri
Copy link
Member

xuri commented May 1, 2022

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.

@Wlhet
Copy link

Wlhet commented May 12, 2022

你可以使用此函数 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"}

@3xxx
Copy link
Author

3xxx commented May 23, 2022

你可以使用此函数 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 {

@xuri xuri linked a pull request Oct 11, 2023 that will close this issue
10 tasks
xuri pushed a commit that referenced this issue Oct 12, 2023
- Introduce new exported function GetPictureCells
- Upgrade dependencies module golang.org/x/net from 0.16.0 to 0.17.0
- Update unit tests
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- Introduce new exported function GetPictureCells
- Upgrade dependencies module golang.org/x/net from 0.16.0 to 0.17.0
- Update unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants