weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.28k stars 255 forks source link

[Q] About get_row_height default value. #214

Closed hiroyuki-sato closed 8 years ago

hiroyuki-sato commented 8 years ago

About default height value 13. Is this size MS Excel on Windows?

I'm using Excel 2011 on OSX. The height size is 18.

https://github.com/weshatheleopard/rubyXL/blob/master/lib/rubyXL/convenience_methods.rb#L384

def get_row_height(row = 0)
  validate_workbook
  validate_nonnegative(row)
  row = sheet_data.rows[row]
  row && row.ht || 13
end
weshatheleopard commented 8 years ago

This code remains from the old old old version 1.0 which was written by @vivekbhagwat, you can ask him.

hiroyuki-sato commented 8 years ago

@weshatheleopard Thanks!!

Could you review this patch? https://github.com/weshatheleopard/rubyXL/pull/215

I'll set default height by myself if height is nil.

weshatheleopard commented 8 years ago

Why is this issue mission critical for you? What are you trying to do?

"Convenience methods" are intended to simplify the code you write, for the price of limiting things you can do. If you need the "raw" row height, you can just do row && row.ht ; you don't need a convenience method for that.

hiroyuki-sato commented 8 years ago

@weshatheleopard Thank you for replying.

I'll use row && row.ht. It is simple.

I thought I can use get_column_width_raw , I want to use get_row_height_raw too. Until I read source code, I didn't know get_row_height return default value if it has not height value

weshatheleopard commented 8 years ago

The reason that get_column_width_raw is that it is measured in pixels, while get_column_width is measured in "characters", see http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx

row_height is measured differently and does not really require complex conversion like that.