Excel To Ruby Array

Login

Email
Password

Don't have an account yet?

Go to Sign up

{{ workbook ? 'Online Table Editor' : 'Input Data' }}
Change File Enter Data
Row Col Row Col
Transpose Clear Delete Empty Deduplicate
ABC abc Abc
Replace
First Row as Header
{{ displayRows.length }} rows x {{ displayHeaders.length }} columns{{ firstRowAsHeader ? ' (1 header)' : '' }} {{ selectedRows.length > 0 ? selectedRows.length + ' selected' : '' }}
Output Data
{{ copied ? 'Copied!' : 'Copy to Clipboard' }} Download File
Properties
Convert Excel to Ruby online — paste, edit, and download Ruby.

Convert Restart
Insert Row Below
Insert Row Above
Insert Column Right
Insert Column Left
Delete Row {{ contextMenu.row + 1 }}
Delete Column {{ contextMenu.col + 1 }}
Clear Cell
Clear Row
Case sensitive Use regex Cancel Replace All

What Is a Ruby Array?

A Ruby array is an ordered, integer-indexed collection of objects. Arrays are one of the most fundamental data structures in Ruby, used to store lists of values — numbers, strings, objects, or even other arrays. Ruby arrays are dynamic: they grow and shrink automatically, and they can hold mixed types in a single collection.

When you convert spreadsheet data to a Ruby array, you get a ready-to-paste code block you can drop into Rails seed files, test fixtures, configuration files, or any Ruby script that needs tabular data.

Ruby Array Syntax at a Glance

SyntaxExampleResult
[] literal["Alice", "Bob", "Carol"]Array of 3 strings
%w[] word list%w[red green blue]["red", "green", "blue"]
%i[] symbol list%i[active pending closed][:active, :pending, :closed]
Nested array[["Alice", 30], ["Bob", 25]]Array of arrays (2D)
Array.newArray.new(3, 0)[0, 0, 0]

Why Convert Excel to Ruby Arrays?

  • Rails seed data — Paste converted arrays directly into db/seeds.rb to populate your database with initial records.

  • Test fixtures — Generate Ruby arrays for Minitest or RSpec test setups without manual data entry.

  • Configuration files — Store lookup tables, permission lists, or enumeration values as Ruby constants.

  • Data migration — Move spreadsheet data into Ruby-based systems without intermediate CSV parsing.

  • Rapid prototyping — Convert product catalogs, pricing tiers, or geographic data into arrays you can iterate over immediately.

Core Features

  • Drag-and-drop upload — Drop any .xlsx, .xls, or .xlsm file onto the upload zone.

  • Built-in table editor — Modify cell values, add or delete rows and columns, transpose, deduplicate, and apply case transformations before conversion.

  • Multi-sheet support — Switch between worksheets in multi-sheet workbooks via the sheet selector dropdown.

  • First Row as Header toggle — Control whether the first row is treated as column headers or regular data.

  • Find & Replace — Bulk-replace cell values with optional regex and case-sensitive matching.

  • Undo / Redo — Full edit history so you can revert mistakes.

  • Copy & Download — One-click copy of the generated Ruby array code, and you can also download the generated Ruby array code.

  • 100% client-side — Your spreadsheet data never leaves your device. No files are uploaded to any server.

How to Convert Excel to Ruby Array

  1. Upload your file — Drag an .xlsx, .xls, or .xlsm file onto the upload area, or click Click here to choose to browse.

  2. Edit if needed — Use the built-in table editor to modify values, add or remove rows and columns, transpose, deduplicate, or apply case changes.

  3. Set options — Toggle First Row as Header on or off depending on your data structure.

  4. Click Convert — Press the Convert button in the Properties panel. The Ruby array output appears in the Output Data area.

  5. Copy & Download the result — Click Copy to Clipboard and paste the Ruby code into your project, and you can also download the generated Ruby array code

Output Example

Input spreadsheet (employees.xlsx):

NameDepartmentSalary
AliceEngineering95000
BobMarketing72000
CarolEngineering102000

Generated Ruby array output:

[
   ["Name", "Department", "Salary"],
   ["Alice", "Engineering", "95000"],
   ["Bob", "Marketing", "72000"],
   ["Carol", "Engineering", "102000"]
]

With First Row as Header enabled, the output becomes an array of hashes — ideal for Rails seed files:

[
   {"Name"=>"Alice", "Department"=>"Engineering", "Salary"=>"95000"},
   {"Name"=>"Bob", "Department"=>"Marketing", "Salary"=>"72000"},
   {"Name"=>"Carol", "Department"=>"Engineering", "Salary"=>"102000"}
]

Ruby Array Quick Reference

