jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.49k stars 332 forks source link

question: <The picture shows the wrong scale> #363

Closed totaldmis closed 2 years ago

totaldmis commented 2 years ago

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

jmcnamara commented 2 years ago

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?

totaldmis commented 2 years ago

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?

jmcnamara commented 2 years ago

Transferred issue to the libxlsxwriter Github.

jmcnamara commented 2 years ago

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

jmcnamara commented 2 years ago

Any update on this?

totaldmis commented 2 years ago

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 .

jmcnamara commented 2 years ago

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:

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.