caxlsx 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +7 -0
  3. data/examples/{image1.jpeg → assets/image1.jpeg} +0 -0
  4. data/examples/generate.rb +15 -0
  5. data/lib/axlsx.rb +1 -0
  6. data/lib/axlsx/drawing/pie_series.rb +1 -1
  7. data/lib/axlsx/package.rb +17 -4
  8. data/lib/axlsx/util/constants.rb +2 -1
  9. data/lib/axlsx/util/zip_command.rb +73 -0
  10. data/lib/axlsx/version.rb +1 -1
  11. data/lib/axlsx/workbook/worksheet/cell.rb +4 -2
  12. data/test/drawing/tc_drawing.rb +2 -2
  13. data/test/drawing/tc_hyperlink.rb +1 -1
  14. data/test/drawing/tc_one_cell_anchor.rb +1 -1
  15. data/test/drawing/tc_pic.rb +4 -4
  16. data/test/drawing/tc_pie_series.rb +2 -1
  17. data/test/fixtures/image1.gif +0 -0
  18. data/test/fixtures/image1.jpeg +0 -0
  19. data/test/fixtures/image1.jpg +0 -0
  20. data/test/fixtures/image1.png +0 -0
  21. data/test/fixtures/image1_fake.jpg +0 -0
  22. data/test/tc_package.rb +29 -12
  23. data/test/util/tc_mime_type_utils.rb +1 -1
  24. data/test/workbook/worksheet/tc_cell.rb +31 -0
  25. metadata +18 -39
  26. data/examples/2010_comments.rb +0 -17
  27. data/examples/anchor_swapping.rb +0 -28
  28. data/examples/auto_filter.rb +0 -25
  29. data/examples/basic_charts.rb +0 -58
  30. data/examples/chart_colors.rb +0 -88
  31. data/examples/colored_links.rb +0 -45
  32. data/examples/conditional_formatting/example_conditional_formatting.rb +0 -89
  33. data/examples/conditional_formatting/getting_barred.rb +0 -37
  34. data/examples/conditional_formatting/hitting_the_high_notes.rb +0 -37
  35. data/examples/conditional_formatting/scaled_colors.rb +0 -39
  36. data/examples/conditional_formatting/stop_and_go.rb +0 -37
  37. data/examples/data_validation.rb +0 -67
  38. data/examples/example.rb +0 -900
  39. data/examples/extractive.rb +0 -45
  40. data/examples/ios_preview.rb +0 -14
  41. data/examples/merge_cells.rb +0 -17
  42. data/examples/no_grid_with_borders.rb +0 -18
  43. data/examples/page_setup.rb +0 -11
  44. data/examples/pivot_table.rb +0 -39
  45. data/examples/pivot_test.rb +0 -63
  46. data/examples/sheet_protection.rb +0 -10
  47. data/examples/skydrive/real_example.rb +0 -63
  48. data/examples/split.rb +0 -16
  49. data/examples/styles.rb +0 -66
  50. data/examples/underline.rb +0 -13
  51. data/examples/wrap_text.rb +0 -21
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
-
4
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
5
- require 'axlsx'
6
-
7
- data = [ ['oil-bbl',9591.411671,8860.714604,8237.936509,7700.523067,7231.831842,6819.307902,6453.297235,6126.251755,5832.182748,5566.276532,5324.618706,5103.992757,4901.730597,4715.600022,4543.718862,4384.488699,4236.543136,4098.707009,3969.963937,3849.430276,3736.33405,3629.997786,3529.824424,3435.28568,3345.912388,3261.286414,3181.033882,3104.819438,3032.341401,2963.327615,2897.531915,2834.731083,2774.722219,2717.320479,2662.357097,2609.677666,2559.140642,2510.616021,2463.984182,2419.134871,2375.966292,2334.384311,2294.301748,2255.637735,2218.317165,2182.270173,2147.431696,2113.741056,2081.141602,2049.580377,2019.007821,1989.377502,1960.645871,1932.772042,1905.71759,1879.446367,1853.924338,1829.119424,1805.001366,1781.541597,1758.713122,1736.490414,1714.849315,1693.766943,1673.22161,1653.192744,1633.660817,1614.607284,1596.014514,1577.865741,1560.145009,1542.837121,1525.927597,1509.402632,1493.249056,1477.454298,1462.006352,1446.893746,1432.105512,1417.631159,1403.460647,1389.584361,1375.993094,1362.678018,1349.630672,1336.842938,1324.307026,1312.015455,1299.961043,1288.136885,1276.536347,1265.153047,1253.980847,1243.013838,1232.246332,1221.672852,1211.288119,1201.087047,1191.064732,1181.216443,1171.537618,1162.023853,1152.670896,1143.474642,1134.431125,1125.536513,1116.787101,1108.179309,1099.709672,1091.37484,1083.171571,1075.096725,1067.147265,1059.320247,1051.612821,1044.022223,1036.545778,1029.180889,1021.92504,1014.775789],
8
-
9
- ['gas-mcf', 940970.153,836556.732,748476.939,673307.64,608520.158,552204.935,502892.3,459432.263,420911.806,386596.658,355889.491,328299.357,303418.988,280907.679,260478.232,241886.857,224925.287,209414.552,195200.029,182147.455,170139.707,159074.174,148860.596,139419.282,130679.626,122578.864,115061.035,108076.1,101579.19,95529.972,89892.104,84632.762,79722.24,75133.597,70842.349,66826.213,63064.865,59539.742,56233.86,53131.662,50218.869,47482.365,44910.082,42490.907,40214.588,38071.662,36053.382,34151.656,32358.989,30668.434,29073.545,27568.334,26147.237,24805.079,23537.041,22338.633,21205.67,20134.246,19120.717,18161.677,17253.941,16394.533,15580.663,14809.724,14079.269,13387.006,12730.786,12108.59,11518.524,10958.809,10427.774,9923.847,9445.55,8991.492,8560.364,8150.934,7762.041,7392.59,7041.551,6707.951,6390.874,6089.452,5802.871,5530.358,5271.185,5024.664,4790.145,4567.013,4354.687,4152.618,3960.286,3777.198,3602.889,3436.919,3278.87,3128.347,2984.976,2848.401,2718.287,2594.316,2476.184,2363.606,2256.309,2154.037,2056.545,1963.599,1874.982,1790.482,1709.903,1633.054,1559.758,1489.844,1423.151,1359.525,1298.821,1240.899,1185.628,1132.883,1082.544,1034.499],
10
-
11
- ['water-bbl',940.97,836.557,748.477,673.308,608.52,552.205,502.892,459.432,420.912,386.597,355.889,328.299,303.419,280.908,260.478,241.887,224.925,209.415,195.2,182.147,170.14,159.074,148.861,139.419,130.68,122.579,115.061,108.076,101.579,95.53,89.892,84.633,79.722,75.134,70.842,66.826,63.065,59.54,56.234,53.132,50.219,47.482,44.91,42.491,40.215,38.072,36.053,34.152,32.359,30.668,29.074,27.568,26.147,24.805,23.537,22.339,21.206,20.134,19.121,18.162,17.254,16.395,15.581,14.81,14.079,13.387,12.731,12.109,11.519,10.959,10.428,9.924,9.446,8.991,8.56,8.151,7.762,7.393,7.042,6.708,6.391,6.089,5.803,5.53,5.271,5.025,4.79,4.567,4.355,4.153,3.96,3.777,3.603,3.437,3.279,3.128,2.985,2.848,2.718,2.594,2.476,2.364,2.256,2.154,2.057,1.964,1.875,1.79,1.71,1.633,1.56,1.49,1.423,1.36,1.299,1.241,1.186,1.133,1.083,1.034] ]
12
-
13
- p = Axlsx::Package.new
14
- wb = p.workbook
15
- wb.add_worksheet(:name => 'volumes') do |ws|
16
-
17
- # perspective, rotX and rotY flatten the 3D chart
18
- # hPercent sets the chart height to 100%
19
- chart = ws.add_chart(Axlsx::Line3DChart, :perspective => 0, :hPercent => 100, :rotX => 0, :rotY => 0, :start_at => "A4", :end_at => 'M44', :title => 'Monthly forcast for Type Curve Gas secondary - gross ngl')
20
-
21
- # Set up log based scaling and appropriate min/max values for Y axis
22
- chart.valAxis.scaling.logBase = 10
23
- chart.valAxis.scaling.min = 0.1
24
- chart.valAxis.scaling.max = 10000000.0
25
-
26
- # No poing in showing the series axis labels as the chart is flattened!
27
- chart.serAxis.delete = true
28
-
29
- # Knock the catAxis labels down to the forced min.
30
- chart.catAxis.crosses = :min
31
-
32
- # set up cat labels / markes to show every 12th item
33
- chart.catAxis.tickLblSkip = 12
34
- chart.catAxis.tickMarkSkip = 12
35
-
36
- #rgb colors for our data series
37
- colors = ['00FF00', 'FF0000', '0000FF']
38
-
39
- data.each_with_index do |value, index|
40
- ws.add_row value
41
- chart.add_series :data => ws.rows.last.cells[(1..value.size-1)], :labels => (0..value.size).map{ |i| i }, :title => ws.rows.last.cells.first, :color => colors[index]
42
- end
43
- end
44
-
45
- p.serialize 'extractive.xlsx'
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
-
5
- #```ruby
6
- require 'axlsx'
7
-
8
- p = Axlsx::Package.new
9
- p.use_shared_strings = true
10
- s = p.workbook.add_worksheet(:name => "Formula test")
11
- s.add_row [1, 2, 3]
12
- s.add_row %w(a b c)
13
- s.add_row ["=SUM(A1:C1)"], :formula_values => [6]
14
- p.serialize "ios_preview.xlsx"
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
-
5
- #```ruby
6
- require 'axlsx'
7
- package = Axlsx::Package.new
8
- package.workbook do |workbook|
9
- workbook.add_worksheet name: 'merged_cells' do |sheet|
10
- 4.times do
11
- sheet.add_row %w(a b c d e f g)
12
- end
13
- sheet.merge_cells "A1:A2"
14
- sheet.merge_cells "B1:B2"
15
- end
16
- end
17
- package.serialize 'merged_cells.xlsx'
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
-
5
- #```ruby
6
- require 'axlsx'
7
- package = Axlsx::Package.new
8
- package.workbook do |workbook|
9
- workbook.styles do |s|
10
- gridstyle_border = s.add_style :border => { :style => :thin, :color =>"FFCDCDCD" }
11
- workbook.add_worksheet :name => "Custom Borders" do |sheet|
12
- sheet.sheet_view.show_grid_lines = false
13
- sheet.add_row ["with", "grid", "style"], :style => gridstyle_border
14
- sheet.add_row ["no", "border"]
15
- end
16
- end
17
- end
18
- package.serialize 'no_grid_with_borders.xlsx'
@@ -1,11 +0,0 @@
1
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
- require 'axlsx'
3
- xls = Axlsx::Package.new
4
- wb = xls.workbook
5
- wb.add_worksheet do |ws|
6
- # Excel does not currently follow the specification and will ignore paper_width and paper_height so if you need
7
- # to for a paper size, be sure to set :paper_size
8
- ws.page_setup.set :paper_width => "210mm", :paper_size => 10, :paper_height => "297mm", :orientation => :landscape
9
- ws.add_row %w(AXLSX is cool)
10
- end
11
- xls.serialize "page_setup.xlsx"
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
-
4
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
5
- require 'axlsx'
6
-
7
- p = Axlsx::Package.new
8
- wb = p.workbook
9
-
10
- # Create some data in a sheet
11
- def month
12
- %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec).sample
13
- end
14
- def year
15
- %w(2010 2011 2012).sample
16
- end
17
- def type
18
- %w(Meat Dairy Beverages Produce).sample
19
- end
20
- def sales
21
- rand(5000)
22
- end
23
- def region
24
- %w(East West North South).sample
25
- end
26
-
27
- wb.add_worksheet(:name => "Data Sheet") do |sheet|
28
- sheet.add_row ['Month', 'Year', 'Type', 'Sales', 'Region']
29
- 30.times { sheet.add_row [month, year, type, sales, region] }
30
- sheet.add_pivot_table 'G4:L17', "A1:E31" do |pivot_table|
31
- pivot_table.rows = ['Month', 'Year']
32
- pivot_table.columns = ['Type']
33
- pivot_table.data = ['Sales']
34
- pivot_table.pages = ['Region']
35
- end
36
- end
37
-
38
- # Write the excel file
39
- p.serialize("pivot_table.xlsx")
@@ -1,63 +0,0 @@
1
- class RandomReportGenerator
2
- def date
3
- Date.today.strftime("%m/%d/%Y")
4
- end
5
- def member_id
6
- @i ||= 0
7
- @i += 1
8
- end
9
- def name
10
- "John S."
11
- end
12
- def gender
13
- ["Male", "Female"].sample
14
- end
15
- def age
16
- rand(100)
17
- end
18
- def city
19
- ["New York", "Mountain View", "Newark", "Phoenix"].sample
20
- end
21
- def state
22
- ["NY", "CA", "NJ", "AZ"].sample
23
- end
24
- def parenting
25
- "Foo"
26
- end
27
- def student
28
- "Bar"
29
- end
30
- def income
31
- "Bar"
32
- end
33
- def education
34
- "Bar"
35
- end
36
- def answer
37
- ["Yes", "No", "Maybe", "I dont know"].sample
38
- end
39
- def run
40
- package = Axlsx::Package.new
41
- workbook = package.workbook
42
-
43
- workbook.add_worksheet(:name => "Data Sheet") do |sheet|
44
- sheet.add_row [
45
- "Date", "Member ID", "Name", "Gender", "Age", "City", "State",
46
- "Parenting Status", "Student Status", "Income", "Education", "Answer"
47
- ]
48
- 30.times do
49
- sheet.add_row [date, member_id, name, gender, age, city, state,
50
- parenting, student, income, education, answer]
51
- end
52
- end
53
-
54
- workbook.add_worksheet(:name => "Summary") do |sheet|
55
- pivot_table = Axlsx::PivotTable.new 'A1:B15', "A1:L31", workbook.worksheets[0]
56
- pivot_table.rows = ['Answer']
57
- pivot_table.data = [{:ref => "Member ID", :subtotal => "count"}]
58
- sheet.pivot_tables << pivot_table
59
- end
60
-
61
- package.serialize("pivot_table.xlsx")
62
- end
63
- end
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
- require 'axlsx'
5
-
6
- p = Axlsx::Package.new
7
- p.workbook.add_worksheet(:name => 'Open Office') { |ws| ws.sheet_protection.password = 'fish' }
8
- p.serialize 'sheet_protection.xlsx'
9
-
10
-
@@ -1,63 +0,0 @@
1
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
2
-
3
- require 'axlsx'
4
-
5
- Axlsx::Package.new do |p|
6
- p.workbook do |wb|
7
- styles = wb.styles
8
- header = styles.add_style :bg_color => "DD", :sz => 16, :b => true, :alignment => {:horizontal => :center}
9
- tbl_header = styles.add_style :b => true, :alignment => { :horizontal => :center }
10
- ind_header = styles.add_style :bg_color => "FFDFDEDF", :b => true, :alignment => {:indent => 1}
11
- col_header = styles.add_style :bg_color => "FFDFDEDF", :b => true, :alignment => { :horizontal => :center }
12
- label = styles.add_style :alignment => { :indent => 1 }
13
- money = styles.add_style :num_fmt => 5
14
- t_label = styles.add_style :b => true, :bg_color => "FFDFDEDF"
15
- t_money = styles.add_style :b => true, :num_fmt => 5, :bg_color => "FFDFDEDF"
16
-
17
- wb.add_worksheet do |sheet|
18
- sheet.add_row
19
- sheet.add_row [nil, "College Budget"], :style => [nil, header]
20
- sheet.add_row
21
- sheet.add_row [nil, "What's coming in this month.", nil, nil, "How am I doing"], :style => tbl_header
22
- sheet.add_row [nil, "Item", "Amount", nil, "Item", "Amount"], :style => [nil, ind_header, col_header, nil, ind_header, col_header]
23
- sheet.add_row [nil, "Estimated monthly net income", 500, nil, "Monthly income", "=C9"], :style => [nil, label, money, nil, label, money]
24
- sheet.add_row [nil, "Financial aid", 100, nil, "Monthly expenses", "=C27"], :style => [nil, label, money, nil, label, money]
25
- sheet.add_row [nil, "Allowance from mom & dad", 20000, nil, "Semester expenses", "=F19"], :style => [nil, label, money, nil, label, money]
26
- sheet.add_row [nil, "Total", "=SUM(C6:C8)", nil, "Difference", "=F6 - SUM(F7:F8)"], :style => [nil, t_label, t_money, nil, t_label, t_money]
27
- sheet.add_row
28
- sheet.add_row [nil, "What's going out this month.", nil, nil, "Semester Costs"], :style => tbl_header
29
- sheet.add_row [nil, "Item", "Amount", nil, "Item", "Amount"], :style => [nil, ind_header, col_header, nil, ind_header, col_header]
30
- sheet.add_row [nil, "Rent", 650, nil, "Tuition", 200], :style => [nil, label, money, nil, label, money]
31
- sheet.add_row [nil, "Utilities", 120, nil, "Lab fees", 50], :style => [nil, label, money, nil, label, money]
32
- sheet.add_row [nil, "Cell phone", 100, nil, "Other fees", 10], :style => [nil, label, money, nil, label, money]
33
- sheet.add_row [nil, "Groceries", 75, nil, "Books", 150], :style => [nil, label, money, nil, label, money]
34
- sheet.add_row [nil, "Auto expenses", 0, nil, "Deposits", 0], :style => [nil, label, money, nil, label, money]
35
- sheet.add_row [nil, "Student loans", 0, nil, "Transportation", 30], :style => [nil, label, money, nil, label, money]
36
- sheet.add_row [nil, "Other loans", 350, nil, "Total", "=SUM(F13:F18)"], :style => [nil, label, money, nil, t_label, t_money]
37
- sheet.add_row [nil, "Credit cards", 450], :style => [nil, label, money]
38
- sheet.add_row [nil, "Insurance", 0], :style => [nil, label, money]
39
- sheet.add_row [nil, "Laundry", 10], :style => [nil, label, money]
40
- sheet.add_row [nil, "Haircuts", 0], :style => [nil, label, money]
41
- sheet.add_row [nil, "Medical expenses", 0], :style => [nil, label, money]
42
- sheet.add_row [nil, "Entertainment", 500], :style => [nil, label, money]
43
- sheet.add_row [nil, "Miscellaneous", 0], :style => [nil, label, money]
44
- sheet.add_row [nil, "Total", "=SUM(C13:C26)"], :style => [nil, t_label, t_money]
45
- sheet.add_chart(Axlsx::Pie3DChart) do |chart|
46
- chart.title = sheet["B11"]
47
- chart.add_series :data => sheet["C13:C26"], :labels => sheet["B13:B26"]
48
- chart.start_at 7, 2
49
- chart.end_at 12, 15
50
- end
51
- sheet.add_chart(Axlsx::Bar3DChart, :barDir => :col) do |chart|
52
- chart.title = sheet["E11"]
53
- chart.add_series :labels => sheet["E13:E18"], :data => sheet["F13:F18"]
54
- chart.start_at 7, 16
55
- chart.end_at 12, 31
56
- end
57
- %w(B4:C4 E4:F4 B11:C11 E11:F11 B2:F2).each { |range| sheet.merge_cells(range) }
58
- sheet.column_widths 2, nil, nil, 2, nil, nil, 2
59
- end
60
- end
61
- p.use_shared_strings = true
62
- p.serialize 'axlsx.xlsx'
63
- end
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
- require 'axlsx'
5
- p = Axlsx::Package.new
6
- wb = p.workbook
7
- wb.add_worksheet name: 'pane' do |sheet|
8
- sheet.sheet_view.pane do |pane|
9
- pane.top_left_cell = "B2"
10
- pane.state = :frozen_split
11
- pane.y_split = 2
12
- pane.x_split = 1
13
- pane.active_pane = :bottom_right
14
- end
15
- end
16
- p.serialize 'pane.xlsx'
@@ -1,66 +0,0 @@
1
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
- require 'axlsx'
3
- require 'date'
4
-
5
- p = Axlsx::Package.new
6
- wb = p.workbook
7
- wb.styles do |style|
8
-
9
- # Date/Time Styles
10
- #
11
- # The most important thing to remember about OOXML styles is that they are
12
- # exclusive. This means that each style must define all the components it
13
- # requires to render the cell the way you want. A good example of this is
14
- # changing the font size for a date. You cannot specify just the font size,
15
- # you must also specify the number format or format code so that renders
16
- # know how to display the serialized date float value
17
- #
18
- # The parts that make up a custom styles are:
19
- #
20
- # fonts(Font), fills(Fill), borders(Border) and number formats(NumFmt).
21
- # Getting to know those classes will help you make the most out of custom
22
- # styling. However axlsx certainly does not expect you to create all those
23
- # objects manually.
24
- #
25
- # workbook.styles.add_style provides a helper method 'add_style' for defining
26
- # styles in one go. The docs for that method are definitely worth a read.
27
- # @see Style#add_style
28
-
29
- # When no style is applied to a cell, axlsx will automatically apply date/time
30
- # formatting to Date and Time objects for you. However, if you are defining
31
- # custom styles, you define all aspects of the style you want to apply.
32
- #
33
- # An aside on styling and auto-width. Auto-width calculations do not
34
- # currently take into account any style or formatting you have applied to the
35
- # data in your cells as it would require the creation of a rendering engine,
36
- # and frankly kill performance. If you are doing a lot of custom formatting,
37
- # you are going to be better served by specifying fixed column widths.
38
- #
39
- # Let's look at an example:
40
- #
41
- # A style that only applies a font size
42
- large_font = wb.styles.add_style :sz => 20
43
-
44
- # A style that applies both a font size and a predefined number format.
45
- # @see NumFmt
46
- predefined_format = wb.styles.add_style :sz => 20, :num_fmt => 14
47
-
48
- # A style that a applies a font size and a custom formatting code
49
- custom_format = wb.styles.add_style :sz => 20, :format_code => 'yyyy-mm-dd'
50
-
51
- # A style that overrides top and left border style
52
- override_border = wb.styles.add_style :border => { :style => :thin, :color =>"FAAC58", :edges => [:right, :top, :left] }, :border_top => { :style => :thick, :color => "01DF74" }, :border_left => { :color => "0101DF" }
53
-
54
-
55
- wb.add_worksheet do |sheet|
56
-
57
- # We then apply those styles positionally
58
- sheet.add_row [123, "123", Time.now], style: [nil, large_font, predefined_format]
59
- sheet.add_row [123, "123", Date.new(2012, 9, 14)], style: [large_font, nil, custom_format]
60
- sheet.add_row [123, "123", Date.new(2000, 9, 12)] # This uses the axlsx default format_code (14)
61
- sheet.add_row [123, "123", Time.now], style: [large_font, override_border, predefined_format]
62
- end
63
-
64
- end
65
- p.serialize 'styles.xlsx'
66
-
@@ -1,13 +0,0 @@
1
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
- require 'axlsx'
3
- p = Axlsx::Package.new
4
- p.workbook do |wb|
5
- wb.styles do |s|
6
- no_underline = s.add_style :sz => 10, :b => true, :u => false, :alignment => { :horizontal=> :right }
7
- wb.add_worksheet(:name => 'wunderlinen') do |sheet|
8
- sheet.add_row %w{a b c really?}, :style => no_underline
9
- end
10
- end
11
- end
12
- p.serialize 'no_underline.xlsx'
13
-
@@ -1,21 +0,0 @@
1
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
- require 'axlsx'
3
- p = Axlsx::Package.new
4
- p.workbook do |wb|
5
- wb.styles do |s|
6
- wrap_text = s.add_style :fg_color=> "FFFFFF",
7
- :b => true,
8
- :bg_color => "004586",
9
- :sz => 12,
10
- :border => { :style => :thin, :color => "00" },
11
- :alignment => { :horizontal => :center,
12
- :vertical => :center ,
13
- :wrap_text => true}
14
- wb.add_worksheet(:name => 'wrap text') do |sheet|
15
- sheet.add_row ['Torp, White and Cronin'], :style => wrap_text
16
- # Forcing the column to be a bit narrow so we can see if the text wrap.
17
- sheet.column_info.first.width = 5
18
- end
19
- end
20
- end
21
- p.serialize 'wrap_text.xlsx'