-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
#1405, add new function SetSheetBackgroundFromBytes #1406
Conversation
… used for setting background image by given image data Change-Id: I83baac1107f66dfa5d9d2eebfa7e40f9f49b79d5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your pull request. I've left some comments.
Change-Id: I04479f92c559e4bbfa5e81d5698389122c90743c
Change-Id: If259d00c12f2b30ebd8dba20845ddf92dc9bc717
Codecov Report
@@ Coverage Diff @@
## master #1406 +/- ##
==========================================
- Coverage 98.54% 98.53% -0.02%
==========================================
Files 31 31
Lines 23936 23947 +11
==========================================
+ Hits 23588 23596 +8
- Misses 230 232 +2
- Partials 118 119 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed some code review issues and updates the unit test case and documentation for this based on your branch. Please upgrade to the master branch code, and this feature will be released in the next version.
…qax-os#1406) Co-authored-by: houjianxin.rupert <[email protected]>
…qax-os#1406) Co-authored-by: houjianxin.rupert <[email protected]>
PR Details
Description
Because of business need, We added a new method for struct File:
SetSheetBackgroundFromBytes
.the function of this method is similar with existing method(SetSheetBackground), they both can add background image for excel files, but the difference between SetSheetBackground and SetSheetBackgroundFromBytes is, the new method use binary image data as image source. And SetSheetBackgroundFromBytes do not need to specify the extension of image data, It can determine the image format by itself.
由于业务需要, 我们为File结构体增加了一个新的方法:
SetSheetBackgroundFromBytes
。该方法的功能与现存SetSheetBackground方法相同,即添加背景图像,不同的是新增方法支持使用二进制数据设置背景图像,同时,SetSheetBackgroundFromBytes无需指定文件后缀,该方法可自行判断二进制数据中所包含图像的格式。
Related Issue
#1405
Motivation and Context
In our business, we want to set the binary image data requested from the upstream service as the background of the excel file directly, so we implement
SetSheetBackgroundFromBytes
.在业务场景中,我们希望能够将从上游服务中请求到的二进制图片数据直接设置为excel文件的背景,因此实现了
SetSheetBackgroundFromBytes
。How Has This Been Tested
We loaded all the images under
test/images/
andexcelize.svg
, and calledSetSheetBackgroundFromBytes
to set the binary data loaded into memory as the background image, the result shows that this method can distinguish the binary data format and set for background, seeTestSetBackgroundFromBytes
insheet_test.go
;In addition to the above images, we also tested with other positive and negative example files that are not in this project, and the results show that
SetSheetBackgroundFromBytes
can be executed correctly;We found that when we use the image
test/images/excel.wmz
as the background, no matter calling the existingSetSheetBackground
or the addedSetSheetBackgroundFromBytes
, the set background cannot be displayed correctly, maybe there is a problem with the image itself;We found that when we use the
.svg
file as the background image, it cannot be displayed normally in excel, and you cannot manually set the.svg
file as the background image in excel. It seems that excel does not support setting the.svg
file as the background image, but it can be displayed normally in WPS.我们读取了
test/images/
下的所有图像以及excelize.svg
,并调用SetSheetBackgroundFromBytes
将加载到内存的二进制数据设置为背景图像,结果显示该方法能正常区分二进制数据格式并设置背景,详见sheet_test.go
中的TestSetBackgroundFromBytes
;除上述图像外,我们还使用其他不在本项目中的正例和反例文件做了测试,结果显示
SetSheetBackgroundFromBytes
均能够正确执行;我们发现使用图像
test/images/excel.wmz
作为背景时,无论调用现存的SetSheetBackground
还是新增的SetSheetBackgroundFromBytes
都无法正确显示设置的背景,可能是图像本身有问题;我们发现使用
.svg
文件作为背景图像时,在excel中无法正常显示,同时在excel中也无法手动设置.svg
文件作为背景图像,似乎excel并不支持设置.svg文件作为背景,但在WPS中可以正常显示。Types of changes
Checklist