47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/xlsx_drone/sheet.rb', line 47
def read_cell(row, column)
XLSXDrone::NativeBinding.xlsx_read_cell(@native_sheet, row, column, @native_cell)
if(@native_cell[:style].null?)
case @native_cell[:value_type]
when 0
@native_cell[:value][:pointer_to_char_value].get_string(0).force_encoding(Encoding::UTF_8)
when 1
@native_cell[:value][:int_value]
when 2
@native_cell[:value][:long_long_value]
when 3
@native_cell[:value][:double_value]
else
nil
end
else
address = @native_cell[:style].address
if(!(@styles.has_key?(address)))
style_obj = XLSXDrone::NativeBinding::XLSXStyleT.new(@native_cell[:style])
@styles[address] = style_obj[:related_category]
end
case @styles[address]
when 2
if(@native_cell[:value_type] == 0)
@native_cell[:value][:pointer_to_char_value].get_string(0).force_encoding(Encoding::UTF_8)
else
Time.new(1900) + ((@native_cell[:value][:int_value] - 2) * 86400)
end
when 4
case(@native_cell[:value_type])
when 0
@native_cell[:value][:pointer_to_char_value].get_string(0).force_encoding(Encoding::UTF_8)
when 1
Time.new(1900) + ((@native_cell[:value][:int_value] - 2) * 86400)
else
match = @native_cell[:value][:double_value].to_s.match(/(\d+)\.(\d+)/)
integral_part = match[1].to_i
floating_part = "0.#{match[2]}".to_f
Time.new(1900) + ((integral_part - 2) * 86400) + (floating_part * 86400)
end
when 0
case @native_cell[:value_type]
when 1
@native_cell[:value][:int_value]
when 2
@native_cell[:value][:long_long_value]
when 3
@native_cell[:value][:double_value]
else
nil
end
when 1
@native_cell[:value][:pointer_to_char_value].get_string(0).force_encoding(Encoding::UTF_8)
when 3
(Time.new(1900) + (@native_cell[:value][:double_value] * 86400)).strftime("%H:%M:%S")
else
case @native_cell[:value_type]
when 0
@native_cell[:value][:pointer_to_char_value].get_string(0).force_encoding(Encoding::UTF_8)
when 1
@native_cell[:value][:int_value]
when 2
@native_cell[:value][:long_long_value]
when 3
@native_cell[:value][:double_value]
else
nil
end
end
end
end
|