File tree 1 file changed +60
-0
lines changed
1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -11,3 +11,63 @@ If [available in Hex](https://hex.pm/docs/publish), the package can be installed
11
11
def deps do
12
12
[{:excelerator, "~> 0.0.1"}]
13
13
end
14
+
15
+ ## Usage
16
+
17
+ 1 . Import ` Excelerator.Workbook ` into your module, then generate the XML content:
18
+
19
+ workbook do
20
+ worksheet "My Sheet" do
21
+ row do
22
+ cell "Name"
23
+ cell "Status"
24
+ end
25
+
26
+ row do
27
+ cell "Elixir"
28
+ cell 1
29
+ end
30
+ end
31
+ end
32
+
33
+ # => <? xml version="1.0" encoding="UTF-8" ?> <Workbook ...
34
+
35
+ ## Usage with Phoenix
36
+
37
+ 1 . Use ` Excelerator.Phoenix ` in your controller:
38
+
39
+ defmodule MyApp.MyController do
40
+ use MyApp.Web, : controller
41
+ use Excelerator.Phoenix
42
+
43
+ 1 . Import ` Excelerator.Workbook ` into your view module:
44
+
45
+ defmodule MyApp.MyView do
46
+ use MyApp.Web, : view
47
+ import Excelerator.Workbook
48
+
49
+ 1 . Alternatively, add the use / import statements to the appropriate sections
50
+ of ` web/web.ex ` , which will make excelerator available in all controllers/
51
+ views.
52
+
53
+ 1 . Call ` xls ` in your controller action to send content as a file download:
54
+
55
+ def show(conn, %{"format" => "xls"} = params) do
56
+ xls conn, "show.xls", favorite: "Elixir"
57
+ end
58
+
59
+ 1 . Create ` web/templates/RESOURCE/NAME.xls.exs `
60
+
61
+ workbook do
62
+ worksheet "My Sheet" do
63
+ row do
64
+ cell "Name"
65
+ cell "Status"
66
+ end
67
+
68
+ row do
69
+ cell assigns.favorite
70
+ cell 1
71
+ end
72
+ end
73
+ end
You can’t perform that action at this time.
0 commit comments