# SpreadSheet

<figure><img src="/files/KH5sGBlakNOJawYawGuP" alt=""><figcaption></figcaption></figure>

샘플맵 바로가기🔗

{% content-ref url="/pages/-MVtfYoN7zHoqLwn7vIV" %}
[Scripting](/ditoland/sample/scripting.md)
{% endcontent-ref %}

***

***

### 🌱 SpreadSheet 생성

월드 트리에서 ‘오브젝트 생성’을 통해 SpreadSheet를 생성할 수 있어요.

* Workspace / Toybox 내부에 생성

<figure><img src="/files/a2CAPTPRJKw3MJnzVE8M" alt=""><figcaption></figcaption></figure>

###

### 🔩 SpreadSheet 구조

<figure><img src="/files/MlohnzBSSCIvt9NVPc0J" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="84.33333333333331"> </th><th width="206">용어</th><th>설명</th></tr></thead><tbody><tr><td>①</td><td>행/열 (+) (-)</td><td>행/열 추가 삭제</td></tr><tr><td>②</td><td>테이블 (셀 영역)</td><td>데이터 입력 영역 (행과 열로 구성)</td></tr><tr><td>③</td><td>닫기</td><td>스프레드 시트 닫기</td></tr><tr><td>④</td><td>저장</td><td>스프레드 시트 저장</td></tr><tr><td>⑤</td><td>초기화</td><td>스프레드 시트 초기화</td></tr><tr><td>⑥</td><td>Export</td><td>스프레드 시트를 csv 파일로 내보내기</td></tr><tr><td>⑦</td><td>Import</td><td>외부 csv 파일 가져오기</td></tr></tbody></table>

***

###

### 💡 SpreadSheet 작성시 참고사항

* List 타입의 데이터는 🏕 쉼표 ( , ) 를 구분 문자로 사용해요.
* GetBoolData 함수는 1 을 true, 이외 값은 false로 판별해요. ⚖

<figure><img src="/files/MKSUuS402M2FqThwR3Gh" alt=""><figcaption></figcaption></figure>

***

### 📤 SpreadSheet 내보내기 (Export)

Export 기능을 이용해 작성한 스프레드 시트를 csv 파일로 내보낼 수 있어요.

<figure><img src="/files/TEu0LiZyASywBQkvAqbo" alt=""><figcaption></figcaption></figure>

***

### 📥 외부 csv 파일 가져오기 (Import)

Import 기능을 이용해 외부 csv 파일을 가져올 수 있어요.

<figure><img src="/files/BH5eMJgOs67nvDJUG2I1" alt=""><figcaption></figcaption></figure>

***

### 📊 스크립트에서 SpreadSheet 활용

####

#### SpreadSheet 선언 🎊

월드 트리의 경로를 이용해 스크립트에서 스프레드 시트를 선언해줄 수 있어요.

<figure><img src="/files/8ZIbKdq1ASoNgRxtKxhF" alt=""><figcaption></figcaption></figure>

####

#### SpreadSheet의 데이터 가져오기 📥

‘T 프로퍼티’ 나 ‘함수’를 사용해서 특정 셀의 데이터를 가져올 수 있으며,

특정 셀을 지정할 때는 ‘행/열 번호’, ‘행/열 키’ 를 사용해요.

* 행/열 번호 (Row/Column Num)

<figure><img src="/files/vdNdmDYLS396xJOacCId" alt=""><figcaption></figcaption></figure>

* 행/열 키 (Row/Column Key)

<figure><img src="/files/VxkdNqoJ4oTulGwZh8Xz" alt=""><figcaption></figcaption></figure>

* 🛑 특정 셀을 지정할 때 ‘행/열 키’를 사용할 경우, **UseStringKey 함수를 먼저 호출**해줘야 해요.

```lua
local MonsterSheet = Workspace.MonsterSheet
MonsterSheet:UseStringKey()

local GoblinDam = MonsterSheet.T["Goblin"]["Dam"] -- 40
-- UseSetingKey 함수를 호출해주지 않으면 Key로 데이터 가져올 수 없어요.
```

예시) Goblin - Dam 값 가져오기

<figure><img src="/files/fx3asjyU5mNPZYMCpr0k" alt=""><figcaption></figcaption></figure>

