1. 시작
devExpress SpreadSheet 로 엑셀 출력물을 만들 때 제목을 텍스트박스(도형)으로 만들고 싶었다.
2. 뻘짓
제목 텍스트 박스 만들고 나니 결재란도 만들고 싶었다.
2-1. 예제 투척 - 결재란 그리기 (대충 아래 표 모양임)
결 재 |
직책 | 직책 | 직책 |
직급 성명 | 직급 성명 | 직급 성명 | |
(결재란) |
//결재 박스
int xF = 3500;
int yF = 10;
int wF = 70;
//직책 시작점
int x = xF + wF;
int y = yF;
int w = 210;
int h = 55;
//직급 시작점
int y2 = y + h;
int y3 = y + h + h;
int h3 = 170;
//결재 박스 높이
int hF = h + h + h3;
//결재 박스
Shape shape0 = MadeTextBox(xF, yF, wF, hF, "결재", worksheet);
//직책 박스
Shape shape1 = MadeTextBox(x, y, w, h, "직책1", worksheet);
Shape shape2 = MadeTextBox(x + w, y, w, h, "직책2", worksheet);
Shape shape3 = MadeTextBox(x + w + w, y, w, h, "직책3", worksheet);
//직급 박스
Shape shape4 = MadeTextBox(x, y2, w, h, "직급1", worksheet);
Shape shape5 = MadeTextBox(x + w, y2, w, h, "직급2", worksheet);
Shape shape6 = MadeTextBox(x + w + w, y2, w, h, "직급3", worksheet);
//결재란 박스
Shape shape7 = MadeTextBox(x, y3, w, h3, "", worksheet);
Shape shape8 = MadeTextBox(x + w, y3, w, h3, "", worksheet);
Shape shape9 = MadeTextBox(x + w + w, y3, w, h3, "", worksheet);
//만들어진 도형을 그룹으로 묶음.
Shape shapeGroup = worksheet.Shapes.GroupShapes(new Shape[] { shape1, shape2, shape3, shape4, shape5, shape6, shape7, shape8, shape9, shape0 }); // 그룹으로.
//박스 만들고, 내용 입력. 엑셀 추가 됨.
private Shape MadeTextBox(int x, int y, int w, int h, string txt, Worksheet worksheet)
{
Shape shape = worksheet.Shapes.AddTextBox(x, y, w, h, txt);
shape.Outline.SetSolidFill(Color.Black);
ShapeText shapeText = shape.ShapeText;
shapeText.HorizontalAnchor = ShapeTextHorizontalAnchorType.Center;
shapeText.VerticalAnchor = ShapeTextVerticalAnchorType.Center;
shapeText.WordWrap = true;
//text
ShapeTextRange range = shapeText.Characters();
//font
//range.Font.Bold = true;
//range.Font.Color = Color.YellowGreen;
range.Font.Size = 10;
range.Font.Name = "맑은 고딕";
return shape;
}
3. 기타. 채우기
shape.Fill.SetSolidFill(Color.Blue); // 채우기
Shape shape1 = worksheet.Shapes.AddShape(ShapeGeometryPreset.RectangularCallout, 100, 100, 300, 300); //도형
4. 더 편한 방법
: 걍 엑셀 카메랑 기능으로 결재 박스 만들어 사용 하면 됨.
5. 끝.