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

resize the insert image to fit the cell #410

Conversation

yoshhiide
Copy link
Contributor

@yoshhiide yoshhiide commented May 27, 2019

PR Details

resize the insert image to fit the cell.

Description

Added "autofit" option to "AddPicture".
Resize the image to the size of a single cell or merged cell.

example)

xlsx.AddPicture("Sheet1", "A30", "./image1.jpg", {"autofit": true})
xlsx.AddPicture("Sheet1", "B30", "./image1.jpg", {"autofit": true, "x_offset": 10, "y_offset": 10})

result)
TestAddPicture_xlsx
"B30: C33" is a merged cell

Related Issue

#384

Motivation and Context

I want to reduce manual editing by automatic image resizing.

How Has This Been Tested

I added a test code to picture_test.go and verified it.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-io
Copy link

codecov-io commented May 27, 2019

Codecov Report

Merging #410 into master will decrease coverage by 1.32%.
The diff coverage is 76.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #410      +/-   ##
==========================================
- Coverage   96.26%   94.94%   -1.33%     
==========================================
  Files          26       22       -4     
  Lines        5513     4528     -985     
==========================================
- Hits         5307     4299    -1008     
- Misses        115      130      +15     
- Partials       91       99       +8
Impacted Files Coverage Δ
cellmerged.go 85% <100%> (-15%) ⬇️
picture.go 95.48% <75%> (-3.02%) ⬇️
excelize.go 89.47% <0%> (-5.68%) ⬇️
sheetpr.go 94.36% <0%> (-5.64%) ⬇️
cell.go 87.31% <0%> (-1.71%) ⬇️
adjust.go 95.12% <0%> (-1.22%) ⬇️
sheet.go 95.41% <0%> (-0.57%) ⬇️
styles.go 98.91% <0%> (-0.37%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e791fa...9e3521d. Read the comment docs.

@yoshhiide yoshhiide force-pushed the feature/issue-384-add-option-auto-fit-to-cell branch from 4ef25da to 69bee73 Compare May 28, 2019 05:33
…on-auto-fit-to-cell

* skylar_excelize/master:
  Add the ability to change the default font
@xuri xuri self-assigned this May 28, 2019
@xuri xuri added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 18, 2019
@paologf-mb
Copy link

Hello, how is going the integration of this useful feature? Is still in progress or is abandoned? Thanks

@xuri
Copy link
Member

xuri commented May 14, 2020

Hello, how is going the integration of this useful feature? Is still in progress or is abandoned? Thanks

I will review this PR this weekend.

xuri added a commit that referenced this pull request May 17, 2020
@xuri xuri closed this May 17, 2020
@xuri
Copy link
Member

xuri commented May 17, 2020

Sorry for my late reply. I have added autofit support for AddPicture API. Thanks for your PR, @yoshhiide. I resolve conflicts and perform a manual merge.

@xuri xuri added this to Features in v2.3.0 May 17, 2020
Jerome1337 pushed a commit to Jerome1337/excelize that referenced this pull request Jun 16, 2020
nullfy pushed a commit to nullfy/excelize that referenced this pull request Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
No open projects
v2.3.0
  
Features
Development

Successfully merging this pull request may close these issues.

None yet

4 participants