MethodDescriptionExample
.lengthReturns the number of elements[1,2,3].length # => 3
.push / <<Append an elementarr << "new"
.mapTransform each element[1,2,3].map { |n| n * 2 }
.selectFilter elements by conditionarr.select { |r| r[1] == "Engineering" }
.flattenCollapse nested arrays[[1,2],[3]].flatten # => [1,2,3]
.eachIterate over elementsdata.each { |row| puts row[0] }

Ruby Array vs Hash for Tabular Data

AspectArray of ArraysArray of Hashes
Access patternIndex-based: row[0]Key-based: row["Name"]
ReadabilityLower — must remember column orderHigher — self-documenting keys
MemoryCompactSlightly larger (key storage)
Best forFixed-position data, matricesRails seeds, API responses, configs

Use the First Row as Header toggle to switch between array-of-arrays and array-of-hashes output.

Frequently Asked Questions

  • What file formats does this tool accept?

    The tool accepts Microsoft Excel files in .xlsx, .xls, and .xlsm formats. LibreOffice and Google Sheets files exported as .xlsx also work.

  • Does the tool upload my Excel file to a server?

    No. All processing happens entirely in your browser using client-side JavaScript. Your file never leaves your device. There are no server uploads, transfers, or storage of any kind.

  • Can I edit the data before converting to a Ruby array?

    Yes. After uploading, a full table editor appears. You can modify individual cells, add or delete rows and columns, transpose the table, remove duplicates, apply case transformations (UPPERCASE, lowercase, Capitalize), and perform find-and-replace operations.

  • What is the difference between array-of-arrays and array-of-hashes output?

    With First Row as Header disabled, each row becomes a nested array — accessed by index (row[0], row[1]). With it enabled, each row becomes a hash — accessed by column name (row["Name"]). Array-of-hashes is more readable and preferred for Rails seed data.

  • Does the tool support multi-sheet Excel files?

    Yes. When your workbook contains multiple sheets, a dropdown selector appears in the editor header. Choose the sheet you want to convert.

  • Can I convert numeric cells to Ruby integers or floats instead of strings?

    The converter outputs all cell values as strings to preserve fidelity. In your Ruby code, you can convert types as needed: row["Salary"].to_i or row["Price"].to_f.

  • Is there a file size limit?

    Since processing is entirely client-side, the limit depends on your browser's memory. Most modern browsers handle workbooks with tens of thousands of rows without issues.

  • How do I use the generated Ruby array in a Rails seed file?

    Copy the output, paste it into db/seeds.rb, and iterate over it. Example:

    employees = [
       {"Name"=>"Alice", "Department"=>"Engineering", "Salary"=>"95000"},
       {"Name"=>"Bob", "Department"=>"Marketing", "Salary"=>"72000"}
    ]
    employees.each do |emp|
       Employee.create!(
           name: emp["Name"],
           department: emp["Department"],
           salary: emp["Salary"].to_i
       )
    end

Featured Tools

Featured tools that you might find useful.

Popular Tools

List of popular tools that users love and frequently use.

New Tools

The latest tools added to our collection, designed for you.

Topics

The tools grouped by topics to quickly find what you need.
Free online JSON to LaTeX table converter. Generate tabular, longtable, or tabularx code from JSON data. Custom borders, captions, alignment, and float positions. 100% client-side.

JSON To LaTeX Table

Free online JSON to LaTeX table converter. Generate tabular, longtable, or tabularx code from JSON data. Custom borders, captions, alignment, and float positions. 100% client-side.
Free online JSON to Custom Template converter. Transform JSON arrays into SQL, CSV, HTML, PHP arrays, batch file commands, or any text format using powerful template syntax — 100% client-side, no sign-up needed.

JSON To Custom Template

Free online JSON to Custom Template converter. Transform JSON arrays into SQL, CSV, HTML, PHP arrays, batch file commands, or any text format using powerful template syntax — 100% client-side, no sign-up needed.
Free online JSON to Markdown table converter. Paste JSON or upload a .json file and instantly generate clean, formatted Markdown tables with aligned columns, bold headers, and custom text alignment — no sign-up required, 100% client-side.

JSON To Markdown Table

Free online JSON to Markdown table converter. Paste JSON or upload a .json file and instantly generate clean, formatted Markdown tables with aligned columns, bold headers, and custom text alignment — no sign-up required, 100% client-side.
Free online JSON to MATLAB converter. Generate cell arrays, numeric matrices, or struct arrays from JSON. Custom variable names, NaN handling, and transposition. 100% client-side.

JSON To MATLAB Array

Free online JSON to MATLAB converter. Generate cell arrays, numeric matrices, or struct arrays from JSON. Custom variable names, NaN handling, and transposition. 100% client-side.