Fix XLSX vertical alignment being set to top when only horizontal alignment is set#32
Fix XLSX vertical alignment being set to top when only horizontal alignment is set#32gtbuchanan wants to merge 1 commit into
Conversation
|
general is available value for horizontal but not for vertical in Excel. The default value of vertical should be center as Excel UI shows. According to my test, vertical attribute is always set by Excel. The only difference is that the default value is center instead of top. |
|
I'll set the default value of vertical attribute to center. |
|
I disagree with your decision. "general" is not an actual XML value for either alignment. It is simply used to mean the attribute does not exist. "ST_HorizontalAlignment.general" is only used in one place in code to determine if the XML attribute should be written back to the file at all. I created a enumeration called "ST_VerticalAlignment.general" and used the exact same logic currently used for horizontal alignment. I think the name "general" is horrible, but I used it to keep the code consistent. As you can see below, the default vertical alignment is bottom; not center as you suggest. And by default, there is no alignment attribute written to the file at all. However, the attribute is written to the file when I change the vertical alignment to top. My proposed changes mimic this behavior. |
….pow() with multiplication. Thanks to Daniel Kuan! This closes nissl-lab#32.

I am using an existing XLSX file as a template. On some cells, only the horizontal alignment is set to something other than the default. When this is the case, an "alignment" node exists in the XML. The CT_CellAlignment class is currently setting the vertical alignment to top when a "vertical" attribute does not even exist on the "alignment" node. The default vertical value in Excel is bottom align, so most of my cell alignment is being overridden with top when I write to the file.