forked from dbernheisel/xlsxir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXlsxir.html
1030 lines (968 loc) · 72.1 KB
/
Xlsxir.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.19.3">
<title>Xlsxir — Xlsxir v1.6.3</title>
<link rel="stylesheet" href="dist/html-399e30b9b028e3059575.css" />
<link rel="canonical" href="https://hexdocs.pm/xlsxir/Xlsxir.html" />
<script src="dist/sidebar_items-ae9c76d27c.js"></script>
<script async src="dist/html-399e30b9b028e3059575.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="overview.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
Xlsxir </h1>
<h2 class="sidebar-projectVersion">
v1.6.3
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
<li><a id="exceptions-list" href="#full-list">Exceptions</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">Xlsxir v1.6.3</small>
Xlsxir
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L1" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="moduledoc">
<p>Extracts and parses data from a <code class="inline">.xlsx</code> file to an Erlang Term Storage (ETS) process and provides various functions for accessing the data.</p>
</section>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#close/1">close(tid)</a>
</div>
<div class="summary-synopsis"><p>Deletes ETS process <code class="inline">tid</code> and returns <code class="inline">:ok</code> if successful</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#extract/4">extract(path, index, timer \\ false, options \\ [])</a>
</div>
<div class="summary-synopsis"><p><strong>Deprecated</strong>
Extracts worksheet data contained in the specified <code class="inline">.xlsx</code> file to an ETS process. Successful extraction
returns <code class="inline">{:ok, tid}</code> with the timer argument set to false and returns a tuple of <code class="inline">{:ok, tid, time}</code> where time is a list containing time elapsed during the extraction process
(i.e. <code class="inline">[hour, minute, second, microsecond]</code>) when the timer argument is set to true and tid - is the ETS table id</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_cell/2">get_cell(table_id, cell_ref)</a>
</div>
<div class="summary-synopsis"><p>Accesses ETS process and returns value of specified cell</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_col/2">get_col(tid, col)</a>
</div>
<div class="summary-synopsis"><p>Accesses <code class="inline">tid</code> ETS process and returns values of specified column in a <code class="inline">list</code></p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_info/2">get_info(table_id, num_type \\ :all)</a>
</div>
<div class="summary-synopsis"><p>See <a href="#get_multi_info/2"><code class="inline">get_multi_info/2</code></a> documentation</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_list/1">get_list(tid)</a>
</div>
<div class="summary-synopsis"><p>Accesses ETS process and returns data formatted as a list of row value lists</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_map/1">get_map(tid)</a>
</div>
<div class="summary-synopsis"><p>Accesses ETS process and returns data formatted as a map of cell references and values</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_mda/1">get_mda(tid)</a>
</div>
<div class="summary-synopsis"><p>Accesses ETS process and returns an indexed map which functions like a multi-dimensional array in other languages</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_multi_info/2">get_multi_info(tid, num_type \\ :all)</a>
</div>
<div class="summary-synopsis"><p>Returns count data based on <code class="inline">num_type</code> specified:</p>
<ul>
<li><code class="inline">:rows</code> - Returns number of rows contained in worksheet
</li>
<li><code class="inline">:cols</code> - Returns number of columns contained in worksheet
</li>
<li><code class="inline">:cells</code> - Returns number of cells contained in worksheet
</li>
<li><code class="inline">:name</code> - Returns worksheet name
</li>
<li><code class="inline">:all</code> - Returns a keyword list containing all of the above
</li>
</ul>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_row/2">get_row(tid, row)</a>
</div>
<div class="summary-synopsis"><p>Accesses ETS process and returns values of specified row in a <code class="inline">list</code></p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#multi_extract/5">multi_extract(path, index \\ nil, timer \\ false, excel \\ nil, options \\ [])</a>
</div>
<div class="summary-synopsis"><p>Extracts worksheet data contained in the specified <code class="inline">.xlsx</code> file to an ETS process. Successful extraction
returns <code class="inline">{:ok, table_id}</code> with the timer argument set to false and returns a tuple of <code class="inline">{:ok, table_id, time}</code> where <code class="inline">time</code> is a list containing time elapsed during the extraction process
(i.e. <code class="inline">[hour, minute, second, microsecond]</code>) when the timer argument is set to true. The <code class="inline">table_id</code> is used to access data for that particular ETS process with the various access functions of the
<a href="#content"><code class="inline">Xlsxir</code></a> module</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#peek/4">peek(path, index, rows, options \\ [])</a>
</div>
<div class="summary-synopsis"><p>Extracts the first n number of rows from the specified worksheet contained in the specified <code class="inline">.xlsx</code> file to an ETS process.
Successful extraction returns <code class="inline">{:ok, tid}</code> where tid - is ETS table id</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#start/2">start(type, args)</a>
</div>
<div class="summary-synopsis"><p>Called when an application is started</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#stream_list/3">stream_list(path, index, options \\ [])</a>
</div>
<div class="summary-synopsis"><p>Stream worksheet rows contained in the specified <code class="inline">.xlsx</code> file</p>
</div>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Functions </h1>
<div class="functions-list">
<section class="detail" id="close/1">
<div class="detail-header">
<a href="#close/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">close(tid)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L641" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Deletes ETS process <code class="inline">tid</code> and returns <code class="inline">:ok</code> if successful.</p>
<h2 id="close/1-example" class="section-heading">
<a href="#close/1-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>Extract first worksheet in an example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code>:</p>
<pre><code class="nohighlight makeup elixir"><span class="gp unselectable">iex> </span><span class="p" data-group-id="8642203684-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8642203684-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="8642203684-2">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="8642203684-2">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="8642203684-3">(</span><span class="n">tid</span><span class="p" data-group-id="8642203684-3">)</span><span class="w">
</span><span class="ss">:ok</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="p" data-group-id="8642203684-4">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8642203684-4">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">multi_extract</span><span class="p" data-group-id="8642203684-5">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="8642203684-5">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="8642203684-6">(</span><span class="n">tid</span><span class="p" data-group-id="8642203684-6">)</span><span class="w">
</span><span class="ss">:ok</span></code></pre>
</section>
</section>
<section class="detail" id="extract/4">
<span id="extract/2"></span>
<span id="extract/3"></span>
<div class="detail-header">
<a href="#extract/4" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">extract(path, index, timer \\ false, options \\ [])</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L87" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p><strong>Deprecated</strong>
Extracts worksheet data contained in the specified <code class="inline">.xlsx</code> file to an ETS process. Successful extraction
returns <code class="inline">{:ok, tid}</code> with the timer argument set to false and returns a tuple of <code class="inline">{:ok, tid, time}</code> where time is a list containing time elapsed during the extraction process
(i.e. <code class="inline">[hour, minute, second, microsecond]</code>) when the timer argument is set to true and tid - is the ETS table id</p>
<p>Cells containing formulas in the worksheet are extracted as either a <code class="inline">string</code>, <code class="inline">integer</code> or <code class="inline">float</code> depending on the resulting value of the cell.
Cells containing an ISO 8601 date format are extracted and converted to Erlang <code class="inline">:calendar.date()</code> format (i.e. <code class="inline">{year, month, day}</code>).</p>
<h2 id="extract/4-parameters" class="section-heading">
<a href="#extract/4-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">path</code> - file path of a <code class="inline">.xlsx</code> file type in <code class="inline">string</code> format
</li>
<li><code class="inline">index</code> - index of worksheet from within the Excel workbook to be parsed (zero-based index)
</li>
<li><code class="inline">timer</code> - boolean flag that tracks extraction process time and returns it when set to <code class="inline">true</code>. Default value is <code class="inline">false</code>.
</li>
</ul>
<h2 id="extract/4-options" class="section-heading">
<a href="#extract/4-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Options
</h2>
<ul>
<li><code class="inline">:max_rows</code> - the number of rows to fetch from within the worksheet
</li>
<li><code class="inline">:extract_to</code> - Specify how the <code class="inline">.xlsx</code> content (i.e. sharedStrings.xml,
style.xml and worksheets xml files) will be be extracted before being parsed.
<code class="inline">:memory</code> will extract files to memory, and <code class="inline">:file</code> to files in the file system
</li>
<li><code class="inline">:extract_base_dir</code> - when extracting to file, files will be extracted
in a sub directory in the <code class="inline">:extract_base_dir</code> directory. Defaults to
<code class="inline">Application.get_env(:xlsxir, :extract_base_dir)</code> or "temp"
</li>
</ul>
<h2 id="extract/4-example" class="section-heading">
<a href="#extract/4-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>Extract first worksheet in an example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code>:</p>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="p" data-group-id="8760592151-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8760592151-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="8760592151-2">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="8760592151-2">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">member?</span><span class="p" data-group-id="8760592151-3">(</span><span class="ss">:ets</span><span class="o">.</span><span class="n">all</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8760592151-3">)</span><span class="w">
</span><span class="no">true</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="8760592151-4">(</span><span class="n">tid</span><span class="p" data-group-id="8760592151-4">)</span><span class="w">
</span><span class="ss">:ok</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="p" data-group-id="8760592151-5">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8760592151-5">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="8760592151-6">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="no">false</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="8760592151-7">[</span><span class="ss">extract_to</span><span class="p">:</span><span class="w"> </span><span class="ss">:file</span><span class="p" data-group-id="8760592151-7">]</span><span class="p" data-group-id="8760592151-6">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">member?</span><span class="p" data-group-id="8760592151-8">(</span><span class="ss">:ets</span><span class="o">.</span><span class="n">all</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8760592151-8">)</span><span class="w">
</span><span class="no">true</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="8760592151-9">(</span><span class="n">tid</span><span class="p" data-group-id="8760592151-9">)</span><span class="w">
</span><span class="ss">:ok</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="p" data-group-id="8760592151-10">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p">,</span><span class="w"> </span><span class="c">_timer</span><span class="p" data-group-id="8760592151-10">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="8760592151-11">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="no">true</span><span class="p" data-group-id="8760592151-11">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">member?</span><span class="p" data-group-id="8760592151-12">(</span><span class="ss">:ets</span><span class="o">.</span><span class="n">all</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8760592151-12">)</span><span class="w">
</span><span class="no">true</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="8760592151-13">(</span><span class="n">tid</span><span class="p" data-group-id="8760592151-13">)</span><span class="w">
</span><span class="ss">:ok</span></code></pre>
<h2 id="extract/4-test-parallel-parsing" class="section-heading">
<a href="#extract/4-test-parallel-parsing" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Test parallel parsing
</h2>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="n">task1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Task</span><span class="o">.</span><span class="n">async</span><span class="p" data-group-id="9569539283-1">(</span><span class="k" data-group-id="9569539283-2">fn</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="9569539283-3">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="9569539283-3">)</span><span class="w"> </span><span class="k" data-group-id="9569539283-2">end</span><span class="p" data-group-id="9569539283-1">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="n">task2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Task</span><span class="o">.</span><span class="n">async</span><span class="p" data-group-id="9569539283-4">(</span><span class="k" data-group-id="9569539283-5">fn</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="9569539283-6">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="9569539283-6">)</span><span class="w"> </span><span class="k" data-group-id="9569539283-5">end</span><span class="p" data-group-id="9569539283-4">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="p" data-group-id="9569539283-7">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid1</span><span class="p" data-group-id="9569539283-7">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Task</span><span class="o">.</span><span class="n">await</span><span class="p" data-group-id="9569539283-8">(</span><span class="n">task1</span><span class="p" data-group-id="9569539283-8">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="p" data-group-id="9569539283-9">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid2</span><span class="p" data-group-id="9569539283-9">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Task</span><span class="o">.</span><span class="n">await</span><span class="p" data-group-id="9569539283-10">(</span><span class="n">task2</span><span class="p" data-group-id="9569539283-10">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">get_list</span><span class="p" data-group-id="9569539283-11">(</span><span class="n">tid1</span><span class="p" data-group-id="9569539283-11">)</span><span class="w">
</span><span class="p" data-group-id="9569539283-12">[</span><span class="p" data-group-id="9569539283-13">[</span><span class="s">"string one"</span><span class="p">,</span><span class="w"> </span><span class="s">"string two"</span><span class="p">,</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w"> </span><span class="mi">20</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="9569539283-14">{</span><span class="mi">2016</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p" data-group-id="9569539283-14">}</span><span class="p" data-group-id="9569539283-13">]</span><span class="p" data-group-id="9569539283-12">]</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">get_list</span><span class="p" data-group-id="9569539283-15">(</span><span class="n">tid2</span><span class="p" data-group-id="9569539283-15">)</span><span class="w">
</span><span class="p" data-group-id="9569539283-16">[</span><span class="p" data-group-id="9569539283-17">[</span><span class="s">"string one"</span><span class="p">,</span><span class="w"> </span><span class="s">"string two"</span><span class="p">,</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w"> </span><span class="mi">20</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="9569539283-18">{</span><span class="mi">2016</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p" data-group-id="9569539283-18">}</span><span class="p" data-group-id="9569539283-17">]</span><span class="p" data-group-id="9569539283-16">]</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="9569539283-19">(</span><span class="n">tid1</span><span class="p" data-group-id="9569539283-19">)</span><span class="w">
</span><span class="ss">:ok</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="9569539283-20">(</span><span class="n">tid2</span><span class="p" data-group-id="9569539283-20">)</span><span class="w">
</span><span class="ss">:ok</span></code></pre>
<h2 id="extract/4-example-errors" class="section-heading">
<a href="#extract/4-example-errors" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example (errors)
</h2>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="3838578213-1">(</span><span class="s">"./test/test_data/test.invalidfile"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="3838578213-1">)</span><span class="w">
</span><span class="p" data-group-id="3838578213-2">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="s">"Invalid file type (expected xlsx)."</span><span class="p" data-group-id="3838578213-2">}</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">extract</span><span class="p" data-group-id="3838578213-3">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p" data-group-id="3838578213-3">)</span><span class="w">
</span><span class="p" data-group-id="3838578213-4">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="s">"Invalid worksheet index."</span><span class="p" data-group-id="3838578213-4">}</span></code></pre>
</section>
</section>
<section class="detail" id="get_cell/2">
<div class="detail-header">
<a href="#get_cell/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_cell(table_id, cell_ref)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L410" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Accesses ETS process and returns value of specified cell.</p>
<h2 id="get_cell/2-parameters" class="section-heading">
<a href="#get_cell/2-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">table_id</code> - table identifier of ETS process to be accessed
</li>
<li><code class="inline">cell_ref</code> - Reference name of cell to be returned in <code class="inline">string</code> format (i.e. <code class="inline">"A1"</code>)
</li>
</ul>
<h2 id="get_cell/2-example" class="section-heading">
<a href="#get_cell/2-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>An example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code> containing the following:</p>
<ul>
<li>cell 'A1' -> "string one"
</li>
<li>cell 'B1' -> "string two"
</li>
<li>cell 'C1' -> integer of 10
</li>
<li>cell 'D1' -> formula of "4 * 5"
</li>
<li><p>cell 'E1' -> date of 1/1/2016 or Excel date serial of 42370</p>
<p>iex> {:ok, tid} = Xlsxir.extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_cell(tid, "A1")
"string one"
iex> Xlsxir.close(tid)
:ok</p>
<p>iex> {:ok, tid} = Xlsxir.multi_extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_cell(tid, "A1")
"string one"
iex> Xlsxir.close(tid)
:ok</p>
</li>
</ul>
</section>
</section>
<section class="detail" id="get_col/2">
<div class="detail-header">
<a href="#get_col/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_col(tid, col)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L544" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Accesses <code class="inline">tid</code> ETS process and returns values of specified column in a <code class="inline">list</code>.</p>
<h2 id="get_col/2-parameters" class="section-heading">
<a href="#get_col/2-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">tid</code> - table identifier of ETS process to be accessed
</li>
<li><code class="inline">col</code> - Reference name of column to be returned in <code class="inline">string</code> format (i.e. <code class="inline">"A"</code>)
</li>
</ul>
<h2 id="get_col/2-example" class="section-heading">
<a href="#get_col/2-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>An example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code> containing the following:</p>
<ul>
<li>cell 'A1' -> "string one"
</li>
<li>cell 'B1' -> "string two"
</li>
<li>cell 'C1' -> integer of 10
</li>
<li>cell 'D1' -> formula of "4 * 5"
</li>
<li><p>cell 'E1' -> date of 1/1/2016 or Excel date serial of 42370</p>
<p>iex> {:ok, tid} = Xlsxir.extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_col(tid, "A")
["string one"]
iex> Xlsxir.close(tid)
:ok</p>
<p>iex> {:ok, tid} = Xlsxir.multi_extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_col(tid, "A")
["string one"]
iex> Xlsxir.close(tid)
:ok</p>
</li>
</ul>
</section>
</section>
<section class="detail" id="get_info/2">
<span id="get_info/1"></span>
<div class="detail-header">
<a href="#get_info/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_info(table_id, num_type \\ :all)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L562" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>See <a href="#get_multi_info/2"><code class="inline">get_multi_info/2</code></a> documentation.</p>
</section>
</section>
<section class="detail" id="get_list/1">
<div class="detail-header">
<a href="#get_list/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_list(tid)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L278" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Accesses ETS process and returns data formatted as a list of row value lists.</p>
<h2 id="get_list/1-parameters" class="section-heading">
<a href="#get_list/1-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">tid</code> - table identifier of ETS process to be accessed
</li>
</ul>
<h2 id="get_list/1-example" class="section-heading">
<a href="#get_list/1-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>An example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code> containing the following:</p>
<ul>
<li>cell 'A1' -> "string one"
</li>
<li>cell 'B1' -> "string two"
</li>
<li>cell 'C1' -> integer of 10
</li>
<li>cell 'D1' -> formula of "4 * 5"
</li>
<li><p>cell 'E1' -> date of 1/1/2016 or Excel date serial of 42370</p>
<p>iex> {:ok, tid} = Xlsxir.extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_list(tid)
[["string one", "string two", 10, 20, {2016, 1, 1}]]
iex> Xlsxir.close(tid)
:ok</p>
<p>iex> {:ok, tid} = Xlsxir.extract("./test/test_data/test.xlsx", 2)
iex> Xlsxir.get_list(tid) |> List.first |> Enum.count
16384</p>
<p>iex> {:ok, tid} = Xlsxir.multi_extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_list(tid)
[["string one", "string two", 10, 20, {2016, 1, 1}]]
iex> Xlsxir.close(tid)
:ok</p>
</li>
</ul>
</section>
</section>
<section class="detail" id="get_map/1">
<div class="detail-header">
<a href="#get_map/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_map(tid)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L314" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Accesses ETS process and returns data formatted as a map of cell references and values.</p>
<h2 id="get_map/1-parameters" class="section-heading">
<a href="#get_map/1-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">tid</code> - table identifier of ETS process to be accessed
</li>
</ul>
<h2 id="get_map/1-example" class="section-heading">
<a href="#get_map/1-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>An example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code> containing the following:</p>
<ul>
<li>cell 'A1' -> "string one"
</li>
<li>cell 'B1' -> "string two"
</li>
<li>cell 'C1' -> integer of 10
</li>
<li>cell 'D1' -> formula of "4 * 5"
</li>
<li><p>cell 'E1' -> date of 1/1/2016 or Excel date serial of 42370</p>
<p>iex> {:ok, tid} = Xlsxir.extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_map(tid)
%{ "A1" => "string one", "B1" => "string two", "C1" => 10, "D1" => 20, "E1" => {2016,1,1}}
iex> Xlsxir.close(tid)
:ok</p>
<p>iex> {:ok, tid} = Xlsxir.multi_extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_map(tid)
%{ "A1" => "string one", "B1" => "string two", "C1" => 10, "D1" => 20, "E1" => {2016,1,1}}
iex> Xlsxir.close(tid)
:ok</p>
</li>
</ul>
</section>
</section>
<section class="detail" id="get_mda/1">
<div class="detail-header">
<a href="#get_mda/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_mda(tid)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L358" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Accesses ETS process and returns an indexed map which functions like a multi-dimensional array in other languages.</p>
<h2 id="get_mda/1-parameters" class="section-heading">
<a href="#get_mda/1-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">tid</code> - table identifier of ETS process to be accessed
</li>
</ul>
<h2 id="get_mda/1-example" class="section-heading">
<a href="#get_mda/1-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>An example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code> containing the following:</p>
<ul>
<li>cell 'A1' -> "string one"
</li>
<li>cell 'B1' -> "string two"
</li>
<li>cell 'C1' -> integer of 10
</li>
<li>cell 'D1' -> formula of "4 * 5"
</li>
<li><p>cell 'E1' -> date of 1/1/2016 or Excel date serial of 42370</p>
<p>iex> {:ok, tid} = Xlsxir.extract("./test/test_data/test.xlsx", 0)
iex> mda = Xlsxir.get_mda(tid)
%{0 => %{0 => "string one", 1 => "string two", 2 => 10, 3 => 20, 4 => {2016,1,1}}}
iex> mda[0][0]
"string one"
iex> mda[0][2]
10
iex> Xlsxir.close(tid)
:ok</p>
<p>iex> {:ok, tid} = Xlsxir.multi_extract("./test/test_data/test.xlsx", 0)
iex> mda = Xlsxir.get_mda(tid)
%{0 => %{0 => "string one", 1 => "string two", 2 => 10, 3 => 20, 4 => {2016,1,1}}}
iex> mda[0][0]
"string one"
iex> mda[0][2]
10
iex> Xlsxir.close(tid)
:ok</p>
</li>
</ul>
</section>
</section>
<section class="detail" id="get_multi_info/2">
<span id="get_multi_info/1"></span>
<div class="detail-header">
<a href="#get_multi_info/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_multi_info(tid, num_type \\ :all)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L578" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Returns count data based on <code class="inline">num_type</code> specified:</p>
<ul>
<li><code class="inline">:rows</code> - Returns number of rows contained in worksheet
</li>
<li><code class="inline">:cols</code> - Returns number of columns contained in worksheet
</li>
<li><code class="inline">:cells</code> - Returns number of cells contained in worksheet
</li>
<li><code class="inline">:name</code> - Returns worksheet name
</li>
<li><code class="inline">:all</code> - Returns a keyword list containing all of the above
</li>
</ul>
<h2 id="get_multi_info/2-parameters" class="section-heading">
<a href="#get_multi_info/2-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">tid</code> - table identifier of ETS process to be accessed
</li>
<li><code class="inline">num_type</code> - type of count data to be returned (see above), defaults to <code class="inline">:all</code>
</li>
</ul>
</section>
</section>
<section class="detail" id="get_row/2">
<div class="detail-header">
<a href="#get_row/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">get_row(tid, row)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L451" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Accesses ETS process and returns values of specified row in a <code class="inline">list</code>.</p>
<h2 id="get_row/2-parameters" class="section-heading">
<a href="#get_row/2-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">tid</code> - table identifier of ETS process to be accessed
</li>
<li><code class="inline">row</code> - Reference name of row to be returned in <code class="inline">integer</code> format (i.e. <code class="inline">1</code>)
</li>
</ul>
<h2 id="get_row/2-example" class="section-heading">
<a href="#get_row/2-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>An example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code> containing the following:</p>
<ul>
<li>cell 'A1' -> "string one"
</li>
<li>cell 'B1' -> "string two"
</li>
<li>cell 'C1' -> integer of 10
</li>
<li>cell 'D1' -> formula of "4 * 5"
</li>
<li><p>cell 'E1' -> date of 1/1/2016 or Excel date serial of 42370</p>
<p>iex> {:ok, tid} = Xlsxir.extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_row(tid, 1)
["string one", "string two", 10, 20, {2016, 1, 1}]
iex> Xlsxir.close(tid)
:ok</p>
<p>iex> {:ok, tid} = Xlsxir.multi_extract("./test/test_data/test.xlsx", 0)
iex> Xlsxir.get_row(tid, 1)
["string one", "string two", 10, 20, {2016, 1, 1}]
iex> Xlsxir.close(tid)
:ok</p>
</li>
</ul>
</section>
</section>
<section class="detail" id="multi_extract/5">
<span id="multi_extract/1"></span>
<span id="multi_extract/2"></span>
<span id="multi_extract/3"></span>
<span id="multi_extract/4"></span>
<div class="detail-header">
<a href="#multi_extract/5" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">multi_extract(path, index \\ nil, timer \\ false, excel \\ nil, options \\ [])</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L244" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Extracts worksheet data contained in the specified <code class="inline">.xlsx</code> file to an ETS process. Successful extraction
returns <code class="inline">{:ok, table_id}</code> with the timer argument set to false and returns a tuple of <code class="inline">{:ok, table_id, time}</code> where <code class="inline">time</code> is a list containing time elapsed during the extraction process
(i.e. <code class="inline">[hour, minute, second, microsecond]</code>) when the timer argument is set to true. The <code class="inline">table_id</code> is used to access data for that particular ETS process with the various access functions of the
<a href="#content"><code class="inline">Xlsxir</code></a> module.</p>
<p>Cells containing formulas in the worksheet are extracted as either a <code class="inline">string</code>, <code class="inline">integer</code> or <code class="inline">float</code> depending on the resulting value of the cell.
Cells containing an ISO 8601 date format are extracted and converted to Erlang <code class="inline">:calendar.date()</code> format (i.e. <code class="inline">{year, month, day}</code>).</p>
<h2 id="multi_extract/5-parameters" class="section-heading">
<a href="#multi_extract/5-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">path</code> - file path of a <code class="inline">.xlsx</code> file type in <code class="inline">string</code> format
</li>
<li><code class="inline">index</code> - index of worksheet from within the Excel workbook to be parsed (zero-based index)
</li>
<li><code class="inline">timer</code> - boolean flag that tracts extraction process time and returns it when set to <code class="inline">true</code>. Defalut value is <code class="inline">false</code>.
</li>
</ul>
<h2 id="multi_extract/5-options" class="section-heading">
<a href="#multi_extract/5-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Options
</h2>
<ul>
<li><code class="inline">:max_rows</code> - the number of rows to fetch from within the worksheets
</li>
<li><code class="inline">:extract_to</code> - Specify how the <code class="inline">.xlsx</code> content (i.e. sharedStrings.xml,
style.xml and worksheets xml files) will be be extracted before being parsed.
<code class="inline">:memory</code> will extract files to memory, and <code class="inline">:file</code> to files in the file system
</li>
<li><code class="inline">:extract_base_dir</code> - when extracting to file, files will be extracted
in a sub directory in the <code class="inline">:extract_base_dir</code> directory. Defaults to
<code class="inline">Application.get_env(:xlsxir, :extract_base_dir)</code> or "temp"
</li>
</ul>
<h2 id="multi_extract/5-example" class="section-heading">
<a href="#multi_extract/5-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>Extract first worksheet in an example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code>:</p>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="p" data-group-id="7006701147-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="7006701147-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">multi_extract</span><span class="p" data-group-id="7006701147-2">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="7006701147-2">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">member?</span><span class="p" data-group-id="7006701147-3">(</span><span class="ss">:ets</span><span class="o">.</span><span class="n">all</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="7006701147-3">)</span><span class="w">
</span><span class="no">true</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="7006701147-4">(</span><span class="n">tid</span><span class="p" data-group-id="7006701147-4">)</span><span class="w">
</span><span class="ss">:ok</span></code></pre>
<h2 id="multi_extract/5-example" class="section-heading">
<a href="#multi_extract/5-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>Extract all worksheets in an example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code>:</p>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="n">results</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">multi_extract</span><span class="p" data-group-id="6926520087-1">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p" data-group-id="6926520087-1">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="n">alive_ids</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">map</span><span class="p" data-group-id="6926520087-2">(</span><span class="n">results</span><span class="p">,</span><span class="w"> </span><span class="k" data-group-id="6926520087-3">fn</span><span class="w"> </span><span class="p" data-group-id="6926520087-4">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="6926520087-4">}</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">member?</span><span class="p" data-group-id="6926520087-5">(</span><span class="ss">:ets</span><span class="o">.</span><span class="n">all</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="6926520087-5">)</span><span class="w"> </span><span class="k" data-group-id="6926520087-3">end</span><span class="p" data-group-id="6926520087-2">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">all?</span><span class="p" data-group-id="6926520087-6">(</span><span class="n">alive_ids</span><span class="p" data-group-id="6926520087-6">)</span><span class="w">
</span><span class="no">true</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">map</span><span class="p" data-group-id="6926520087-7">(</span><span class="n">results</span><span class="p">,</span><span class="w"> </span><span class="k" data-group-id="6926520087-8">fn</span><span class="w"> </span><span class="p" data-group-id="6926520087-9">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="6926520087-9">}</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="6926520087-10">(</span><span class="n">tid</span><span class="p" data-group-id="6926520087-10">)</span><span class="w"> </span><span class="k" data-group-id="6926520087-8">end</span><span class="p" data-group-id="6926520087-7">)</span><span class="w"> </span><span class="o">|></span><span class="w"> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">all?</span><span class="p" data-group-id="6926520087-11">(</span><span class="k" data-group-id="6926520087-12">fn</span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="ss">:ok</span><span class="w"> </span><span class="k" data-group-id="6926520087-12">end</span><span class="p" data-group-id="6926520087-11">)</span><span class="w">
</span><span class="no">true</span></code></pre>
<h2 id="multi_extract/5-example" class="section-heading">
<a href="#multi_extract/5-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>Extract all worksheets in an example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code> with timer:</p>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="n">results</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">multi_extract</span><span class="p" data-group-id="8995670594-1">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w"> </span><span class="no">true</span><span class="p" data-group-id="8995670594-1">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="n">alive_ids</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">map</span><span class="p" data-group-id="8995670594-2">(</span><span class="n">results</span><span class="p">,</span><span class="w"> </span><span class="k" data-group-id="8995670594-3">fn</span><span class="w"> </span><span class="p" data-group-id="8995670594-4">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p">,</span><span class="w"> </span><span class="c">_timer</span><span class="p" data-group-id="8995670594-4">}</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">member?</span><span class="p" data-group-id="8995670594-5">(</span><span class="ss">:ets</span><span class="o">.</span><span class="n">all</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="8995670594-5">)</span><span class="w"> </span><span class="k" data-group-id="8995670594-3">end</span><span class="p" data-group-id="8995670594-2">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">all?</span><span class="p" data-group-id="8995670594-6">(</span><span class="n">alive_ids</span><span class="p" data-group-id="8995670594-6">)</span><span class="w">
</span><span class="no">true</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">map</span><span class="p" data-group-id="8995670594-7">(</span><span class="n">results</span><span class="p">,</span><span class="w"> </span><span class="k" data-group-id="8995670594-8">fn</span><span class="w"> </span><span class="p" data-group-id="8995670594-9">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p">,</span><span class="w"> </span><span class="c">_timer</span><span class="p" data-group-id="8995670594-9">}</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="8995670594-10">(</span><span class="n">tid</span><span class="p" data-group-id="8995670594-10">)</span><span class="w"> </span><span class="k" data-group-id="8995670594-8">end</span><span class="p" data-group-id="8995670594-7">)</span><span class="w"> </span><span class="o">|></span><span class="w"> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">all?</span><span class="p" data-group-id="8995670594-11">(</span><span class="k" data-group-id="8995670594-12">fn</span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">-></span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="ss">:ok</span><span class="w"> </span><span class="k" data-group-id="8995670594-12">end</span><span class="p" data-group-id="8995670594-11">)</span><span class="w">
</span><span class="no">true</span></code></pre>
<h2 id="multi_extract/5-example-errors" class="section-heading">
<a href="#multi_extract/5-example-errors" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example (errors)
</h2>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">multi_extract</span><span class="p" data-group-id="8498853876-1">(</span><span class="s">"./test/test_data/test.invalidfile"</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="8498853876-1">)</span><span class="w">
</span><span class="p" data-group-id="8498853876-2">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="s">"Invalid file type (expected xlsx)."</span><span class="p" data-group-id="8498853876-2">}</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">multi_extract</span><span class="p" data-group-id="8498853876-3">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p" data-group-id="8498853876-3">)</span><span class="w">
</span><span class="p" data-group-id="8498853876-4">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="s">"Invalid worksheet index."</span><span class="p" data-group-id="8498853876-4">}</span></code></pre>
</section>
</section>
<section class="detail" id="peek/4">
<span id="peek/3"></span>
<div class="detail-header">
<a href="#peek/4" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">peek(path, index, rows, options \\ [])</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L166" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Extracts the first n number of rows from the specified worksheet contained in the specified <code class="inline">.xlsx</code> file to an ETS process.
Successful extraction returns <code class="inline">{:ok, tid}</code> where tid - is ETS table id.</p>
<h2 id="peek/4-parameters" class="section-heading">
<a href="#peek/4-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">path</code> - file path of a <code class="inline">.xlsx</code> file type in <code class="inline">string</code> format
</li>
<li><code class="inline">index</code> - index of worksheet from within the Excel workbook to be parsed (zero-based index)
</li>
<li><code class="inline">rows</code> - the number of rows to fetch from within the specified worksheet
</li>
</ul>
<h2 id="peek/4-options" class="section-heading">
<a href="#peek/4-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Options
</h2>
<ul>
<li><code class="inline">:extract_to</code> - Specify how the <code class="inline">.xlsx</code> content (i.e. sharedStrings.xml,
style.xml and worksheets xml files) will be be extracted before being parsed.
<code class="inline">:memory</code> will extract files to memory, and <code class="inline">:file</code> to files in the file system
</li>
<li><code class="inline">:extract_base_dir</code> - when extracting to file, files will be extracted
in a sub directory in the <code class="inline">:extract_base_dir</code> directory. Defaults to
<code class="inline">Application.get_env(:xlsxir, :extract_base_dir)</code> or "temp"
</li>
</ul>
<h2 id="peek/4-example" class="section-heading">
<a href="#peek/4-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>
<p>Peek at the first 10 rows of the 9th worksheet in an example file named <code class="inline">test.xlsx</code> located in <code class="inline">./test/test_data</code>:</p>
<pre><code class="nohighlight makeup elixir"><span class="w"> </span><span class="gp unselectable">iex> </span><span class="p" data-group-id="6467586247-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="6467586247-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">peek</span><span class="p" data-group-id="6467586247-2">(</span><span class="s">"./test/test_data/test.xlsx"</span><span class="p">,</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="mi">10</span><span class="p" data-group-id="6467586247-2">)</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Enum</span><span class="o">.</span><span class="n">member?</span><span class="p" data-group-id="6467586247-3">(</span><span class="ss">:ets</span><span class="o">.</span><span class="n">all</span><span class="p">,</span><span class="w"> </span><span class="n">tid</span><span class="p" data-group-id="6467586247-3">)</span><span class="w">
</span><span class="no">true</span><span class="w">
</span><span class="gp unselectable">iex> </span><span class="nc">Xlsxir</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="6467586247-4">(</span><span class="n">tid</span><span class="p" data-group-id="6467586247-4">)</span><span class="w">
</span><span class="ss">:ok</span></code></pre>
</section>
</section>
<section class="detail" id="start/2">
<div class="detail-header">
<a href="#start/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">start(type, args)</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L6" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Called when an application is started.</p>
<p>This function is called when an application is started using
<a href="https://hexdocs.pm/elixir/Application.html#start/2"><code class="inline">Application.start/2</code></a> (and functions on top of that, such as
<a href="https://hexdocs.pm/elixir/Application.html#ensure_started/2"><code class="inline">Application.ensure_started/2</code></a>). This function should start the top-level
process of the application (which should be the top supervisor of the
application's supervision tree if the application follows the OTP design
principles around supervision).</p>
<p><code class="inline">start_type</code> defines how the application is started:</p>
<ul>
<li><code class="inline">:normal</code> - used if the startup is a normal startup or if the application
is distributed and is started on the current node because of a failover
from another node and the application specification key <code class="inline">:start_phases</code>
is <code class="inline">:undefined</code>.
</li>
<li><code class="inline">{:takeover, node}</code> - used if the application is distributed and is
started on the current node because of a failover on the node <code class="inline">node</code>.
</li>
<li><code class="inline">{:failover, node}</code> - used if the application is distributed and is
started on the current node because of a failover on node <code class="inline">node</code>, and the
application specification key <code class="inline">:start_phases</code> is not <code class="inline">:undefined</code>.
</li>
</ul>
<p><code class="inline">start_args</code> are the arguments passed to the application in the <code class="inline">:mod</code>
specification key (e.g., <code class="inline">mod: {MyApp, [:my_args]}</code>).</p>
<p>This function should either return <code class="inline">{:ok, pid}</code> or <code class="inline">{:ok, pid, state}</code> if
startup is successful. <code class="inline">pid</code> should be the PID of the top supervisor. <code class="inline">state</code>
can be an arbitrary term, and if omitted will default to <code class="inline">[]</code>; if the
application is later stopped, <code class="inline">state</code> is passed to the <code class="inline">stop/1</code> callback (see
the documentation for the <code class="inline">c:stop/1</code> callback for more information).</p>
<p><code class="inline">use Application</code> provides no default implementation for the <a href="#start/2"><code class="inline">start/2</code></a>
callback.</p>
<p>Callback implementation for <a href="https://hexdocs.pm/elixir/Application.html#c:start/2"><code class="inline">Application.start/2</code></a>.</p>
</section>
</section>
<section class="detail" id="stream_list/3">
<span id="stream_list/2"></span>
<div class="detail-header">
<a href="#stream_list/3" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature">stream_list(path, index, options \\ [])</span>
<a href="https://github.com/jsonkenl/xlsxir/blob/master/lib/xlsxir.ex#L120" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Stream worksheet rows contained in the specified <code class="inline">.xlsx</code> file.</p>
<p>Cells containing formulas in the worksheet are extracted as either a <code class="inline">string</code>, <code class="inline">integer</code> or <code class="inline">float</code> depending on the resulting value of the cell.
Cells containing an ISO 8601 date format are extracted and converted to Erlang <code class="inline">:calendar.date()</code> format (i.e. <code class="inline">{year, month, day}</code>).</p>
<h2 id="stream_list/3-parameters" class="section-heading">
<a href="#stream_list/3-parameters" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Parameters
</h2>
<ul>
<li><code class="inline">path</code> - file path of a <code class="inline">.xlsx</code> file type in <code class="inline">string</code> format
</li>
<li><code class="inline">index</code> - index of worksheet from within the Excel workbook to be parsed (zero-based index)
</li>
</ul>
<h2 id="stream_list/3-options" class="section-heading">
<a href="#stream_list/3-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Options
</h2>
<ul>
<li><code class="inline">:extract_to</code> - Specify how the <code class="inline">.xlsx</code> content (i.e. sharedStrings.xml,
style.xml and worksheets xml files) will be be extracted before being parsed.
<code class="inline">:memory</code> will extract files to memory, and <code class="inline">:file</code> to files in the file system
</li>
<li><code class="inline">:extract_base_dir</code> - when extracting to file, files will be extracted
in a sub directory in the <code class="inline">:extract_base_dir</code> directory. Defaults to
<code class="inline">Application.get_env(:xlsxir, :extract_base_dir)</code> or "temp"
</li>
</ul>
<h2 id="stream_list/3-example" class="section-heading">
<a href="#stream_list/3-example" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Example
</h2>