Skip to content

Commit

Permalink
Fixed broken Xlsxir functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonkenl committed May 16, 2016
1 parent 3ed29e0 commit e9bb298
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 74 deletions.
34 changes: 25 additions & 9 deletions OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,34 @@ Argument descriptions:
- `index` is the position of the worksheet you wish to parse (zero-based index)
- `timer` is a boolean flag that controls an extraction timer that returns time elapsed when set to `true`. Defalut value is `false`.

Upon successful completion, the extraction process returns `:ok` with `timer` set to `false`, or `{:ok, time_elapsed}` with `timer` set to `true`.
Upon successful completion, the extraction process returns:
- `:ok` with `timer` set to `false`
- `{:ok, time_elapsed}` with `timer` set to `true`

<br/>
The extracted worksheet data can be accessed using any of the following functions:
- `Xlsxir.get_list/0` - Returns entire worksheet data in the form of a list of row lists (i.e. `[[row 1 values], [row 2 values], ...]`)
- `Xlsxir.get_map/0` - Returns entire worksheet data in the form of a map of cell names and values (i.e. `%{"A1" => value, "A2" => value, ...}`)
- `Xlsxir.get_cell/1` - Returns value of specified cell (i.e. `"A1"` returns value contained in cell A1)
- `Xlsxir.get_row/1` - Returns values of specified row (i.e. `1` returns the first row of data)
- `Xlsxir.get_col/1` - Returns values of specified column (i.e `"A"` returns the first column of data)

Once the table data is no longer needed, run `Xlsxir.close` to delete the ETS process and free memory. Be sure to close an open ETS process before trying to parse another worksheet in the same session or process. If you try to open a new `:worksheet` ETS process when one already exists, you will get an error.
```elixir
Xlsxir.get_list
Xlsxir.get_map
Xlsxir.get_cell(cell_ref)
Xlsxir.get_row(row_num)
Xlsxir.get_col(col_ltr)
Xlsxir.get_info(num_type)
```
`Xlsxir.get_list/0` returns entire worksheet in a list of row lists (i.e. `[[row 1 values], ...]`)<br/>
`Xlsxir.get_map/0` returns entire worksheet in a map of cell names and values (i.e. `%{"A1" => value, ...}`)<br/>
`Xlsxir.get_cell/1` returns value of specified cell (i.e. `"A1"` returns value contained in cell A1)<br/>
`Xlsxir.get_row/1` returns values of specified row (i.e. `1` returns the first row of data)<br/>
`Xlsxir.get_col/1` returns values of specified column (i.e. `"A"` returns the first column of data)<br/>
`Xlsxir.get_info/1` returns count data for `num_type` specified (i.e. `:rows`, `:cols`, `:cells`, `:all`)<br/>

Once the table data is no longer needed, run the following function to delete the ETS process and free memory:
```elixir
Xlsxir.close
```
Be sure to close an open ETS process before trying to parse another worksheet in the same session or process. If you try to open a new `:worksheet` ETS process when one already exists, you will get an error.

