Sha256: c511022b2d96296c4e8cec1b5c51af54631ce63d09cc297a5ed01148884b1e45
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require "csv" require "csv/excel/version" class CSV module Excel UTF8BOM = -"\xEF\xBB\xBF" class Error < StandardError; end def initialize(data, **options) @for_excel = options.delete(:for_excel) options[:force_quotes] = true if @for_excel super(data, **options) end private def writer_options super.merge(for_excel: @for_excel) end end class Writer module Excel DATE_FORMAT = -"%Y/%m/%d" TIME_FORMAT = -"%Y/%m/%d %H:%M:%S" 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) encoded_assign_character + quoted else super end end end end end CSV.prepend CSV::Excel CSV::Writer.prepend CSV::Writer::Excel
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv-excel-0.1.0 | lib/csv/excel.rb |