[GH-ISSUE #363] question: <The picture shows the wrong scale> #287

Closed
opened 2026-05-05 12:06:07 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @Robinhao2k on GitHub (Dec 27, 2021).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/363

Question

Hello Sir,
I am using VC2019 to test the "xlsxwriter" library. I compiled the example project and executed the example program "images.exe". The program produced the "images.xlsx" file. When I opened the "images.xlsx" file with Excel 2019, I found There is a problem with the display ratio of the picture in the file. For example, the first picture does not have a zoom ratio set in the program, but it displays 90% width and 110% height in excel. What is the problem?

I am using VC2019 X64, Windows 10 and Excel 2019.

It is the example code and the xlsx file:
images.zip
Scale1

In addition, the font used in Excel is Chinese Song Ti. Maybe it's an error caused by the font?
Scale2

thank you very much

Originally created by @Robinhao2k on GitHub (Dec 27, 2021). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/363 ### Question Hello Sir, I am using VC2019 to test the "xlsxwriter" library. I compiled the example project and executed the example program "images.exe". The program produced the "images.xlsx" file. When I opened the "images.xlsx" file with Excel 2019, I found There is a problem with the display ratio of the picture in the file. For example, the first picture does not have a zoom ratio set in the program, but it displays 90% width and 110% height in excel. What is the problem? I am using VC2019 X64, Windows 10 and Excel 2019. It is the example code and the xlsx file: [images.zip](https://github.com/jmcnamara/XlsxWriter/files/7778964/images.zip) ![Scale1](https://user-images.githubusercontent.com/77141948/147447415-7e1600f8-208d-4a56-88b7-347e21e422e7.png) In addition, the font used in Excel is Chinese Song Ti. Maybe it's an error caused by the font? ![Scale2](https://user-images.githubusercontent.com/77141948/147447489-6c801f54-251f-4185-874b-245bf071d590.png) thank you very much
Author
Owner

@jmcnamara commented on GitHub (Dec 27, 2021):

In addition, the font used in Excel is Chinese Song Ti. Maybe it's an error caused by the font?

That is probably the issue. The scaling calculations for images are based on the font Calibri and size 11.

How are you changing the default font to Song Ti?

<!-- gh-comment-id:1001486060 --> @jmcnamara commented on GitHub (Dec 27, 2021): > In addition, the font used in Excel is Chinese Song Ti. Maybe it's an error caused by the font? That is probably the issue. The scaling calculations for images are based on the font Calibri and size 11. How are you changing the default font to Song Ti?
Author
Owner

@Robinhao2k commented on GitHub (Dec 27, 2021):

Thank you for your reply.
My operating system is Chinese Simplified Windows operating system. So I guess the default font of Excel is Chinese Song Ti. I set the default font to Calibri, size 11.
Option

then open "images.xlsx" again, but Chinese Song Ti is still the default font.
Font1

when I create a new xlsx document, Excel uses Calibri as the default font.
Font2

How can I use Calibri font as the default font to open images.xlsx document?

<!-- gh-comment-id:1001521212 --> @Robinhao2k commented on GitHub (Dec 27, 2021): Thank you for your reply. My operating system is Chinese Simplified Windows operating system. So I guess the default font of Excel is Chinese Song Ti. I set the default font to Calibri, size 11. ![Option](https://user-images.githubusercontent.com/77141948/147467454-0513737b-dcaa-44c4-a41d-eac6766aca1d.png) then open "images.xlsx" again, but Chinese Song Ti is still the default font. ![Font1](https://user-images.githubusercontent.com/77141948/147467477-2a4495ca-5652-4957-8d5f-3f104abe8ffd.png) when I create a new xlsx document, Excel uses Calibri as the default font. ![Font2](https://user-images.githubusercontent.com/77141948/147467495-65ac9bc0-f63e-45dd-bacf-5d644b270907.png) How can I use Calibri font as the default font to open images.xlsx document?
Author
Owner

@jmcnamara commented on GitHub (Dec 28, 2021):

Transferred issue to the libxlsxwriter Github.

<!-- gh-comment-id:1002275078 --> @jmcnamara commented on GitHub (Dec 28, 2021): Transferred issue to the libxlsxwriter Github.
Author
Owner

@jmcnamara commented on GitHub (Dec 29, 2021):

Probably there is some other system setting where the default font is set. Setting the default font in Excel won't change the font when you are reading files.

Can you try with this test file created in Excel and see if you get the same behaviour: https://github.com/jmcnamara/libxlsxwriter/blob/main/test/functional/xlsx_files/image10.xlsx

<!-- gh-comment-id:1002775119 --> @jmcnamara commented on GitHub (Dec 29, 2021): Probably there is some other system setting where the default font is set. Setting the default font in Excel won't change the font when you are reading files. Can you try with this test file created in Excel and see if you get the same behaviour: https://github.com/jmcnamara/libxlsxwriter/blob/main/test/functional/xlsx_files/image10.xlsx
Author
Owner

@jmcnamara commented on GitHub (Jan 3, 2022):

Any update on this?

<!-- gh-comment-id:1004309614 --> @jmcnamara commented on GitHub (Jan 3, 2022): Any update on this?
Author
Owner

@Robinhao2k commented on GitHub (Jan 4, 2022):

Sorry, I haven't noticed your reply these days. I tested your file. It seems that there is still the same problem. Please see my screen copy. Note, this time I am using the Chinese version of Excel.
QQ截图20220104145934
.

<!-- gh-comment-id:1004571827 --> @Robinhao2k commented on GitHub (Jan 4, 2022): Sorry, I haven't noticed your reply these days. I tested your file. It seems that there is still the same problem. Please see my screen copy. Note, this time I am using the Chinese version of Excel. ![QQ截图20220104145934](https://user-images.githubusercontent.com/77141948/148021919-96cdfabb-c87e-46d6-a84d-17a29a55ba83.png) .
Author
Owner

@jmcnamara commented on GitHub (Jan 4, 2022):

That file was created in Excel. So this issue isn't related to libxlsxwriter (which produces the same file and dimensions as Excel).

I don't any good suggestions on how to deal with this:

  • You could scale the image in libxlsxwriter so that it is 100% x100% in Excel - but this will distort the image if you share it with anyone with a non Chinese version of Excel.
  • Change the system font used by Excel - however this would probably effect other programs as well so that probably isn't a good solution.

Any way this isn't a libxlsxwriter issue. Libxlsxwriter has a lot of code and tests to ensure that it inserts images in exactly the same way as Excel.

So, since I cannot help you any further I will close this issue.

<!-- gh-comment-id:1004656811 --> @jmcnamara commented on GitHub (Jan 4, 2022): That file was created in Excel. So this issue isn't related to libxlsxwriter (which produces the same file and dimensions as Excel). I don't any good suggestions on how to deal with this: - You could scale the image in libxlsxwriter so that it is 100% x100% in Excel - but this will distort the image if you share it with anyone with a non Chinese version of Excel. - Change the system font used by Excel - however this would probably effect other programs as well so that probably isn't a good solution. Any way this isn't a libxlsxwriter issue. Libxlsxwriter has a lot of code and tests to ensure that it inserts images in exactly the same way as Excel. So, since I cannot help you any further I will close this issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#287
No description provided.