Skip to content

Commit

Permalink
Add excel-tables.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hoontee committed Dec 3, 2023
1 parent a337d76 commit d2a4064
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 4 deletions.
107 changes: 104 additions & 3 deletions docs/lync/project-format/files/excel-tables.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,107 @@
::: danger UNFINISHED
This documentation is unfinished.
:::
# Excel Tables
Excel Tables specify a range of cells from an Excel Spreadsheet (`XLSX`/`XLS`) to translate into a [ModuleScript](https://create.roblox.com/docs/reference/engine/classes/ModuleScript).

The resulting table can be formatted in multiple ways.

## Syntax
::: info File Name
- `*.Excel.JSON`
:::
::: info Keys
- string `spreadsheet` - A relative path to the associated Excel Spreadsheet.
- string `ref` - 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](https://support.microsoft.com/en-us/office/create-a-named-range-from-selected-cells-in-a-worksheet-fd8905ed-1130-4cca-9bb0-ad02b7e594fd), which allows the range to be modified from inside the Excel worksheet.
- boolean `hasHeader` - Whether or not the first row should be used as keys for nesting elements in the translated Excel Table.
- number `numColumnKeys` - Defines by how many columns each entry should be nested.
:::

## Examples

### Example 1
Given an Excel Spreadsheet named `Economy.xlsx` containing the following in a sheet named `Pets`;
| | A | B | C | D | E | F |
|-|-|-|-|-|-|-|
| 1 | PetID | Name | Area | Deluxe | Rarity | Power |
| 2 | Starter_Cat | Cat | 1 | 0 | 0 | 5 |
| 3 | Starter_Dog | Dog | 1 | 0 | 0 | 5 |
| 4 | Starter_Bunn | Bunny | 1 | 0 | 0 | 5 |

... and an Excel Table file named `Pets.Excel.JSON` containing the following;
```json
{
"spreadsheet": "Economy.xlsx",
"ref": "Pets!A1:F4",
"hasHeader": true,
"numColumnKeys": 1
}
```
... the following table will appear in Roblox as a [ModuleScript](https://create.roblox.com/docs/reference/engine/classes/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 in a sheet named `Sheet1`;
| | C | D | E | F |
|-|-|-|-|-|
| 4 | Name | Foo | Bar | Baz |
| 5 | Alfa | 512 | 64 | 8 |
| 6 | Bravo | 256 | | 4 |
| 7 | Charlie | 128 | 16 | 2 |

... and an Excel Table file named `Leaderboard.Excel.JSON` containing the following;
```json
{
"spreadsheet": "Players.xlsx",
"ref": "Sheet1!C4:F7",
"hasHeader": true,
"numColumnKeys": 0
}
```
... the following table will appear in Roblox as a [ModuleScript](https://create.roblox.com/docs/reference/engine/classes/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,
},
}
```
2 changes: 1 addition & 1 deletion docs/lync/project-format/files/json-models.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# JSON Models
JSON Models describe a simple set of Instances.

Unlike Model Files (`RBXM`/`RBXMX`); their data is limited to that which can be assigned by a script (e.g., no [MeshPart](https://create.roblox.com/docs/reference/engine/classes/MeshPart) data.)
Unlike Model Files (`RBXM`/`RBXMX`\;) their data is limited to that which can be assigned by a script (e.g., no [MeshPart](https://create.roblox.com/docs/reference/engine/classes/MeshPart) data.)

## Syntax
::: info File Name
Expand Down
3 changes: 3 additions & 0 deletions docs/lync/project-format/files/meta-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ They are used in scenarios where it would be desirable to change the properties
:::

## Examples

### Example 1
The most common use case is changing the ClassName of a Folder.

If your project has a Folder and you want to change its ClassName, you will create a `Init.Meta.JSON` inside it with:
Expand All @@ -25,6 +27,7 @@ If your project has a Folder and you want to change its ClassName, you will crea
}
```

### Example 2
Another use case is changing the properties of a Model File (`RBXM`/`RBXMX`). Because the file is encoded, it cannot have its properties changed directly.

If your project has `{example}.RBXM` (which contains a single [Part](https://create.roblox.com/docs/reference/engine/classes/Part)) and you want to make it a different color, you would create a `{example}.Meta.JSON` next to it with:
Expand Down

0 comments on commit d2a4064

Please sign in to comment.