Skip to content

Commit

Permalink
Bug fixes and doc updates to prepare for v1.5 Hex release
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonkenl committed Mar 8, 2017
1 parent 354f73d commit 3f905be
Show file tree
Hide file tree
Showing 32 changed files with 553 additions and 190 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 1.5.0
- ***Xlsxir requires Elixir v1.4+ with this update***
- Added ability to extract only a given number of rows from a worksheet via `Xlsxir.peek/3`. Thanks to Ali Tahbaz (@tahbaza) for contribution.
- `DateTime` type values are now converted to an Elixir `Naive DateTime` type upon extraction. Regular `Date` types are still converted to Erlang `:calendar.date()` type. Thanks to Ali Tahbaz (@tahbaza) for contribution.
- A bug in `convert_char_number/1` was fixed to allow support for floats with scientific notation in them. Thanks to Daniel Parnell (@dparnell) for contribution.
- Minor bug fixes and documentation updates.

## 1.4.1
- Added parsing support for time values. Thanks to Edgar Cabrera (@aleandros) for contribution.
- Fixed bug that prevented worksheet ETS tables from closing. Thanks to Alex Kovalevych (@AlexKovalevych) for contribution.
Expand Down
13 changes: 8 additions & 5 deletions OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can add Xlsxir as a dependancy to your Elixir project via the Hex package ma

```elixir
def deps do
[ {:xlsxir, "~> 1.4.1"} ]
[ {:xlsxir, "~> 1.5.0"} ]
end
```

Expand All @@ -24,20 +24,22 @@ end

## Basic Usage

Xlsxir parses a `.xlsx` file located at a given `path` and extracts the data to an ETS process via the `Xlsxir.extract/3` and `Xlsxir.multi_extract/3` functions:
Xlsxir parses a `.xlsx` file located at a given `path` and extracts the data to an ETS process via the `Xlsxir.extract/3`, `Xlsxir.multi_extract/3` and `Xlsxir.peek/3` functions:

```elixir
Xlsxir.extract(path, index, timer \\ false)
Xlsxir.multi_extract(path, index \\ nil, timer \\ false)
Xlsxir.peek(path, index, rows)
```

The `multi_extract/3` function allows multiple worksheets to be parsed by creating a separate ETS process for each worksheet and returning a unique table identifier for each. This option will parse all worksheets by default
The `peek/3` function returns only the given number of rows from the worksheet at a given index. The `multi_extract/3` function allows multiple worksheets to be parsed by creating a separate ETS process for each worksheet and returning a unique table identifier for each. This option will parse all worksheets by default
(when `index == nil`), returning a list of tuple results.

Argument descriptions:
- `path` the path of the file to be parsed in `string` format
- `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`.
- `rows` is an integer representing the number of rows to be extracted from the given worksheet.

Upon successful completion, the extraction process returns:
- for `extract/3`:
Expand All @@ -48,6 +50,7 @@ Upon successful completion, the extraction process returns:
* `{:ok, table_id}` when given a specific worksheet `index`
* `[{:ok, table_1_id, time_elapsed}, ...]` with `timer` set to `true`
* `{:ok, table_id, time_elapsed}` when given a specific worksheet `index`
- for `peek/3`: `:ok`

Unsucessful parsing of a specific worksheet returns `{:error, reason}`.

