简体   繁体   English

不同计算机上的列宽不同

[英]Column width is different on different computers

I need to provide custom column width for my excel.我需要为我的 excel 提供自定义列宽。 I'm achieving it with a getColumn method by setting a number of points to width property.我通过将一些点设置为宽度属性来使用getColumn方法来实现它。

Main question is why on different computers I'm getting different column width both in pixels and points.主要问题是为什么在不同的计算机上我得到不同的像素和点的列宽。 Is it possible to have same value (at least in points) for all exported excels?所有导出的 excel 是否可以具有相同的值(至少以点为单位)?

For example the width of column is set to 16 points: on first computer I got 15.36 points and 176px , on the second - 15.29 points and 112px .例如,列的宽度设置为 16 点:在第一台计算机上我得到15.36 points176px ,在第二台计算机上 - 15.29 points112px

Additional question: is it happening because of different monitor resolutions or because of excel settings?附加问题:这是因为不同的显示器分辨率还是因为 excel 设置?

This should work (according to the docs ):这应该有效(根据文档):

  1. Specify the style of your columns, eg Normal , and specify the Font and Font Size of that style on the source computer that creates the workbook.指定列的样式,例如Normal ,并在创建工作簿的源计算机上指定该样式的FontFont Size
  2. Explicitly set the Font and Font size of Normal Style on the target computer's Excel when opening the file to match that of the source computer.在打开文件时,在目标计算机的 Excel 上显式设置Normal Style 的FontFont size以匹配源计算机的 Font 和 Font size。

By doing this you will have matched styles on the source and target computers, and hence experience the same column width.通过这样做,您将在源计算机和目标计算机上匹配 styles,因此会遇到相同的列宽。

PS: I'm assuming here that you are not using any Style other than Normal . PS:我在这里假设您没有使用除Normal以外的任何 Style 。 If you are, then you will of course need to approach these styles appropriately.如果您是,那么您当然需要适当地接近这些 styles。

The reason is different fonts available on each OS.原因是每个操作系统上可用的 fonts 不同。 Following by Ecma-376, widths and heights has digit size as a unit ( ch or em unit from css).在 Ecma-376 之后,宽度和高度以数字大小为单位(css 中的chem单位)。 Setting sizes should work perfectly with an available font for all OS.设置大小应该与所有操作系统的可用字体完美配合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM