Skip to content

Excel Tables

Excel Tables specify a range of cells from an Excel Spreadsheet (XLSX/XLS) to translate into a ModuleScript.

The resulting table can be formatted in multiple ways.

Syntax

File Name

  • *.Excel.JSON

Keys

  • spreadsheet: string
    • A relative path to the associated Excel Spreadsheet.
  • ref: string
    • The 2D range with which to pull data from. Formatted as sheetName!rowColumn:rowColumn, e.g. Sheet1!A1:C3. It can also be a named range, which allows the range to be modified from inside the Excel worksheet.
  • hasHeader: boolean
    • Whether or not the first row should be used as keys for nesting elements in the translated Excel Table.
  • numColumnKeys: number
    • Defines by how many columns each entry should be nested.
  • lastColumnKeyUsesIndices: boolean
    • Whether or not the last nesting defined by numColumnKeys should be treated as an array.

Examples

Example 1

Given an Excel Spreadsheet named Economy.xlsx containing the following cells in a sheet named Pets;

ABCDEF
1PetIDNameAreaDeluxeRarityPower
2Starter_CatCat1005
3Starter_DogDog1005
4Starter_BunnBunny1005

... and an Excel Table file named Pets.Excel.JSON containing the following;

json
{
	"spreadsheet": "Economy.xlsx",
	"ref": "Pets!A1:F4",
	"hasHeader": true,
	"numColumnKeys": 1,
	"lastColumnKeyUsesIndices": false
}

... the following table will appear in Roblox as a ModuleScript named Pets:

lua
return {
	Starter_Cat = {
		Name = "Cat",
		Area = 1,
		Deluxe = 0,
		Rarity = 0,
		Power = 5,
	},
	Starter_Dog = {
		Name = "Dog",
		Area = 1,
		Deluxe = 0,
		Rarity = 0,
		Power = 5,
	},
	Starter_Bunn = {
		Name = "Bunny",
		Area = 1,
		Deluxe = 0,
		Rarity = 0,
		Power = 5,
	}
}

TIP

It's important to format tables in ways that are easy for you to use. When tables are organized with keys instead of indices, you will be able to access these entries directly (e.g., Pets[uniquePetId].)

Example 2

Given an Excel Spreadsheet named Players.xlsx containing the following cells in a sheet named Sheet1;

CDEF
4NameFooBarBaz
5Alfa512648
6Bravo2564
7Charlie128162

... and an Excel Table file named Leaderboard.Excel.JSON containing the following;

json
{
    "spreadsheet": "Players.xlsx",
    "ref": "Sheet1!C4:F7",
    "hasHeader": true,
    "numColumnKeys": 0,
	"lastColumnKeyUsesIndices": false
}

... the following table will appear in Roblox as a ModuleScript named Leaderboard:

lua
return {
	{
		Name = "Alfa",
		Foo = 512,
		Bar = 64,
		Baz = 8,
	},
	{
		Name = "Bravo",
		Foo = 256,
		Bar = nil,
		Baz = 4,
	},
	{
		Name = "Charlie",
		Foo = 128,
		Bar = 16,
		Baz = 2,
	},
}

Lync and Pronghorn released under LGPL 2.1