diff --git a/docs/404.html b/docs/404.html index dce0188..4a664c3 100644 --- a/docs/404.html +++ b/docs/404.html @@ -3,8 +3,8 @@ - - + + @@ -13,7 +13,7 @@ - xlsx-parser 0.8.2 + xlsx-parser 1.0.0 @@ -39,7 +39,7 @@

- 0.8.2 + 1.0.0 @@ -61,9 +61,39 @@

-
  • +
  • Sheet + + + +
  • + +
  • + Styles + + + +
  • diff --git a/docs/XlsxParser.html b/docs/XlsxParser.html index 51097c9..f3c4b26 100644 --- a/docs/XlsxParser.html +++ b/docs/XlsxParser.html @@ -3,8 +3,8 @@ - - + + @@ -13,7 +13,7 @@ - XlsxParser - xlsx-parser 0.8.2 + XlsxParser - xlsx-parser 1.0.0 @@ -39,7 +39,7 @@

    - 0.8.2 + 1.0.0 @@ -61,9 +61,39 @@

    -
  • +
  • Sheet + + + +
  • + +
  • + Styles + + + +
  • @@ -111,17 +141,23 @@

    - xlsx-parser.cr + + xlsx-parser.cr +
    - xlsx-parser/book.cr + + xlsx-parser/book.cr +
    - xlsx-parser/sheet.cr + + xlsx-parser/sheet.cr +
    @@ -141,7 +177,7 @@

    - VERSION = "0.8.2" + VERSION = "1.0.0"
    diff --git a/docs/XlsxParser/Book.html b/docs/XlsxParser/Book.html index 91da5a2..5589af3 100644 --- a/docs/XlsxParser/Book.html +++ b/docs/XlsxParser/Book.html @@ -3,8 +3,8 @@ - - + + @@ -13,7 +13,7 @@ - XlsxParser::Book - xlsx-parser 0.8.2 + XlsxParser::Book - xlsx-parser 1.0.0 @@ -39,7 +39,7 @@

    - 0.8.2 + 1.0.0 @@ -61,9 +61,39 @@

    -
  • +
  • Sheet + + + +
  • + +
  • + Styles + + + +
  • @@ -113,13 +143,39 @@

    - xlsx-parser/book.cr + + xlsx-parser/book.cr +
    + +

    + + + + Constant Summary +

    + +
    + +
    + TIME_1900 = Time.utc(1899, 12, 30) +
    + + +
    + TIME_1904 = Time.utc(1904, 1, 1) +
    + + +
    +

    @@ -153,6 +209,11 @@

    @@ -113,7 +143,9 @@

    - xlsx-parser/sheet.cr + + xlsx-parser/sheet.cr +
    @@ -214,6 +246,8 @@


    + [View source] +
    @@ -242,6 +276,8 @@


    + [View source] +
    @@ -256,6 +292,8 @@


    + [View source] +
    diff --git a/docs/XlsxParser/Sheet/Type.html b/docs/XlsxParser/Sheet/Type.html new file mode 100644 index 0000000..43b279a --- /dev/null +++ b/docs/XlsxParser/Sheet/Type.html @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + XlsxParser::Sheet::Type - xlsx-parser 1.0.0 + + + + + + + + +
    +

    + + alias XlsxParser::Sheet::Type + +

    + + + + + +

    + + + + Overview +

    + +

    All possible output types

    + + + +

    + + + + Alias Definition +

    + Bool | Float64 | Int32 | String | Time + + + + + + + + + + + + +

    + + + + Defined in: +

    + + + + xlsx-parser/sheet.cr + + +
    + + + + + + + + + + + + + + +
    + +
    + + + + + + + + + +
    + + + diff --git a/docs/XlsxParser/Styles.html b/docs/XlsxParser/Styles.html new file mode 100644 index 0000000..60561aa --- /dev/null +++ b/docs/XlsxParser/Styles.html @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + XlsxParser::Styles - xlsx-parser 1.0.0 + + + + + + + + +
    +

    + + module XlsxParser::Styles + +

    + + + + + + + + + + + + + + + + + + +

    + + + + Defined in: +

    + + + + xlsx-parser/styles.cr + + +
    + + + + xlsx-parser/styles/converter.cr + + +
    + + + + xlsx-parser/styles/parser.cr + + +
    + + + + + +

    + + + + Constant Summary +

    + +
    + +
    + NumFmtMap = {0 => :string, 1 => :fixnum, 2 => :float, 3 => :fixnum, 4 => :float, 5 => :unsupported, 6 => :unsupported, 7 => :unsupported, 8 => :unsupported, 9 => :percentage, 10 => :percentage, 11 => :bignum, 12 => :unsupported, 13 => :unsupported, 14 => :date, 15 => :date, 16 => :date, 17 => :date, 18 => :time, 19 => :time, 20 => :time, 21 => :time, 22 => :date_time, 37 => :unsupported, 38 => :unsupported, 39 => :unsupported, 40 => :unsupported, 45 => :time, 46 => :time, 47 => :time, 48 => :bignum, 49 => :unsupported} +
    + +
    +

    Map of non-custom numFmtId to casting symbol

    +
    + + +
    + + + + + + + + + + + +
    + +
    + + + + + + + + + +
    + + + diff --git a/docs/XlsxParser/Styles/Converter.html b/docs/XlsxParser/Styles/Converter.html new file mode 100644 index 0000000..81cd4be --- /dev/null +++ b/docs/XlsxParser/Styles/Converter.html @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + XlsxParser::Styles::Converter - xlsx-parser 1.0.0 + + + + + + + + +
    +

    + + class XlsxParser::Styles::Converter + +

    + + + + + + + + + + + + + + + + + + + + +

    + + + + Defined in: +

    + + + + xlsx-parser/styles/converter.cr + + +
    + + + + + +

    + + + + Constant Summary +

    + +
    + +
    + DATE_TYPES = [:date, :time, :date_time] of ::Symbol +
    + + +
    + + + + + +

    + + + + Class Method Summary +

    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + +

    + + + + Class Method Detail +

    + +
    +
    + + def self.call(value : String, type : String?, style : Symbol?, book : Book) + + # +
    + +
    + +

    ameba:disable Metrics/CyclomaticComplexity

    +
    + +
    +
    + + [View source] + +
    +
    + + + + + + + +
    + + + diff --git a/docs/XlsxParser/Styles/Parser.html b/docs/XlsxParser/Styles/Parser.html new file mode 100644 index 0000000..1d5b950 --- /dev/null +++ b/docs/XlsxParser/Styles/Parser.html @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + XlsxParser::Styles::Parser - xlsx-parser 1.0.0 + + + + + + + + +
    +

    + + class XlsxParser::Styles::Parser + +

    + + + + + + + + + + + + + + + + + + + + +

    + + + + Defined in: +

    + + + + xlsx-parser/styles/parser.cr + + +
    + + + + + + + + +

    + + + + Class Method Summary +

    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + +

    + + + + Class Method Detail +

    + +
    +
    + + def self.call(book : Book) : Array(Symbol?) + + # +
    + +
    +
    + + [View source] + +
    +
    + + + + + + + +
    + + + diff --git a/docs/index.html b/docs/index.html index 840da35..57d0b32 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3,8 +3,8 @@ - - + + @@ -13,7 +13,7 @@ - xlsx-parser 0.8.2 + xlsx-parser 1.0.0 @@ -39,7 +39,7 @@

    - 0.8.2 + 1.0.0 @@ -61,9 +61,39 @@

    -
  • +
  • Sheet + + + +
  • + +
  • + Styles + + + +
  • @@ -78,16 +108,16 @@

    -

    -xlsx-parser (v0.8.2)

    +xlsx-parser (v1.0.0)

    GitHub Workflow Status (event) GitHub issues GitHub license

    Crystal wrapper for parsing .xlsx spreadsheets

    :rocket: Suggestions for new improvements are welcome in the issue tracker.

    -

    Note: Work with Cystal versions >= 0.36.1, < 2.0.0

    +

    Note: Work with Cystal versions >= 1.4.0, < 2.0.0

    dependencies:
       xlsx-parser:
         github: D1ceWard/xlsx-parser
    -    version: 0.8.2
    + version: 1.0.0
  • Run shards install

    diff --git a/docs/index.json b/docs/index.json index 651b9c8..a34aafa 100644 --- a/docs/index.json +++ b/docs/index.json @@ -1 +1 @@ -{"repository_name":"xlsx-parser","body":"# xlsx-parser (v0.8.2)\n![GitHub Workflow Status (event)](https://github.com/D1ceWard/xlsx-parser/actions/workflows/main.yml/badge.svg?branch=master)\n[![GitHub issues](https://img.shields.io/github/issues/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/issues)\n[![GitHub license](https://img.shields.io/github/license/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/blob/master/LICENSE)\n\nCrystal wrapper for parsing .xlsx spreadsheets\n\n:rocket: Suggestions for new improvements are welcome in the issue tracker.\n\nNote: Work with Cystal versions `>= 0.36.1, < 2.0.0`\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n xlsx-parser:\n github: D1ceWard/xlsx-parser\n version: 0.8.2\n ```\n\n2. Run `shards install`\n\n## Usage\n\n### With IO\n```crystal\nrequire \"xlsx-parser\"\n\nfile_io = File.new(\"./my_super_spreadsheet.xlsx\")\nbook = XlsxParser::Book.new(file_io)\n```\n\n### With file path\n```crystal\nrequire \"xlsx-parser\"\n\nbook = XlsxParser::Book.new(\"./my_super_spreadsheet.xlsx\")\n```\n\n### Print rows content\n```crystal\n# Iterate on each row of the first sheet\nbook.sheets[0].rows.each do |row|\n puts row #=> { \"A1\" => \"Col A Row 1\", \"B1\" => \"Col B Row 1\" }\nend\n\n# Second sheet\nbook.sheets[1]\n\nbook.close\n```\n\nDocumentation available here : https://d1ceward.github.io/xlsx-parser/\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/D1ceWard/xlsx-parser. By contributing you agree to abide by the Code of Merit.\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [D1ceWard](https://github.com/D1ceWard) - creator and maintainer\n","program":{"html_id":"xlsx-parser/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"xlsx-parser","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"xlsx-parser/XlsxParser","path":"XlsxParser.html","kind":"module","full_name":"XlsxParser","name":"XlsxParser","abstract":false,"locations":[{"filename":"src/xlsx-parser.cr","line_number":4,"url":null},{"filename":"src/xlsx-parser/book.cr","line_number":4,"url":null},{"filename":"src/xlsx-parser/sheet.cr","line_number":1,"url":null}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.8.2\""}],"types":[{"html_id":"xlsx-parser/XlsxParser/Book","path":"XlsxParser/Book.html","kind":"class","full_name":"XlsxParser::Book","name":"Book","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/book.cr","line_number":5,"url":null}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(file:IO|String,check_file_extension=true)-class-method","name":"new","abstract":false,"args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"args_string":"(file : IO | String, check_file_extension = true)","args_html":"(file : IO | String, check_file_extension = true)","location":{"filename":"src/xlsx-parser/book.cr","line_number":10,"url":null},"def":{"name":"new","args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(file, check_file_extension)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"close-instance-method","name":"close","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":45,"url":null},"def":{"name":"close","visibility":"Public","body":"@zip.close"}},{"html_id":"shared_strings:Array(String)-instance-method","name":"shared_strings","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":8,"url":null},"def":{"name":"shared_strings","return_type":"Array(String)","visibility":"Public","body":"@shared_strings"}},{"html_id":"sheets-instance-method","name":"sheets","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":31,"url":null},"def":{"name":"sheets","visibility":"Public","body":"workbook = XML.parse(@zip[\"xl/workbook.xml\"].open(&.gets_to_end))\nsheets_nodes = workbook.xpath_nodes(\"//*[name()='sheet']\")\nrels = XML.parse(@zip[\"xl/_rels/workbook.xml.rels\"].open(&.gets_to_end))\n@sheets = sheets_nodes.map do |sheet|\n sheetfile = rels.xpath_string(\"string(//*[name()='Relationship' and contains(@Id,'#{sheet[\"id\"]}')]/@Target)\")\n Sheet.new(self, sheetfile)\nend\n"}},{"html_id":"zip:Compress::Zip::File-instance-method","name":"zip","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":6,"url":null},"def":{"name":"zip","return_type":"Compress::Zip::File","visibility":"Public","body":"@zip"}}]},{"html_id":"xlsx-parser/XlsxParser/Sheet","path":"XlsxParser/Sheet.html","kind":"class","full_name":"XlsxParser::Sheet","name":"Sheet","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/sheet.cr","line_number":2,"url":null}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(book:Book,file:String)-class-method","name":"new","abstract":false,"args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"args_string":"(book : Book, file : String)","args_html":"(book :
    Book, file : String)","location":{"filename":"src/xlsx-parser/sheet.cr","line_number":5,"url":null},"def":{"name":"new","args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(book, file)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"node:XML::Reader-instance-method","name":"node","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":3,"url":null},"def":{"name":"node","return_type":"XML::Reader","visibility":"Public","body":"@node"}},{"html_id":"rows-instance-method","name":"rows","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":9,"url":null},"def":{"name":"rows","visibility":"Public","body":"Iterator.of do\n row = nil\n row_index = nil\n cell = nil\n cell_type = nil\n loop do\n if @node.read\n else\n break\n end\n if @node.name == \"row\"\n if @node.node_type == XML::Reader::Type::ELEMENT\n row = {} of String => String | Int32\n row_index = node[\"r\"]?\n else\n row = inner_padding(row, row_index, cell)\n break\n end\n else\n if (@node.name == \"c\") && (@node.node_type == XML::Reader::Type::ELEMENT)\n cell_type = node[\"t\"]?\n cell = node[\"r\"]?\n else\n if (((@node.name == \"v\") && (@node.node_type == XML::Reader::Type::ELEMENT)) && row) && cell\n row[cell] = convert(cell_type)\n end\n end\n end\n end\n row || Iterator.stop\nend"}}]}]}]}} \ No newline at end of file +{"repository_name":"xlsx-parser","body":"# xlsx-parser (v1.0.0)\n![GitHub Workflow Status (event)](https://github.com/D1ceWard/xlsx-parser/actions/workflows/main.yml/badge.svg?branch=master)\n[![GitHub issues](https://img.shields.io/github/issues/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/issues)\n[![GitHub license](https://img.shields.io/github/license/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/blob/master/LICENSE)\n\nCrystal wrapper for parsing .xlsx spreadsheets\n\n:rocket: Suggestions for new improvements are welcome in the issue tracker.\n\nNote: Work with Cystal versions `>= 1.4.0, < 2.0.0`\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n xlsx-parser:\n github: D1ceWard/xlsx-parser\n version: 1.0.0\n ```\n\n2. Run `shards install`\n\n## Usage\n\n### With IO\n```crystal\nrequire \"xlsx-parser\"\n\nfile_io = File.new(\"./my_super_spreadsheet.xlsx\")\nbook = XlsxParser::Book.new(file_io)\n```\n\n### With file path\n```crystal\nrequire \"xlsx-parser\"\n\nbook = XlsxParser::Book.new(\"./my_super_spreadsheet.xlsx\")\n```\n\n### Print rows content\n```crystal\n# Iterate on each row of the first sheet\nbook.sheets[0].rows.each do |row|\n puts row #=> { \"A1\" => \"Col A Row 1\", \"B1\" => \"Col B Row 1\" }\nend\n\n# Second sheet\nbook.sheets[1]\n\nbook.close\n```\n\nDocumentation available here : https://d1ceward.github.io/xlsx-parser/\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/D1ceWard/xlsx-parser. By contributing you agree to abide by the Code of Merit.\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [D1ceWard](https://github.com/D1ceWard) - creator and maintainer\n","program":{"html_id":"xlsx-parser/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"xlsx-parser","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"xlsx-parser/XlsxParser","path":"XlsxParser.html","kind":"module","full_name":"XlsxParser","name":"XlsxParser","abstract":false,"locations":[{"filename":"src/xlsx-parser.cr","line_number":5,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser.cr#L5"},{"filename":"src/xlsx-parser/book.cr","line_number":4,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L4"},{"filename":"src/xlsx-parser/sheet.cr","line_number":1,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L1"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"1.0.0\""}],"types":[{"html_id":"xlsx-parser/XlsxParser/Book","path":"XlsxParser/Book.html","kind":"class","full_name":"XlsxParser::Book","name":"Book","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/book.cr","line_number":5,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L5"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"TIME_1900","name":"TIME_1900","value":"Time.utc(1899, 12, 30)"},{"id":"TIME_1904","name":"TIME_1904","value":"Time.utc(1904, 1, 1)"}],"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(file:IO|String,check_file_extension=true)-class-method","name":"new","abstract":false,"args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"args_string":"(file : IO | String, check_file_extension = true)","args_html":"(file : IO | String, check_file_extension = true)","location":{"filename":"src/xlsx-parser/book.cr","line_number":15,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L15"},"def":{"name":"new","args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(file, check_file_extension)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"base_time-instance-method","name":"base_time","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":58,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L58"},"def":{"name":"base_time","visibility":"Public","body":"@base_time || (@base_time = (begin\n result = TIME_1900\n workbook = XML.parse(@zip[\"xl/workbook.xml\"].open(&.gets_to_end))\n (workbook.xpath_nodes(\"//*[name()='workbookPr']\")).each do |workbook_pr|\n if workbook_pr.try do |__arg4|\n __arg4.attributes[\"date1904\"]\n end.try(&.content) =~ (/true|1/i)\n else\n next\n end\n result = TIME_1904\n break\n end\n result\nend))"}},{"html_id":"close-instance-method","name":"close","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":54,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L54"},"def":{"name":"close","visibility":"Public","body":"@zip.close"}},{"html_id":"shared_strings:Array(String)-instance-method","name":"shared_strings","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":8,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L8"},"def":{"name":"shared_strings","return_type":"Array(String)","visibility":"Public","body":"@shared_strings"}},{"html_id":"sheets-instance-method","name":"sheets","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":36,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L36"},"def":{"name":"sheets","visibility":"Public","body":"workbook = XML.parse(@zip[\"xl/workbook.xml\"].open(&.gets_to_end))\nsheets_nodes = workbook.xpath_nodes(\"//*[name()='sheet']\")\nrels = XML.parse(@zip[\"xl/_rels/workbook.xml.rels\"].open(&.gets_to_end))\n@sheets = sheets_nodes.map do |sheet|\n sheetfile = rels.xpath_string(\"string(//*[name()='Relationship' and contains(@Id,'#{sheet[\"id\"]}')]/@Target)\")\n Sheet.new(self, sheetfile)\nend\n"}},{"html_id":"style_types-instance-method","name":"style_types","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":50,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L50"},"def":{"name":"style_types","visibility":"Public","body":"@style_types || (@style_types = Styles::Parser.call(self))"}},{"html_id":"zip:Compress::Zip::File-instance-method","name":"zip","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":6,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L6"},"def":{"name":"zip","return_type":"Compress::Zip::File","visibility":"Public","body":"@zip"}}]},{"html_id":"xlsx-parser/XlsxParser/Sheet","path":"XlsxParser/Sheet.html","kind":"class","full_name":"XlsxParser::Sheet","name":"Sheet","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/sheet.cr","line_number":2,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L2"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(book:Book,file:String)-class-method","name":"new","abstract":false,"args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"args_string":"(book : Book, file : String)","args_html":"(book : Book, file : String)","location":{"filename":"src/xlsx-parser/sheet.cr","line_number":8,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L8"},"def":{"name":"new","args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(book, file)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"node:XML::Reader-instance-method","name":"node","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":3,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L3"},"def":{"name":"node","return_type":"XML::Reader","visibility":"Public","body":"@node"}},{"html_id":"rows-instance-method","name":"rows","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":12,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L12"},"def":{"name":"rows","visibility":"Public","body":"Iterator.of do\n row = nil\n row_index = nil\n cell = nil\n cell_type = nil\n cell_style_idx = nil\n loop do\n if @node.read\n else\n break\n end\n if @node.name == \"row\"\n if @node.node_type == XML::Reader::Type::ELEMENT\n row = {} of String => Type\n row_index = node[\"r\"]?\n else\n row = inner_padding(row, row_index, cell)\n break\n end\n else\n if (@node.name == \"c\") && (@node.node_type == XML::Reader::Type::ELEMENT)\n cell_type = node[\"t\"]?\n cell_style_idx = node[\"s\"]?\n cell = node[\"r\"]?\n else\n if (((@node.name == \"v\") && (@node.node_type == XML::Reader::Type::ELEMENT)) && row) && cell\n row[cell] = convert(@node.read_inner_xml, cell_type, cell_style_idx)\n end\n end\n end\n end\n row || Iterator.stop\nend"}}],"types":[{"html_id":"xlsx-parser/XlsxParser/Sheet/Type","path":"XlsxParser/Sheet/Type.html","kind":"alias","full_name":"XlsxParser::Sheet::Type","name":"Type","abstract":false,"locations":[{"filename":"src/xlsx-parser/sheet.cr","line_number":6,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L6"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":true,"aliased":"(Bool | Float64 | Int32 | String | Time)","aliased_html":"Bool | Float64 | Int32 | String | Time","const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser/Sheet","kind":"class","full_name":"XlsxParser::Sheet","name":"Sheet"},"doc":"All possible output types","summary":"

    All possible output types

    "}]},{"html_id":"xlsx-parser/XlsxParser/Styles","path":"XlsxParser/Styles.html","kind":"module","full_name":"XlsxParser::Styles","name":"Styles","abstract":false,"locations":[{"filename":"src/xlsx-parser/styles.cr","line_number":4,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles.cr#L4"},{"filename":"src/xlsx-parser/styles/converter.cr","line_number":1,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/converter.cr#L1"},{"filename":"src/xlsx-parser/styles/parser.cr","line_number":1,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/parser.cr#L1"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"NumFmtMap","name":"NumFmtMap","value":"{0 => :string, 1 => :fixnum, 2 => :float, 3 => :fixnum, 4 => :float, 5 => :unsupported, 6 => :unsupported, 7 => :unsupported, 8 => :unsupported, 9 => :percentage, 10 => :percentage, 11 => :bignum, 12 => :unsupported, 13 => :unsupported, 14 => :date, 15 => :date, 16 => :date, 17 => :date, 18 => :time, 19 => :time, 20 => :time, 21 => :time, 22 => :date_time, 37 => :unsupported, 38 => :unsupported, 39 => :unsupported, 40 => :unsupported, 45 => :time, 46 => :time, 47 => :time, 48 => :bignum, 49 => :unsupported}","doc":"Map of non-custom numFmtId to casting symbol","summary":"

    Map of non-custom numFmtId to casting symbol

    "}],"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"types":[{"html_id":"xlsx-parser/XlsxParser/Styles/Converter","path":"XlsxParser/Styles/Converter.html","kind":"class","full_name":"XlsxParser::Styles::Converter","name":"Converter","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/styles/converter.cr","line_number":2,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/converter.cr#L2"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DATE_TYPES","name":"DATE_TYPES","value":"[:date, :time, :date_time] of ::Symbol"}],"namespace":{"html_id":"xlsx-parser/XlsxParser/Styles","kind":"module","full_name":"XlsxParser::Styles","name":"Styles"},"class_methods":[{"html_id":"call(value:String,type:String?,style:Symbol?,book:Book)-class-method","name":"call","doc":"ameba:disable Metrics/CyclomaticComplexity","summary":"

    ameba:disable Metrics/CyclomaticComplexity

    ","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"String"},{"name":"type","external_name":"type","restriction":"String | ::Nil"},{"name":"style","external_name":"style","restriction":"Symbol | ::Nil"},{"name":"book","external_name":"book","restriction":"Book"}],"args_string":"(value : String, type : String?, style : Symbol?, book : Book)","args_html":"(value : String, type : String?, style : Symbol?, book : Book)","location":{"filename":"src/xlsx-parser/styles/converter.cr","line_number":6,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/converter.cr#L6"},"def":{"name":"call","args":[{"name":"value","external_name":"value","restriction":"String"},{"name":"type","external_name":"type","restriction":"String | ::Nil"},{"name":"style","external_name":"style","restriction":"Symbol | ::Nil"},{"name":"book","external_name":"book","restriction":"Book"}],"visibility":"Public","body":"if type.nil? || ((type == \"n\") && (DATE_TYPES.includes?(style)))\n type = style\nend\ncase type\nwhen \"s\"\n book.shared_strings[value.to_i]\nwhen \"n\"\n value.to_f\nwhen 'b'\n value.to_i == 1\nwhen :string\n value\nwhen :unsupported\n convert_unknown(value)\nwhen :fixnum\n value.to_i\nwhen :float, :percentage\n value.to_f\nwhen :time, :date, :date_time\n convert_time(value, book)\nelse\n convert_unknown(value)\nend\n"}}]},{"html_id":"xlsx-parser/XlsxParser/Styles/Parser","path":"XlsxParser/Styles/Parser.html","kind":"class","full_name":"XlsxParser::Styles::Parser","name":"Parser","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/styles/parser.cr","line_number":2,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/parser.cr#L2"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser/Styles","kind":"module","full_name":"XlsxParser::Styles","name":"Styles"},"class_methods":[{"html_id":"call(book:Book):Array(Symbol?)-class-method","name":"call","abstract":false,"args":[{"name":"book","external_name":"book","restriction":"Book"}],"args_string":"(book : Book) : Array(Symbol?)","args_html":"(book : Book) : Array(Symbol?)","location":{"filename":"src/xlsx-parser/styles/parser.cr","line_number":3,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/parser.cr#L3"},"def":{"name":"call","args":[{"name":"book","external_name":"book","restriction":"Book"}],"return_type":"Array(Symbol | Nil)","visibility":"Public","body":"if (styles_file = book.zip[\"xl/styles.xml\"]?)\nelse\n return [] of Symbol | ::Nil\nend\nstyles = XML.parse(styles_file.open(&.gets_to_end))\ncustom_style_types = parse_custom_style_types(styles)\nstyles_nodes = styles.xpath_nodes(\"//*[name()='styleSheet']//*[name()='cellXfs']//*[name()='xf']\")\nstyles_nodes.map do |xstyle|\n if ( num_fmt_id = xstyle.attributes[\"numFmtId\"]?.try(&.content).try(&.to_i))\n else\n next\n end\n NumFmtMap[num_fmt_id]? || custom_style_types[num_fmt_id]\nend\n"}}]}]}]}]}} \ No newline at end of file diff --git a/docs/search-index.js b/docs/search-index.js index 8dac8c2..5d1db3b 100644 --- a/docs/search-index.js +++ b/docs/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"xlsx-parser","body":"# xlsx-parser (v0.8.2)\n![GitHub Workflow Status (event)](https://github.com/D1ceWard/xlsx-parser/actions/workflows/main.yml/badge.svg?branch=master)\n[![GitHub issues](https://img.shields.io/github/issues/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/issues)\n[![GitHub license](https://img.shields.io/github/license/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/blob/master/LICENSE)\n\nCrystal wrapper for parsing .xlsx spreadsheets\n\n:rocket: Suggestions for new improvements are welcome in the issue tracker.\n\nNote: Work with Cystal versions `>= 0.36.1, < 2.0.0`\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n xlsx-parser:\n github: D1ceWard/xlsx-parser\n version: 0.8.2\n ```\n\n2. Run `shards install`\n\n## Usage\n\n### With IO\n```crystal\nrequire \"xlsx-parser\"\n\nfile_io = File.new(\"./my_super_spreadsheet.xlsx\")\nbook = XlsxParser::Book.new(file_io)\n```\n\n### With file path\n```crystal\nrequire \"xlsx-parser\"\n\nbook = XlsxParser::Book.new(\"./my_super_spreadsheet.xlsx\")\n```\n\n### Print rows content\n```crystal\n# Iterate on each row of the first sheet\nbook.sheets[0].rows.each do |row|\n puts row #=> { \"A1\" => \"Col A Row 1\", \"B1\" => \"Col B Row 1\" }\nend\n\n# Second sheet\nbook.sheets[1]\n\nbook.close\n```\n\nDocumentation available here : https://d1ceward.github.io/xlsx-parser/\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/D1ceWard/xlsx-parser. By contributing you agree to abide by the Code of Merit.\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [D1ceWard](https://github.com/D1ceWard) - creator and maintainer\n","program":{"html_id":"xlsx-parser/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"xlsx-parser","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"xlsx-parser/XlsxParser","path":"XlsxParser.html","kind":"module","full_name":"XlsxParser","name":"XlsxParser","abstract":false,"locations":[{"filename":"src/xlsx-parser.cr","line_number":4,"url":null},{"filename":"src/xlsx-parser/book.cr","line_number":4,"url":null},{"filename":"src/xlsx-parser/sheet.cr","line_number":1,"url":null}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.8.2\""}],"types":[{"html_id":"xlsx-parser/XlsxParser/Book","path":"XlsxParser/Book.html","kind":"class","full_name":"XlsxParser::Book","name":"Book","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/book.cr","line_number":5,"url":null}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(file:IO|String,check_file_extension=true)-class-method","name":"new","abstract":false,"args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"args_string":"(file : IO | String, check_file_extension = true)","args_html":"(file : IO | String, check_file_extension = true)","location":{"filename":"src/xlsx-parser/book.cr","line_number":10,"url":null},"def":{"name":"new","args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(file, check_file_extension)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"close-instance-method","name":"close","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":45,"url":null},"def":{"name":"close","visibility":"Public","body":"@zip.close"}},{"html_id":"shared_strings:Array(String)-instance-method","name":"shared_strings","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":8,"url":null},"def":{"name":"shared_strings","return_type":"Array(String)","visibility":"Public","body":"@shared_strings"}},{"html_id":"sheets-instance-method","name":"sheets","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":31,"url":null},"def":{"name":"sheets","visibility":"Public","body":"workbook = XML.parse(@zip[\"xl/workbook.xml\"].open(&.gets_to_end))\nsheets_nodes = workbook.xpath_nodes(\"//*[name()='sheet']\")\nrels = XML.parse(@zip[\"xl/_rels/workbook.xml.rels\"].open(&.gets_to_end))\n@sheets = sheets_nodes.map do |sheet|\n sheetfile = rels.xpath_string(\"string(//*[name()='Relationship' and contains(@Id,'#{sheet[\"id\"]}')]/@Target)\")\n Sheet.new(self, sheetfile)\nend\n"}},{"html_id":"zip:Compress::Zip::File-instance-method","name":"zip","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":6,"url":null},"def":{"name":"zip","return_type":"Compress::Zip::File","visibility":"Public","body":"@zip"}}]},{"html_id":"xlsx-parser/XlsxParser/Sheet","path":"XlsxParser/Sheet.html","kind":"class","full_name":"XlsxParser::Sheet","name":"Sheet","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/sheet.cr","line_number":2,"url":null}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(book:Book,file:String)-class-method","name":"new","abstract":false,"args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"args_string":"(book : Book, file : String)","args_html":"(book : Book, file : String)","location":{"filename":"src/xlsx-parser/sheet.cr","line_number":5,"url":null},"def":{"name":"new","args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(book, file)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"node:XML::Reader-instance-method","name":"node","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":3,"url":null},"def":{"name":"node","return_type":"XML::Reader","visibility":"Public","body":"@node"}},{"html_id":"rows-instance-method","name":"rows","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":9,"url":null},"def":{"name":"rows","visibility":"Public","body":"Iterator.of do\n row = nil\n row_index = nil\n cell = nil\n cell_type = nil\n loop do\n if @node.read\n else\n break\n end\n if @node.name == \"row\"\n if @node.node_type == XML::Reader::Type::ELEMENT\n row = {} of String => String | Int32\n row_index = node[\"r\"]?\n else\n row = inner_padding(row, row_index, cell)\n break\n end\n else\n if (@node.name == \"c\") && (@node.node_type == XML::Reader::Type::ELEMENT)\n cell_type = node[\"t\"]?\n cell = node[\"r\"]?\n else\n if (((@node.name == \"v\") && (@node.node_type == XML::Reader::Type::ELEMENT)) && row) && cell\n row[cell] = convert(cell_type)\n end\n end\n end\n end\n row || Iterator.stop\nend"}}]}]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"xlsx-parser","body":"# xlsx-parser (v1.0.0)\n![GitHub Workflow Status (event)](https://github.com/D1ceWard/xlsx-parser/actions/workflows/main.yml/badge.svg?branch=master)\n[![GitHub issues](https://img.shields.io/github/issues/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/issues)\n[![GitHub license](https://img.shields.io/github/license/D1ceWard/xlsx-parser)](https://github.com/D1ceWard/xlsx-parser/blob/master/LICENSE)\n\nCrystal wrapper for parsing .xlsx spreadsheets\n\n:rocket: Suggestions for new improvements are welcome in the issue tracker.\n\nNote: Work with Cystal versions `>= 1.4.0, < 2.0.0`\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n xlsx-parser:\n github: D1ceWard/xlsx-parser\n version: 1.0.0\n ```\n\n2. Run `shards install`\n\n## Usage\n\n### With IO\n```crystal\nrequire \"xlsx-parser\"\n\nfile_io = File.new(\"./my_super_spreadsheet.xlsx\")\nbook = XlsxParser::Book.new(file_io)\n```\n\n### With file path\n```crystal\nrequire \"xlsx-parser\"\n\nbook = XlsxParser::Book.new(\"./my_super_spreadsheet.xlsx\")\n```\n\n### Print rows content\n```crystal\n# Iterate on each row of the first sheet\nbook.sheets[0].rows.each do |row|\n puts row #=> { \"A1\" => \"Col A Row 1\", \"B1\" => \"Col B Row 1\" }\nend\n\n# Second sheet\nbook.sheets[1]\n\nbook.close\n```\n\nDocumentation available here : https://d1ceward.github.io/xlsx-parser/\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/D1ceWard/xlsx-parser. By contributing you agree to abide by the Code of Merit.\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [D1ceWard](https://github.com/D1ceWard) - creator and maintainer\n","program":{"html_id":"xlsx-parser/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"xlsx-parser","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"xlsx-parser/XlsxParser","path":"XlsxParser.html","kind":"module","full_name":"XlsxParser","name":"XlsxParser","abstract":false,"locations":[{"filename":"src/xlsx-parser.cr","line_number":5,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser.cr#L5"},{"filename":"src/xlsx-parser/book.cr","line_number":4,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L4"},{"filename":"src/xlsx-parser/sheet.cr","line_number":1,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L1"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"1.0.0\""}],"types":[{"html_id":"xlsx-parser/XlsxParser/Book","path":"XlsxParser/Book.html","kind":"class","full_name":"XlsxParser::Book","name":"Book","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/book.cr","line_number":5,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L5"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"TIME_1900","name":"TIME_1900","value":"Time.utc(1899, 12, 30)"},{"id":"TIME_1904","name":"TIME_1904","value":"Time.utc(1904, 1, 1)"}],"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(file:IO|String,check_file_extension=true)-class-method","name":"new","abstract":false,"args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"args_string":"(file : IO | String, check_file_extension = true)","args_html":"(file : IO | String, check_file_extension = true)","location":{"filename":"src/xlsx-parser/book.cr","line_number":15,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L15"},"def":{"name":"new","args":[{"name":"file","external_name":"file","restriction":"IO | String"},{"name":"check_file_extension","default_value":"true","external_name":"check_file_extension","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(file, check_file_extension)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"base_time-instance-method","name":"base_time","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":58,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L58"},"def":{"name":"base_time","visibility":"Public","body":"@base_time || (@base_time = (begin\n result = TIME_1900\n workbook = XML.parse(@zip[\"xl/workbook.xml\"].open(&.gets_to_end))\n (workbook.xpath_nodes(\"//*[name()='workbookPr']\")).each do |workbook_pr|\n if workbook_pr.try do |__arg4|\n __arg4.attributes[\"date1904\"]\n end.try(&.content) =~ (/true|1/i)\n else\n next\n end\n result = TIME_1904\n break\n end\n result\nend))"}},{"html_id":"close-instance-method","name":"close","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":54,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L54"},"def":{"name":"close","visibility":"Public","body":"@zip.close"}},{"html_id":"shared_strings:Array(String)-instance-method","name":"shared_strings","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":8,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L8"},"def":{"name":"shared_strings","return_type":"Array(String)","visibility":"Public","body":"@shared_strings"}},{"html_id":"sheets-instance-method","name":"sheets","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":36,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L36"},"def":{"name":"sheets","visibility":"Public","body":"workbook = XML.parse(@zip[\"xl/workbook.xml\"].open(&.gets_to_end))\nsheets_nodes = workbook.xpath_nodes(\"//*[name()='sheet']\")\nrels = XML.parse(@zip[\"xl/_rels/workbook.xml.rels\"].open(&.gets_to_end))\n@sheets = sheets_nodes.map do |sheet|\n sheetfile = rels.xpath_string(\"string(//*[name()='Relationship' and contains(@Id,'#{sheet[\"id\"]}')]/@Target)\")\n Sheet.new(self, sheetfile)\nend\n"}},{"html_id":"style_types-instance-method","name":"style_types","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":50,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L50"},"def":{"name":"style_types","visibility":"Public","body":"@style_types || (@style_types = Styles::Parser.call(self))"}},{"html_id":"zip:Compress::Zip::File-instance-method","name":"zip","abstract":false,"location":{"filename":"src/xlsx-parser/book.cr","line_number":6,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/book.cr#L6"},"def":{"name":"zip","return_type":"Compress::Zip::File","visibility":"Public","body":"@zip"}}]},{"html_id":"xlsx-parser/XlsxParser/Sheet","path":"XlsxParser/Sheet.html","kind":"class","full_name":"XlsxParser::Sheet","name":"Sheet","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/sheet.cr","line_number":2,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L2"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"constructors":[{"html_id":"new(book:Book,file:String)-class-method","name":"new","abstract":false,"args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"args_string":"(book : Book, file : String)","args_html":"(book : Book, file : String)","location":{"filename":"src/xlsx-parser/sheet.cr","line_number":8,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L8"},"def":{"name":"new","args":[{"name":"book","external_name":"book","restriction":"Book"},{"name":"file","external_name":"file","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(book, file)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"node:XML::Reader-instance-method","name":"node","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":3,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L3"},"def":{"name":"node","return_type":"XML::Reader","visibility":"Public","body":"@node"}},{"html_id":"rows-instance-method","name":"rows","abstract":false,"location":{"filename":"src/xlsx-parser/sheet.cr","line_number":12,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L12"},"def":{"name":"rows","visibility":"Public","body":"Iterator.of do\n row = nil\n row_index = nil\n cell = nil\n cell_type = nil\n cell_style_idx = nil\n loop do\n if @node.read\n else\n break\n end\n if @node.name == \"row\"\n if @node.node_type == XML::Reader::Type::ELEMENT\n row = {} of String => Type\n row_index = node[\"r\"]?\n else\n row = inner_padding(row, row_index, cell)\n break\n end\n else\n if (@node.name == \"c\") && (@node.node_type == XML::Reader::Type::ELEMENT)\n cell_type = node[\"t\"]?\n cell_style_idx = node[\"s\"]?\n cell = node[\"r\"]?\n else\n if (((@node.name == \"v\") && (@node.node_type == XML::Reader::Type::ELEMENT)) && row) && cell\n row[cell] = convert(@node.read_inner_xml, cell_type, cell_style_idx)\n end\n end\n end\n end\n row || Iterator.stop\nend"}}],"types":[{"html_id":"xlsx-parser/XlsxParser/Sheet/Type","path":"XlsxParser/Sheet/Type.html","kind":"alias","full_name":"XlsxParser::Sheet::Type","name":"Type","abstract":false,"locations":[{"filename":"src/xlsx-parser/sheet.cr","line_number":6,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/sheet.cr#L6"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":true,"aliased":"(Bool | Float64 | Int32 | String | Time)","aliased_html":"Bool | Float64 | Int32 | String | Time","const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser/Sheet","kind":"class","full_name":"XlsxParser::Sheet","name":"Sheet"},"doc":"All possible output types","summary":"

    All possible output types

    "}]},{"html_id":"xlsx-parser/XlsxParser/Styles","path":"XlsxParser/Styles.html","kind":"module","full_name":"XlsxParser::Styles","name":"Styles","abstract":false,"locations":[{"filename":"src/xlsx-parser/styles.cr","line_number":4,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles.cr#L4"},{"filename":"src/xlsx-parser/styles/converter.cr","line_number":1,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/converter.cr#L1"},{"filename":"src/xlsx-parser/styles/parser.cr","line_number":1,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/parser.cr#L1"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"NumFmtMap","name":"NumFmtMap","value":"{0 => :string, 1 => :fixnum, 2 => :float, 3 => :fixnum, 4 => :float, 5 => :unsupported, 6 => :unsupported, 7 => :unsupported, 8 => :unsupported, 9 => :percentage, 10 => :percentage, 11 => :bignum, 12 => :unsupported, 13 => :unsupported, 14 => :date, 15 => :date, 16 => :date, 17 => :date, 18 => :time, 19 => :time, 20 => :time, 21 => :time, 22 => :date_time, 37 => :unsupported, 38 => :unsupported, 39 => :unsupported, 40 => :unsupported, 45 => :time, 46 => :time, 47 => :time, 48 => :bignum, 49 => :unsupported}","doc":"Map of non-custom numFmtId to casting symbol","summary":"

    Map of non-custom numFmtId to casting symbol

    "}],"namespace":{"html_id":"xlsx-parser/XlsxParser","kind":"module","full_name":"XlsxParser","name":"XlsxParser"},"types":[{"html_id":"xlsx-parser/XlsxParser/Styles/Converter","path":"XlsxParser/Styles/Converter.html","kind":"class","full_name":"XlsxParser::Styles::Converter","name":"Converter","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/styles/converter.cr","line_number":2,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/converter.cr#L2"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DATE_TYPES","name":"DATE_TYPES","value":"[:date, :time, :date_time] of ::Symbol"}],"namespace":{"html_id":"xlsx-parser/XlsxParser/Styles","kind":"module","full_name":"XlsxParser::Styles","name":"Styles"},"class_methods":[{"html_id":"call(value:String,type:String?,style:Symbol?,book:Book)-class-method","name":"call","doc":"ameba:disable Metrics/CyclomaticComplexity","summary":"

    ameba:disable Metrics/CyclomaticComplexity

    ","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"String"},{"name":"type","external_name":"type","restriction":"String | ::Nil"},{"name":"style","external_name":"style","restriction":"Symbol | ::Nil"},{"name":"book","external_name":"book","restriction":"Book"}],"args_string":"(value : String, type : String?, style : Symbol?, book : Book)","args_html":"(value : String, type : String?, style : Symbol?, book : Book)","location":{"filename":"src/xlsx-parser/styles/converter.cr","line_number":6,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/converter.cr#L6"},"def":{"name":"call","args":[{"name":"value","external_name":"value","restriction":"String"},{"name":"type","external_name":"type","restriction":"String | ::Nil"},{"name":"style","external_name":"style","restriction":"Symbol | ::Nil"},{"name":"book","external_name":"book","restriction":"Book"}],"visibility":"Public","body":"if type.nil? || ((type == \"n\") && (DATE_TYPES.includes?(style)))\n type = style\nend\ncase type\nwhen \"s\"\n book.shared_strings[value.to_i]\nwhen \"n\"\n value.to_f\nwhen 'b'\n value.to_i == 1\nwhen :string\n value\nwhen :unsupported\n convert_unknown(value)\nwhen :fixnum\n value.to_i\nwhen :float, :percentage\n value.to_f\nwhen :time, :date, :date_time\n convert_time(value, book)\nelse\n convert_unknown(value)\nend\n"}}]},{"html_id":"xlsx-parser/XlsxParser/Styles/Parser","path":"XlsxParser/Styles/Parser.html","kind":"class","full_name":"XlsxParser::Styles::Parser","name":"Parser","abstract":false,"superclass":{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"xlsx-parser/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"xlsx-parser/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/xlsx-parser/styles/parser.cr","line_number":2,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/parser.cr#L2"}],"repository_name":"xlsx-parser","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"xlsx-parser/XlsxParser/Styles","kind":"module","full_name":"XlsxParser::Styles","name":"Styles"},"class_methods":[{"html_id":"call(book:Book):Array(Symbol?)-class-method","name":"call","abstract":false,"args":[{"name":"book","external_name":"book","restriction":"Book"}],"args_string":"(book : Book) : Array(Symbol?)","args_html":"(book : Book) : Array(Symbol?)","location":{"filename":"src/xlsx-parser/styles/parser.cr","line_number":3,"url":"https://github.com/D1ceWard/xlsx-parser/blob/673cfdc3282125012cc33d57e00d3203470c087d/src/xlsx-parser/styles/parser.cr#L3"},"def":{"name":"call","args":[{"name":"book","external_name":"book","restriction":"Book"}],"return_type":"Array(Symbol | Nil)","visibility":"Public","body":"if (styles_file = book.zip[\"xl/styles.xml\"]?)\nelse\n return [] of Symbol | ::Nil\nend\nstyles = XML.parse(styles_file.open(&.gets_to_end))\ncustom_style_types = parse_custom_style_types(styles)\nstyles_nodes = styles.xpath_nodes(\"//*[name()='styleSheet']//*[name()='cellXfs']//*[name()='xf']\")\nstyles_nodes.map do |xstyle|\n if ( num_fmt_id = xstyle.attributes[\"numFmtId\"]?.try(&.content).try(&.to_i))\n else\n next\n end\n NumFmtMap[num_fmt_id]? || custom_style_types[num_fmt_id]\nend\n"}}]}]}]}]}}) \ No newline at end of file