Refer to [Xlsxir documentation](https://hexdocs.pm/xlsxir/index.html) for more detailed examples.
Refer to [API Reference](https://hexdocs.pm/xlsxir/api-reference.html) for more detailed examples.

## Considerations

Expand Down
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,32 @@ Argument descriptions:
- `index` is the position of the worksheet you wish to parse (zero-based index)
- `timer` is a boolean flag that controls an extraction timer that returns time elapsed when set to `true`. Defalut value is `false`.

Upon successful completion, the extraction process returns `:ok` with `timer` set to `false`, or `{:ok, time_elapsed}` with `timer` set to `true`.
Upon successful completion, the extraction process returns:
- `:ok` with `timer` set to `false`
- `{:ok, time_elapsed}` with `timer` set to `true`

<br/>
The extracted worksheet data can be accessed using any of the following functions:
- `Xlsxir.get_list/0` - Returns entire worksheet data in the form of a list of row lists (i.e. `[[row 1 values], [row 2 values], ...]`)
- `Xlsxir.get_map/0` - Returns entire worksheet data in the form of a map of cell names and values (i.e. `%{"A1" => value, "A2" => value, ...}`)
- `Xlsxir.get_cell/1` - Returns value of specified cell (i.e. `"A1"` returns value contained in cell A1)
- `Xlsxir.get_row/1` - Returns values of specified row (i.e. `1` returns the first row of data)
- `Xlsxir.get_col/1` - Returns values of specified column (i.e `"A"` returns the first column of data)

Once the table data is no longer needed, run `Xlsxir.close` to delete the ETS process and free memory.
```elixir
Xlsxir.get_list
Xlsxir.get_map
Xlsxir.get_cell(cell_ref)
Xlsxir.get_row(row_num)
Xlsxir.get_col(col_ltr)
Xlsxir.get_info(num_type)
```
`Xlsxir.get_list/0` returns entire worksheet in a list of row lists (i.e. `[[row 1 values], ...]`)<br/>
`Xlsxir.get_map/0` returns entire worksheet in a map of cell names and values (i.e. `%{"A1" => value, ...}`)<br/>
`Xlsxir.get_cell/1` returns value of specified cell (i.e. `"A1"` returns value contained in cell A1)<br/>
`Xlsxir.get_row/1` returns values of specified row (i.e. `1` returns the first row of data)<br/>
`Xlsxir.get_col/1` returns values of specified column (i.e. `"A"` returns the first column of data)<br/>
`Xlsxir.get_info/1` returns count data for `num_type` specified (i.e. `:rows`, `:cols`, `:cells`, `:all`)<br/>

Once the table data is no longer needed, run the following function to delete the ETS process and free memory:
```elixir
Xlsxir.close
```
Be sure to close an open ETS process before trying to parse another worksheet in the same session or process. If you try to open a new `:worksheet` ETS process when one already exists, you will get an error.

Refer to [Xlsxir documentation](https://hexdocs.pm/xlsxir/index.html) for more detailed examples.

Expand Down
2 changes: 1 addition & 1 deletion doc/Xlsxir.SaxParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ <h2>Example</h2>
&quot;string one&quot;
iex&gt; Xlsxir.SaxParser.parse(&quot;./test/test_data/test/xl/worksheets/sheet1.xml&quot;, :worksheet)
:ok
iex&gt; Xlsxir.Worksheet.get_at(0)
iex&gt; Xlsxir.Worksheet.get_at(1)
[[&quot;A1&quot;, &quot;string one&quot;], [&quot;B1&quot;, &quot;string two&quot;], [&quot;C1&quot;, 10], [&quot;D1&quot;, 20], [&quot;E1&quot;, {2016, 1, 1}]]
iex&gt; Xlsxir.Worksheet.delete
true</code></pre>
Expand Down
4 changes: 2 additions & 2 deletions doc/Xlsxir.Worksheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h2>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_at/1">get_at(index)</a>
<a href="#get_at/1">get_at(row_num)</a>
</div>

<div class="summary-synopsis"><p>Returns a row at a given index of the ETS process</p>
Expand Down Expand Up @@ -217,7 +217,7 @@ <h1 class="section-heading">
<a href="#get_at/1" class="detail-link" title="Link to this function">
<i class="icon-link"></i>
</a>
<span class="signature">get_at(index)</span>
<span class="signature">get_at(row_num)</span>

<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir/state_manager.ex#L24" class="view-source" rel="help" title="View Source">
<i class="icon-code"></i>
Expand Down
67 changes: 56 additions & 11 deletions doc/Xlsxir.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ <h2>
<a href="#get_cell/1">get_cell(cell_ref)</a>
</div>

<div class="summary-synopsis"><p>Accesses <code class="inline">:worksheet</code> ETS process and returns value of specified cell. Note: entire worksheet is traversed each time this function is executed. Use with caution as
this would be an expensive task for a large worksheet</p>
<div class="summary-synopsis"><p>Accesses <code class="inline">:worksheet</code> ETS process and returns value of specified cell</p>
</div>

</div>
Expand All @@ -129,6 +128,25 @@ <h2>
<div class="summary-synopsis"><p>Accesses <code class="inline">:worksheet</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/1">get_info(num_type \\ :all)</a>
</div>

<div class="summary-synopsis"><p>Returns count data based on <code class="inline">num_type</code> specified, default is <code class="inline">:all</code>. </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">:all</code> - Returns a keyword list containing all of the above
</li>
</ul>
</div>

</div>
<div class="summary-row">
<div class="summary-signature">
Expand All @@ -153,7 +171,7 @@ <h2>
<a href="#get_row/1">get_row(row)</a>
</div>

<div class="summary-synopsis"><p>Accesses <code class="inline">:worksheet</code> ETS process and returns values of specified row in a <code class="inline">list</code>. Blank rows are not counted</p>
<div class="summary-synopsis"><p>Accesses <code class="inline">:worksheet</code> ETS process and returns values of specified row in a <code class="inline">list</code></p>
</div>

</div>
Expand Down Expand Up @@ -185,7 +203,7 @@ <h1 class="section-heading">
</a>
<span class="signature">close()</span>

<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L199" class="view-source" rel="help" title="View Source">
<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L244" class="view-source" rel="help" title="View Source">
<i class="icon-code"></i>
</a>

Expand Down Expand Up @@ -248,15 +266,14 @@ <h2>Example</h2>
</a>
<span class="signature">get_cell(cell_ref)</span>

<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L132" class="view-source" rel="help" title="View Source">
<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L127" class="view-source" rel="help" title="View Source">
<i class="icon-code"></i>
</a>

</div>

<section class="docstring">
<p>Accesses <code class="inline">:worksheet</code> ETS process and returns value of specified cell. Note: entire worksheet is traversed each time this function is executed. Use with caution as
this would be an expensive task for a large worksheet.</p>
<p>Accesses <code class="inline">:worksheet</code> ETS process and returns value of specified cell.</p>
<h2>Parameters</h2>
<ul>
<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">&quot;A1&quot;</code>)
Expand Down Expand Up @@ -292,7 +309,7 @@ <h2>Example</h2>
</a>
<span class="signature">get_col(col)</span>

<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L183" class="view-source" rel="help" title="View Source">
<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L186" class="view-source" rel="help" title="View Source">
<i class="icon-code"></i>
</a>

Expand Down Expand Up @@ -328,14 +345,42 @@ <h2>Example</h2>

</section>
</div>
<div class="detail" id="get_info/1">
<div class="detail-header">
<a href="#get_info/1" class="detail-link" title="Link to this function">
<i class="icon-link"></i>
</a>
<span class="signature">get_info(num_type \\ :all)</span>

<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L205" class="view-source" rel="help" title="View Source">
<i class="icon-code"></i>
</a>

</div>

<section class="docstring">
<p>Returns count data based on <code class="inline">num_type</code> specified, default is <code class="inline">:all</code>. </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">:all</code> - Returns a keyword list containing all of the above
</li>
</ul>

</section>
</div>
<div class="detail" id="get_list/0">
<div class="detail-header">
<a href="#get_list/0" class="detail-link" title="Link to this function">
<i class="icon-link"></i>
</a>
<span class="signature">get_list()</span>

<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L73" class="view-source" rel="help" title="View Source">
<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L70" class="view-source" rel="help" title="View Source">
<i class="icon-code"></i>
</a>

Expand Down Expand Up @@ -373,7 +418,7 @@ <h2>Example</h2>
</a>
<span class="signature">get_map()</span>

<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L100" class="view-source" rel="help" title="View Source">
<a href="https://github.com/kennellroxco/xlsxir/blob/master/lib/xlsxir.ex#L96" class="view-source" rel="help" title="View Source">
<i class="icon-code"></i>
</a>

Expand Down Expand Up @@ -418,7 +463,7 @@ <h2>Example</h2>
</div>

<section class="docstring">
<p>Accesses <code class="inline">:worksheet</code> ETS process and returns values of specified row in a <code class="inline">list</code>. Blank rows are not counted.</p>
<p>Accesses <code class="inline">:worksheet</code> ETS process and returns values of specified row in a <code class="inline">list</code>.</p>
<h2>Parameters</h2>
<ul>
<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>)
Expand Down
20 changes: 13 additions & 7 deletions doc/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<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.11.4">
<title>Change Log – Xlsxir v1.0.0</title>
<title>CHANGELOG – Xlsxir v1.0.0</title>
<link rel="stylesheet" href="dist/app-1e374caa3d.css" />
<script src="dist/sidebar_items.js"></script>
</head>
Expand Down Expand Up @@ -59,7 +59,8 @@ <h2 class="sidebar-projectVersion">


<h1>Change Log</h1>
<h2 id="1-0-0"> 1.0.0</h2><p>Major changes in version 1.0.0 (non-backwards compatible) to improve performance and incorporate new functionality, including: </p>
<h2>1.0.0</h2>
<p>Major changes in version 1.0.0 (non-backwards compatible) to improve performance and incorporate new functionality, including: </p>
<ul>
<li><p>Refactored the <a href="Xlsxir.Unzip.html"><code class="inline">Xlsxir.Unzip</code></a> module to extract <code class="inline">.xlsx</code> contents to file instead of memory to improve memory usage. The following functions were created to support this functionality:</p>
<ul>
Expand Down Expand Up @@ -98,11 +99,13 @@ <h2 id="1-0-0"> 1.0.0</h2><p>Major changes in version 1.0.0 (non-backwards compa
<li>Updated documentation and testing to incorporate changes.
</li>
</ul>
<h2 id="0-0-5"> 0.0.5</h2><ul>
<h2>0.0.5</h2>
<ul>
<li>Minor bug fixes and documentation updates.
</li>
</ul>
<h2 id="0-0-4"> 0.0.4</h2><ul>
<h2>0.0.4</h2>
<ul>
<li>Expanded coverage of Office Open XML standard <code class="inline">numFmt</code> (Standard Number Format). The <code class="inline">formatCode</code> for a standard <code class="inline">numFmt</code> is implied rather than explicitly identified in the XML file.
</li>
<li>Implemented support for Office Open XML custom <code class="inline">numFmt</code> (Custom Number Format) utilizing the <code class="inline">formatCode</code> explicitly identified in the XML file.
Expand All @@ -112,19 +115,22 @@ <h2 id="0-0-4"> 0.0.4</h2><ul>
<li>Fixed issue resulting when no strings exist in a worksheet and therefore there is no <code class="inline">sharedStrings.xml</code> file (<code class="inline">:file_not_found</code> error).
</li>
</ul>
<h2 id="0-0-3"> 0.0.3</h2><ul>
<h2>0.0.3</h2>
<ul>
<li>Fixed issue related to strings that contain special characters. Refactored <code class="inline">Xlsxir.Parse.shared_strings/1</code> to properly parse strings with special characters.
</li>
</ul>
<h2 id="0-0-2"> 0.0.2</h2><ul>
<h2>0.0.2</h2>
<ul>
<li>Refactored <code class="inline">Xlsxir.Parse</code> functions to improve <code class="inline">extract</code> performance on larger files.
</li>
<li>Expanded documentation and test coverage.
</li>
<li>Completed <a href="Xlsxir.ConvertDate.html"><code class="inline">Xlsxir.ConvertDate</code></a> module.
</li>
</ul>
<h2 id="0-0-1"> 0.0.1</h2><ul>
<h2>0.0.1</h2>
<ul>
<li>Initial draft. Functionality limited to very small Excel worksheets.
</li>
<li><a href="Xlsxir.ConvertDate.html"><code class="inline">Xlsxir.ConvertDate</code></a> functionality incomplete.
Expand Down
Loading

0 comments on commit e9bb298

Please sign in to comment.