(1) T 프로퍼티 사용

* T 프로퍼티는 테이블 접근 편의를 위한 프로퍼티에요.

* SpreadSheet.T\[Row]\[Column] 구조를 사용해요.

  ```lua
  local MonsterSheet = Workspace.MonsterSheet

  --행/열 번호 사용
  local GoblinDam = MonsterSheet.T[3][2] -- 40

  --행/열 키 사용
  SpreadSheet:UseStringKey()
  local GoblinDam = SpreadSheet.T["Goblin"]["Dam"] -- 40
  ```

* 🛑 SpreadSheet.T\[”RowKey”]\[”ColumnKey”] 구조에서는 Key로 사용하는 1행과 1열의 데이터는 \
  가져올 수 없어요.

<figure><img src="/files/asZAYcDUP75yxnodk7Lz" alt=""><figcaption></figcaption></figure>

\*\* Key를 이용해 1행 혹은 1열의 데이터를 가져올 경우에는 함수를 사용해주세요.

```lua
local SpreadSheet = Workspace.SpreadSheet
SpreadSheet:UseStringKey()

local a = SpreadSheet.T["Goblin"]["Name"] -- X
local b = SpreadSheet:GetStringData("Goblin", "Name") -- Goblin
```

(2) 함수 사용

* Get\_\_Data(Row, Column) 구조를 사용해요. ( \* \_\_에는 가져올 데이터의 타입이 들어가요. )

  ```lua
  local MonsterSheet = Workspace.MonsterSheet

  --행/열 번호 사용
  local GoblinDam = MonsterSheet:GetNumberData(3, 2) -- 40

  --행/열 키 사용
  MonsterSheet:UseStringKey()
  local GoblinDam = SpreadSheet:GetNumberData("Goblin", "Dam") -- 40
  ```

***

### 📜 SpreadSheet 함수 목록

<table><thead><tr><th width="243">함수명</th><th>설명</th></tr></thead><tbody><tr><td>UseStringKey</td><td>데이터를 키 값으로 찾을 수 있도록 선언해줘요.</td></tr><tr><td>GetStringData</td><td>지정한 셀의 데이터를 String 타입으로 반환해요.</td></tr><tr><td>GetStringListData</td><td>지정한 셀의 데이터를 StringList 타입으로 반환해요.</td></tr><tr><td>GetNumberData</td><td>지정한 셀의 데이터를 Number 타입으로 반환해요.</td></tr><tr><td>GetNumberListData</td><td>지정한 셀의 데이터를 NumberList 타입으로 반환해요.</td></tr><tr><td>GetBoolData</td><td>지정한 셀의 데이터를 Bool 타입으로 반환해요.</td></tr><tr><td>GetRowCount</td><td>스프레드 시트의 행 개수를 반환해요.</td></tr><tr><td>GetColumnCount</td><td>스프레드 시트의 열 개수를 반환해요.</td></tr><tr><td>GetRow</td><td>지정한 행의 데이터를 Table 타입으로 반환해요.</td></tr><tr><td>GetColumn</td><td>지정한 열의 데이터를 Table 타입으로 반환해요.</td></tr></tbody></table>

**| void UseStringKey()**

데이터를 키 값으로 찾을 수 있도록 선언 해줘요.

```lua
local MonsterSheet = Workspace.MonsterSheet
MonsterSheet:UseStringKey()

local GoblinDam = MonsterSheet.T["Goblin"]["Dam"]
local GoblinDam = MonsterSheet:GetNumberData("Goblin", "Dam")

print(GoblinDam) -- 40
```

**| string GetStringData(number Row, number Column)** \
\&#xNAN;**| string GetStringData(string RowKey, string ColumnKey)**

지정한 셀의 데이터를 String 타입으로 반환해요.

```lua
local MonsterSheet = Workspace.MonsterSheet

--행/열 번호 사용
local GoblinName = MonsterSheet:GetStringData(3, 1)

--행/열 키 사용
SpreadSheet:UseStringKey()
local GoblinName = MonsterSheet:GetStringData("Goblin", "Name")

print(GoblinName) -- Goblin
```

**| stringList GetStringListData(number Row, number Column)** \
**| stringList GetStringListData(string RowKey, string ColumnKey)**

