# 표를 만들 때 단에 딱 맞게 만들고 싶습니다.

**URL:** <https://forum.developer.hancom.com/t/topic/1808>\
**Category:** 한글 오토메이션\
**Created:** [9월 23, 2024, 7:43오전 UTC](https://forum.developer.hancom.com/t/topic/1808 "2024-09-23T07:43:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![onlymath](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/onlymath/32/1223_2.png) [@onlymath](https://forum.developer.hancom.com/u/onlymath)\
**Post date:** [9월 23, 2024, 7:43오전 UTC](https://forum.developer.hancom.com/t/topic/1808/1 "2024-09-23T07:43:08Z")

</div>

![화면 캡처 2024-09-23 164121](https://us1.discourse-cdn.com/flex016/uploads/hancom_dev_forum/original/2X/5/5166577433f45f09c75a7e3ccd117e4ec7df90e6.png)

한글스크립트에서  
HAction.GetDefault(“TableCreate”, HParameterSet.HTableCreation.HSet);  
with (HParameterSet.HTableCreation)  
{  
Rows = 1;  
Cols = 3;  
WidthType = 1;  
HeightType = 0;  
}  
HAction.Execute(“TableCreate”, HParameterSet.HTableCreation.HSet);

파이썬에서는  
hwp.HAction.GetDefault(“TableCreate”, hwp.HParameterSet.HTableCreation.HSet)

hwp.HParameterSet.HTableCreation.Rows = 1

hwp.HParameterSet.HTableCreation.Cols = 3

hwp.HParameterSet.HTableCreation.WidthType = 1

hwp.HParameterSet.HTableCreation.HeightType = 0

hwp.HParameterSet.HTableCreation.TableProperties.TreatAsChar = 1

hwp.HAction.Execute(“TableCreate”, hwp.HParameterSet.HTableCreation.HSet)

그런데 단에 딱 맞게 출력이 안되네요… WidthType=0이나 1로 변경해도 안되요…  
무엇을 더 추가해야 할까요?

---

<div class="post-metadata">

**Author:** ![bhjung](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/bhjung/32/259_2.png) [@bhjung](https://forum.developer.hancom.com/u/bhjung)\
**Post date:** [9월 24, 2024, 1:12오전 UTC](https://forum.developer.hancom.com/t/topic/1808/2 "2024-09-24T01:12:19Z")

</div>

안녕하세요 ^^  
파이썬환경에서 HSet을 생성시 주소값이 매번 새로생성되어 정상적으로 동작하지 않는 이슈가 있습니다.  
파이썬에선 CreateAction과 CreateSet을 이용해서 액션을 실행하는 방식으로 사용해야할것 같습니다.  
감사합니다.

> [@인쇄도중 windows와 상호작용을 멈추고 닫히는 경우](https://forum.developer.hancom.com/t/windows/1549/8):
>
> 안녕하세요 ^^ 확인해보니 파이썬환경에서 한글 오토메이션 오브젝트가 다르게 동작하는 부분 확인했습니다. 파이썬에서 “self.hwp.HParameterSet.HPrint.HSet” 와 같이 HParameterSet을 이용해 HSet을 생성시 매번 새로운 주소의 Set값이 생성이 되고있습니다. 해당 방법을 이용해서는 원하시는대로 동작이 어려울것 같습니다. 아래와같은 방식으로 action과 set을 이용해야할것 같습니다. 감사합니다. act = hwp.CreateAction("Print"); set = act.CreateSet(); act.GetDefault(set); set.SetItem("Collate", 1); set.SetItem("UserOrder",0); .... act.Execute(set):

---

<div class="post-metadata">

**Author:** ![jhbang](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jhbang](https://forum.developer.hancom.com/u/jhbang)\
**Post date:** [9월 24, 2024, 1:17오전 UTC](https://forum.developer.hancom.com/t/topic/1808/3 "2024-09-24T01:17:49Z")

</div>

@hbjung님 설명해준 이유 때문에  
아래와 같이 우회 작성을 해주시면 됩니다.

```auto
act = hwp.CreateAction("TableCreate")
set = act.CreateSet()

act.GetDefault(set)

set.SetItem("Rows", 1)
set.SetItem("Cols", 5)
set.SetItem("widthType", 0)
set.SetItem("HeightType", 0)
tblSet = set.Item("TableProperties")
tblSet.SetItem("TreatAsChar", 1)
set.SetItem("TableProperties", tblSet)

act.Execute(set)

```

감사합니다.

---

<div class="post-metadata">

**Author:** ![onlymath](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/onlymath/32/1223_2.png) [@onlymath](https://forum.developer.hancom.com/u/onlymath)\
**Post date:** [9월 29, 2024, 1:05오후 UTC](https://forum.developer.hancom.com/t/topic/1808/4 "2024-09-29T13:05:30Z")

</div>

저번 답변 감사드립니다.

act = hwp.CreateAction(“TableCreate”)  
set = act.CreateSet()  
act.GetDefault(set)  
set.SetItem(“Rows”, 1)  
set.SetItem(“Cols”, 2)  
set.SetItem(“widthType”, 2)  
set.SetItem(“HeightType”, 0)  
colset = set.CreateItemArray(“ColWidth”, 2)  
colset.SetItem(0, 700)  
colset.SetItem(1, 500)  
tblSet = set.Item(“TableProperties”)  
tblSet.SetItem(“TreatAsChar”, 1)  
set.SetItem(“TableProperties”, tblSet)  
act.Execute(set)

이렇게 표칸 크기도 조절하고 싶은데… 안되요… ㅜㅜ 무엇이 잘못되었을까요…

---

<div class="post-metadata">

**Author:** ![ilco](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/ilco/32/1213_2.png) [@ilco](https://forum.developer.hancom.com/u/ilco)\
**Post date:** [10월 6, 2024, 3:25오후 UTC](https://forum.developer.hancom.com/t/topic/1808/5 "2024-10-06T15:25:27Z")

</div>

오타가 있어요…  
`widthType`을 `WidthType`으로 바꾸시면 잘 작동합니다.

---

<div class="post-metadata">

**Author:** ![kosohn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/kosohn/32/2313_2.png) [@kosohn](https://forum.developer.hancom.com/u/kosohn)\
**Post date:** [10월 7, 2024, 5:31오전 UTC](https://forum.developer.hancom.com/t/topic/1808/6 "2024-10-07T05:31:26Z")

</div>

질문의 내용에 좀 더 보태어서  
단의 수를 변경해도 단의 너비에 맞도록 표를 수정하는 방법도 있습니다.

파이썬이 아니라 그렇긴 합니다만…  
관심있으시면 아래 링크에서 확인해 보셔요.

[https://blog.naver.com/kosohn/223356549326](https://blog.naver.com/kosohn/223356549326)
