lib/axlsx/stylesheet/styles.rb in axlsx-1.0.8 vs lib/axlsx/stylesheet/styles.rb in axlsx-1.0.9

- old
+ new

@@ -195,53 +195,53 @@ numFmts << NumFmt.new(:numFmtId => n, :formatCode=> options[:format_code]) n else options[:num_fmt] || 0 end - + borderId = options[:border] || 0 raise ArgumentError, "Invalid borderId" unless borderId < borders.size - + fill = if options[:bg_color] color = Color.new(:rgb=>options[:bg_color]) pattern = PatternFill.new(:patternType =>:solid, :fgColor=>color) fills << Fill.new(pattern) else 0 end - + fontId = if (options.values_at(:fg_color, :sz, :b, :i, :strike, :outline, :shadow, :charset, :family, :font_name).length) font = Font.new() [:b, :i, :strike, :outline, :shadow, :charset, :family, :sz].each { |k| font.send("#{k}=", options[k]) unless options[k].nil? } font.color = Color.new(:rgb => options[:fg_color]) unless options[:fg_color].nil? font.name = options[:font_name] unless options[:font_name].nil? fonts << font else 0 end - - applyProtection = (options[:hidden] || options[:locked]) ? 1 : 0 - + + applyProtection = (options[:hidden] || options[:locked]) ? 1 : 0 + xf = Xf.new(:fillId => fill, :fontId=>fontId, :applyFill=>1, :applyFont=>1, :numFmtId=>numFmtId, :borderId=>borderId, :applyProtection=>applyProtection) - + if options[:alignment] xf.alignment = CellAlignment.new(options[:alignment]) end if applyProtection xf.protection = CellProtection.new(options) end - + cellXfs << xf - end - + end + # Serializes the styles document # @return [String] def to_xml() builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml| xml.styleSheet(:xmlns => XML_NS) { - [:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :dxfs, :tableStyles].each do |key| + [:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key| self.instance_values[key.to_s].to_xml(xml) end } end builder.to_xml @@ -278,10 +278,10 @@ @cellStyleXfs = SimpleTypedList.new Xf, "cellStyleXfs" @cellStyleXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0) @cellStyleXfs.lock @cellStyles = SimpleTypedList.new CellStyle - @cellStyles << CellStyle.new(:name =>"標準", :builtinId =>0, :xfId=>0) + @cellStyles << CellStyle.new(:name =>"Normal", :builtinId =>0, :xfId=>0) @cellStyles.lock @cellXfs = SimpleTypedList.new Xf, "cellXfs" @cellXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0) @cellXfs << Xf.new(:borderId=>1, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)