# 셀너비 가져오기, 표안에 이미지 넣기

**URL:** <https://forum.developer.hancom.com/t/topic/1447>\
**Category:** 한글 오토메이션\
**Created:** [4월 9, 2024, 12:45오전 UTC](https://forum.developer.hancom.com/t/topic/1447 "2024-04-09T00:45:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuristar](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@nuristar](https://forum.developer.hancom.com/u/nuristar)\
**Post date:** [4월 9, 2024, 12:45오전 UTC](https://forum.developer.hancom.com/t/topic/1447/1 "2024-04-09T00:45:46Z")

</div>

안녕하세요? 두가지가 궁금해서 여쭤보고자 글을 올립니다.

1. 표에서 현재 셀의 크기를 확인하는 방법  
표 만들때 크기를 지정은 가능한데 이미 만들어진 셀의 크기를 가져오는 방법은 모르겠는데요  
표 안에서 현재 커서가 위치한 셀의 가로, 세로 크기를 가져오는 방법이 궁금한데 가능할까요?

2. 표안에 그림을 넣을때 셀 가로크기 보다 크기를 조금 작게 넣을 수 있을까요?

```auto
   double width = 1;
   double height = 1;
   hwp.InsertPicture(filename, true, 3, false, false, 0, width, height); // 셀 크기에 맞춰서

```

HwpAutomation 문서를 보면 세번째 파라메타 값이 2 나 3일때는  
“현재 캐럿이 표의 셀 안에 있을 경우 셀의 크기에 맞게 자동 조절하여 삽입한다  
width는 셀의 width만큼, height는 셀의 height만큼 확대/축소된다”  
라고 나와있는데요

여기서 width, height 값은 어떻게 줘야 할까요?

셀의 가로 크기에 너무 딱 맞춰서 이미지가 삽입되는데…  
셀의 가로 크기보다 조금 더 작게 넣고 싶은데 가능할까요?

현재 커서가 위치한 셀의 가로 크기를 구할수 있으면 이미지의 가로 크기를 설정하면 될텐데…  
표의 크기가 그때 그때 달라서요…

---

<div class="post-metadata">

**Author:** ![nuristar](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@nuristar](https://forum.developer.hancom.com/u/nuristar)\
**Post date:** [4월 9, 2024, 2:04오전 UTC](https://forum.developer.hancom.com/t/topic/1447/2 "2024-04-09T02:04:34Z")

</div>

아래 게시물 중 표안의 셀 크기 관련 내용중

```auto
var Height;
var Width;
HAction.GetDefault("TablePropertyDialog", HParameterSet.HShapeObject.HSet);
Height = HParameterSet.HShapeObject.ShapeTableCell.Height / 283;
Width = HParameterSet.HShapeObject.ShapeTableCell.Width / 283;

```

위와 같은 코드가 있는데

c#에서는 에러가 나더라구요…

```auto
hwp.HAction.GetDefault("TablePropertyDialog", hwp.HParameterSet.HShapeObject.HSet);
var Width = hwp.HParameterSet.HShapeObject.ShapeTableCell.Width / 283.465;
var Height = hwp.HParameterSet.HShapeObject.ShapeTableCell.Height / 283.465;
Debug.WriteLine($"가로 : {Width}, 세로 : {Height}");

```

임의로 이렇게 수정해봤는데 가로, 세로 크기가 모두 0으로 나오는데  
c#에서는 어떻게 수정해야 할까요?

---

<div class="post-metadata">

**Author:** ![nuristar](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@nuristar](https://forum.developer.hancom.com/u/nuristar)\
**Post date:** [4월 9, 2024, 3:45오전 UTC](https://forum.developer.hancom.com/t/topic/1447/3 "2024-04-09T03:45:42Z")

</div>

아니면 그림의 크기를 가져올 수 있나요?  
그림의 크기를 가져온 후에 크기를 가로, 세로 각각 90% 크기로 수정할 수 있을까요?

---

<div class="post-metadata">

**Author:** ![nuristar](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@nuristar](https://forum.developer.hancom.com/u/nuristar)\
**Post date:** [4월 11, 2024, 8:40오전 UTC](https://forum.developer.hancom.com/t/topic/1447/6 "2024-04-11T08:40:42Z")

</div>

c# 에서 cell 크기 가져오는 방법을 알아냈습니다.

다른 코드에서 action 을 만들어서 하는 방법을 응용하다가 이렇게 해보고 저렇게 해보다 보니 나오네요 ㅎㅎ

```auto
var act = hwp.CreateAction("TablePropertyDialog");
var set = act.CreateSet();
act.GetDefault(set);
w = set.Item("ShapeTableCell").Item("Width") / 283.465;
h = set.Item("ShapeTableCell").Item("Height") / 283.465;

Debug.WriteLine($"가로 : {w}, 세로 : {h}");

```

결과 =\> 가로 : 74.002081385709, 세로 : 4.52260420157691

이렇게 하니 소숫점이하로 길게 나오는데 적당히 반올림 해주면 될거 같네요.

---

<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:** [4월 12, 2024, 1:26오전 UTC](https://forum.developer.hancom.com/t/topic/1447/7 "2024-04-12T01:26:37Z")

</div>

@nuristar 님,  
직접 답변을 달아주셨네요. 😂  
한글 오토메이션의 API가 문서를 핸들링하기에는 불친절하다는 것은 내부에서도 인지하고 있습니다.  
필요한 API나 의견을 많이 남겨주시면 반영하도록 노력하겠습니다. 🙂

감사합니다.