Expand All @@ -62,7 +65,7 @@ Xlsxir.get_row(table_id, row_num)
Xlsxir.get_col(table_id, col_ltr)
Xlsxir.get_info(table_id, num_type)
```
**Note:** `table_id` defaults to `:worksheet` and is therefore not required when using `Xlsxir.extract/3` to parse a given worksheet. The `table_id` parameter is only used with `Xlsxir.multi_extract/3`.
**Note:** `table_id` defaults to `:worksheet` and is therefore not required when using `Xlsxir.extract/3` and `Xlsxir.peek/3` to parse a given worksheet. The `table_id` parameter is only used with `Xlsxir.multi_extract/3`.

`Xlsxir.get_list/1` returns entire worksheet in a list of row lists (i.e. `[[row 1 values], ...]`)<br/>
`Xlsxir.get_map/1` returns entire worksheet in a map of cell names and values (i.e. `%{"A1" => value, ...}`)<br/>
Expand All @@ -83,7 +86,7 @@ Refer to [API Reference](https://hexdocs.pm/xlsxir/api-reference.html) for more

## Considerations

Cell references are formatted as a string (i.e. "A1"). Strings will be returned as type `string`, resulting values for functions from within the worksheet are returned as type `string`, `integer` or `float` depending on the type of the resulting value, data formatted as a number in the worksheet will be returned as type `integer` or `float`, and ISO 8601 date formatted values will be returned in Erlang `:calendar.date()` type format (i.e. `{year, month, day}`). Xlsxir does not currently support dates prior to 1/1/1900.
Cell references are formatted as a string (i.e. "A1"). Strings will be returned as type `string`, resulting values for functions from within the worksheet are returned as type `string`, `integer` or `float` depending on the type of the resulting value, data formatted as a number in the worksheet will be returned as type `integer` or `float`, date formatted values will be returned in Erlang `:calendar.date()` type format (i.e. `{year, month, day}`), and datetime values will be returned as an Elixir `naive datetime`. Xlsxir does not currently support dates prior to 1/1/1900.

## Contributing

Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can add Xlsxir as a dependancy to your Elixir project via the Hex package ma

```elixir
def deps do
[ {:xlsxir, "~> 1.4.1"} ]
[ {:xlsxir, "~> 1.5.0"} ]
end
```

Expand All @@ -29,20 +29,22 @@ end

## Basic Usage

Xlsxir parses a `.xlsx` file located at a given `path` and extracts the data to an ETS process via the `Xlsxir.extract/3` and `Xlsxir.multi_extract/3` functions:
Xlsxir parses a `.xlsx` file located at a given `path` and extracts the data to an ETS process via the `Xlsxir.extract/3`, `Xlsxir.multi_extract/3` and `Xlsxir.peek/3` functions:

```elixir
Xlsxir.extract(path, index, timer \\ false)
Xlsxir.multi_extract(path, index \\ nil, timer \\ false)
Xlsxir.peek(path, index, rows)
```

The `multi_extract/3` function allows multiple worksheets to be parsed by creating a separate ETS process for each worksheet and returning a unique table identifier for each. This option will parse all worksheets by default
The `peek/3` function returns only the given number of rows from the worksheet at a given index. The `multi_extract/3` function allows multiple worksheets to be parsed by creating a separate ETS process for each worksheet and returning a unique table identifier for each. This option will parse all worksheets by default
(when `index == nil`), returning a list of tuple results.

Argument descriptions:
- `path` the path of the file to be parsed in `string` format
- `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`.
- `rows` is an integer representing the number of rows to be extracted from the given worksheet.

Upon successful completion, the extraction process returns:
- for `extract/3`:
Expand All @@ -53,6 +55,7 @@ Upon successful completion, the extraction process returns:
* `{:ok, table_id}` when given a specific worksheet `index`
* `[{:ok, table_1_id, time_elapsed}, ...]` with `timer` set to `true`
* `{:ok, table_id, time_elapsed}` when given a specific worksheet `index`
- for `peek/3`: `:ok`

Unsucessful parsing of a specific worksheet returns `{:error, reason}`.

Expand Down Expand Up @@ -87,7 +90,7 @@ Refer to [Xlsxir documentation](https://hexdocs.pm/xlsxir/index.html) for more d

## Considerations

Cell references are formatted as a string (i.e. "A1"). Strings will be returned as type `string`, resulting values for functions from within the worksheet are returned as type `string`, `integer` or `float` depending on the type of the resulting value, data formatted as a number in the worksheet will be returned as type `integer` or `float`, and ISO 8601 date formatted values will be returned in Erlang `:calendar.date()` type format (i.e. `{year, month, day}`). Xlsxir does not currently support dates prior to 1/1/1900.
Cell references are formatted as a string (i.e. "A1"). Strings will be returned as type `string`, resulting values for functions from within the worksheet are returned as type `string`, `integer` or `float` depending on the type of the resulting value, data formatted as a number in the worksheet will be returned as type `integer` or `float`, date formatted values will be returned in Erlang `:calendar.date()` type format (i.e. `{year, month, day}`), and datetime values will be returned as an Elixir `naive datetime`. Xlsxir does not currently support dates prior to 1/1/1900.

## Planned Development

Expand Down
6 changes: 4 additions & 2 deletions doc/404.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.5">
<title>404 – Xlsxir v1.4.1</title>
<title>404 – Xlsxir v1.5.0</title>
<link rel="stylesheet" href="dist/app-f9b4ee049e.css" />

<script src="dist/sidebar_items.js"></script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
Xlsxir
</h1>
<h2 class="sidebar-projectVersion">
v1.4.1
v1.5.0
</h2>
</div>

Expand All @@ -47,6 +47,8 @@ <h2 class="sidebar-projectVersion">



<li><a id="exceptions-list" href="#full-list">Exceptions</a></li>



</ul>
Expand Down
8 changes: 5 additions & 3 deletions doc/Xlsxir.Codepoint.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.5">
<title>Xlsxir.Codepoint – Xlsxir v1.4.1</title>
<title>Xlsxir.Codepoint – Xlsxir v1.5.0</title>
<link rel="stylesheet" href="dist/app-f9b4ee049e.css" />

<script src="dist/sidebar_items.js"></script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
Xlsxir
</h1>
<h2 class="sidebar-projectVersion">
v1.4.1
v1.5.0
</h2>
</div>

Expand All @@ -47,6 +47,8 @@ <h2 class="sidebar-projectVersion">



<li><a id="exceptions-list" href="#full-list">Exceptions</a></li>



</ul>
Expand All @@ -60,7 +62,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">Xlsxir v1.4.1</small>
<small class="visible-xs">Xlsxir v1.5.0</small>
Xlsxir.Codepoint


Expand Down
10 changes: 6 additions & 4 deletions doc/Xlsxir.ConvertDate.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.5">
<title>Xlsxir.ConvertDate – Xlsxir v1.4.1</title>
<title>Xlsxir.ConvertDate – Xlsxir v1.5.0</title>
<link rel="stylesheet" href="dist/app-f9b4ee049e.css" />

<script src="dist/sidebar_items.js"></script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
Xlsxir
</h1>
<h2 class="sidebar-projectVersion">
v1.4.1
v1.5.0
</h2>
</div>

Expand All @@ -47,6 +47,8 @@ <h2 class="sidebar-projectVersion">



<li><a id="exceptions-list" href="#full-list">Exceptions</a></li>



</ul>
Expand All @@ -60,7 +62,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">Xlsxir v1.4.1</small>
<small class="visible-xs">Xlsxir v1.5.0</small>
Xlsxir.ConvertDate


Expand All @@ -72,7 +74,7 @@ <h1>


<section id="moduledoc" class="docstring">
<p>Converts an ISO 8601 date format serial number, in <code class="inline">char_list</code> format, to a date formatted in
<p>Converts an ISO 8601 date format serial number, in <code class="inline">char_list</code> format, to a date formatted in
Erlang <code class="inline">:calendar.date()</code> type format (i.e. <code class="inline">{year, month, day}</code>).</p>

</section>
Expand Down
58 changes: 40 additions & 18 deletions doc/Xlsxir.ConvertTime.html → doc/Xlsxir.ConvertDateTime.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.5">
<title>Xlsxir.ConvertTime – Xlsxir v1.4.1</title>
<title>Xlsxir.ConvertDateTime – Xlsxir v1.5.0</title>
<link rel="stylesheet" href="dist/app-f9b4ee049e.css" />

<script src="dist/sidebar_items.js"></script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
Xlsxir
</h1>
<h2 class="sidebar-projectVersion">
v1.4.1
v1.5.0
</h2>
</div>

Expand All @@ -47,6 +47,8 @@ <h2 class="sidebar-projectVersion">



<li><a id="exceptions-list" href="#full-list">Exceptions</a></li>



</ul>
Expand All @@ -60,21 +62,20 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">Xlsxir v1.4.1</small>
Xlsxir.ConvertTime
<small class="visible-xs">Xlsxir v1.5.0</small>
Xlsxir.ConvertDateTime


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

</h1>


<section id="moduledoc" class="docstring">
<p>Converts a time formatted as a decimal number that represents the fraction
of the day in <code class="inline">char_list</code> form, to a tiem formatted in Erlang <code class="inline">:erlang.time()</code>
format (i.e. <code class="inline">{hour, minute, second}</code>).</p>
<p>Converts a datetime formatted as a decimal number that represents the fraction
of the day in <code class="inline">char_list</code> form, to an elixir naive datetime</p>

</section>

Expand All @@ -99,9 +100,15 @@ <h2>
<a href="#from_charlist/1">from_charlist(charlist)</a>
</div>

<div class="summary-synopsis"><p>Given a charlist in the form of a fraction of the day, return the time
formatted as <code class="inline">:erlang.time()</code></p>
<div class="summary-synopsis"><p>Given a charlist in the form of a serial date float representing fraction of the day
return a naive datetime</p>
</div>

</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#from_float/1">from_float(n)</a>
</div>

</div>

Expand Down Expand Up @@ -132,26 +139,41 @@ <h1 class="section-heading">
</a>
<span class="signature">from_charlist(charlist)</span>

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

</div>

<section class="docstring">
<p>Given a charlist in the form of a fraction of the day, return the time
formatted as <code class="inline">:erlang.time()</code>.</p>
<p>Note that the <code class="inline">float</code> representation of the input must be a number between
<code class="inline">0</code> (inclusive) and <code class="inline">1</code> (exclusive).</p>
<p>Given a charlist in the form of a serial date float representing fraction of the day
return a naive datetime</p>
<h2>Parameters</h2>
<ul>
<li><code class="inline">charlist</code> - Character list in the form of a fractional number (i.e. <code class="inline">0.25</code>)
<li><code class="inline">charlist</code> - Character list in the form of a date serial with a fractional number (i.e. <code class="inline">41261.6013888889</code>)
</li>
</ul>
<h2>Example</h2>
<pre><code class="iex elixir">iex&gt; Xlsxir.ConvertTime.from_charlist(&#39;0.25&#39;)
{6, 0, 0}</code></pre>
<pre><code class="iex elixir">iex&gt; Xlsxir.ConvertDateTime.from_charlist(&#39;41261.6013888889&#39;)
~N[2012-12-18 14:26:00]</code></pre>

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

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

</div>

<section class="docstring">

</section>
</div>

Expand Down
8 changes: 5 additions & 3 deletions doc/Xlsxir.Index.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.5">
<title>Xlsxir.Index – Xlsxir v1.4.1</title>
<title>Xlsxir.Index – Xlsxir v1.5.0</title>
<link rel="stylesheet" href="dist/app-f9b4ee049e.css" />

<script src="dist/sidebar_items.js"></script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
Xlsxir
</h1>
<h2 class="sidebar-projectVersion">
v1.4.1
v1.5.0
</h2>
</div>

Expand All @@ -47,6 +47,8 @@ <h2 class="sidebar-projectVersion">



<li><a id="exceptions-list" href="#full-list">Exceptions</a></li>



</ul>
Expand All @@ -60,7 +62,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">Xlsxir v1.4.1</small>
<small class="visible-xs">Xlsxir v1.5.0</small>
Xlsxir.Index


Expand Down
Loading

0 comments on commit 3f905be

Please sign in to comment.