Module: CSV::Writer::Excel

Included in:
CSV::Writer
Defined in:
lib/csv/excel.rb

Constant Summary collapse

DATE_FORMAT =
-"%Y/%m/%d"
TIME_FORMAT =
-"%Y/%m/%d %H:%M:%S"

Instance Method Summary collapse

Instance Method Details

#quote_field(field) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/csv/excel.rb', line 27

def quote_field(field)
  return super unless @options[:for_excel]

  case field
  when Date
    super(field.strftime(DATE_FORMAT))
  when Time, DateTime
    super(field.strftime(TIME_FORMAT))
  when String
    quoted = super
    encoded_assign_character = "=".encode(quoted.encoding)
    super(encoded_assign_character + quoted)
  else
    super
  end
end