지정한 셀의 데이터를 StringList 타입으로 반환해요.\
\*\* 구분문자는 쉼표( , ) 로, 쉼표를 기준으로 데이터를 나눠 테이블에 넣어요.

```lua
local MonsterSheet = Workspace.MonsterSheet

--행/열 번호 사용
local GoblinDesc = MonsterSheet:GetStringListData(3, 3)

--행/열 키 사용
MonsterSheet:UseStringKey()
local GoblinDesc = MonsterSheet:GetStringListData("Goblin", "Desc")

print(GoblinDesc[1], ", ", GoblinDesc[2]) -- 고블린 설명1, 고블린 설명2
```

**| number GetNumberData(number Row, number Column)** \
**| number GetNumberData(string RowKey, string ColumnKey)**

지정한 셀의 데이터를 Number 타입으로 반환해요.

```lua
local MonsterSheet = Workspace.MonsterSheet

--행/열 번호 사용
local GoblinDam = MonsterSheet:GetNumberData(3, 2)

--행/열 키 사용
MonsterSheet:UseStringKey()
local GoblinDam = MonsterSheet:GetNumberData("Goblin", "Dam")

print(GoblinDam) -- 40
```

**| numberlist GetNumberListData(number Row, number Column)** \
**| numberlist GetNumberListData(string RowKey, string ColumnKey)**

지정한 셀의 데이터를 NumberList 타입으로 반환해요.\
\*\* 구분문자는 쉼표( , ) 로, 쉼표를 기준으로 데이터를 나눠 테이블에 넣어요.

```lua
local MonsterSheet = Workspace.MonsterSheet

--행/열 번호 사용
local GoblinWayIDList = MonsterSheet:GetNumberListData(3, 4)

--행/열 키 사용
MonsterSheet:UseStringKey()
local GoblinWayIDList = MonsterSheet:GetNumberListData("Goblin", "WayIDList")

print(GoblinWayIDList[1], ", ", GoblinWayIDList[2], ", ", GoblinWayIDList[3])  --1, 7, 3
```

**| bool GetBoolData(number Row, number Column)** \
**| bool GetBoolData(string RowKey, string ColumnKey)**

지정한 셀의 데이터를 Bool 타입으로 반환해요.\
\*\* GetBoolData는 데이터 값이 1 일 때만 true를 반환해요.

```lua
local MonsterSheet = Workspace.MonsterSheet

--행/열 번호 사용
local OrcState1 = MonsterSheet:GetBoolData(2, 5)
local GoblinState1 = MonsterSheet:GetBoolData(3, 5)

--행/열 키 사용
SpreadSheet:UseStringKey()
local OrcState1 = MonsterSheet:GetBoolData("Orc", "State1")
local GoblinState1 = MonsterSheet:GetBoolData("Goblin", "State1")

print(OrcState1) -- true
print(GoblinState1) -- false
```

**| number GetRowCount()**

스프레드 시트의 행 개수를 반환해요.

```lua
local MonsterSheet = Workspace.MonsterSheet

local RowCount = MonsterSheet:GetRowCount()
print(RowCount) -- 5
```

**| number GetColumnCount()**

스프레드 시트의 열 개수를 반환해요.

```lua
local MonsterSheet = Workspace.MonsterSheet

local ColumnCount = MonsterSheet:GetColumnCount()
print(ColumnCount) -- 5
```

**| Table GetRow(number Row)**

지정한 행의 데이터를 Table 타입으로 반환해요.

```lua
local MonsterSheet = Workspace.MonsterSheet

local GoblinRowTable = MonsterSheet:GetRow(3)   -- 3행의 데이터
local GoblinDam = GoblinRowTable[2]             -- 3행의 2열 데이터

print(GoblinDam) -- 40
```

**| Table GetColumn(number Column)**

지정한 열의 데이터를 Table 타입으로 반환해요.

```lua
local MonsterSheet = Workspace.MonsterSheet

local DamColumnTable = MonsterSheet:GetColumn(2) -- 2열의 데이터
local GoblinDam = ColumnTable[3]                 -- 3행의 2열 데이터

print(GoblinDam) -- 40
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ditoland-utplus.gitbook.io/ditoland/manual/spreadsheet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
