Home 소개       다운로드       온라인 설명서      주식/코인 차트    Q & A     Blog    

히포차트 4.3 레포트 - 인쇄하기 샘플 (PrintDialog, PrintPreviewDialog)







buy clomid pct

buy clomid uk go buy clomid tablets

Amoxicillin 500 mg Capsules

buy amoxicillin

amitriptyline 25mg

amitriptyline 50mg

accutane without blood tests

buy accutane europe click cheap accutane

buy low dose naltrexone online

buy naltrexone

buy prednisolone 5mg tablets uk

prednisolone pharmacy
히포차트를 이용하여 인쇄, 레포트 폼을 만드는 샘플을 한 번 알아봅니다. 히포차트 윈폼에서는 차트 저장 기능이 있으므로 닷넷에서 지원하는 프린트 객체와 연동해서 원하시는 프린트 폼을 완성하실 수 있습니다.

또한, 코드 내에 그리드를 그리는 코드도 좋은 참고가 되실듯 합니다.

프로젝트 샘플도 지원하니 소스와 함께 참고하십시오




[히포차트 4.2] 엑셀 내보내기 기능 추가   [히포차트 4.2] 다중시리즈리스트 샘플   [히포차트 4.2] 마이크로차트를 위한 히든 객체 공개  히포차트 4.3 레포트 - 인쇄하기 샘플 (PrintDialog, PrintPreviewDialog)  히포차트 4.3 - 정규분포 곡선 그리기  히포차트 4.3 - Graphics 객체를 사용해 그래프 위에 다른 그림 그리기  히포차트 4.3 - 매틀랩(matlab) 스무싱 기법 (smoothing), 피크 지점 찾기 (Peak Detection)  


C#
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Text;
using System.Windows.Forms;
using Hippo;

namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
SeriesList sList = new SeriesList();
sList.ChartType = ChartType.Column;
sList.AxisFactor.YAxis.IsShorterFigures = true;

Random r = new Random();
for(int i = 0; i < 3; i++)
{
Series sr = new Series();
sr.Name = "Brand" + i.ToString();

sr.UnAxisFactor.PieTypes = PieType.TwoDemention;

for(int x = 0; x < 4; x++)
{
SeriesItem item = new SeriesItem();
item.Name = "product" + x.ToString();
item.IsShowFigureText = true;

item.YValue = r.Next(999999);

sr.items.Add(item);
}
sList.SeriesCollection.Add(sr);
}

this.hHippoChart1.LegendBox.Location = LegendLocation.Top;
this.hHippoChart1.LegendBox.Header.NameLabel.Text = "product111";
this.hHippoChart1.LegendBox.Visible = true;
this.hHippoChart1.Titles.Label.Text = "2015년 상반기 제품별 판매 현황";
this.hHippoChart1.SeriesListDictionary.Add(sList);
this.hHippoChart1.DrawChart();

this.hHippoChart1.SaveImage(@"c:\\printimage.png", System.Drawing.Imaging.ImageFormat.Png);
}

private void button1_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);

PrintDialog printdlg = new PrintDialog();
PrintPreviewDialog printPrvDlg = new PrintPreviewDialog();

printPrvDlg.Document = pd;
printPrvDlg.ShowDialog();

printdlg.Document = pd;

if (printdlg.ShowDialog() == DialogResult.OK)
{
pd.Print();
}
}

void pd_PrintPage(object sender, PrintPageEventArgs e)
{
Single yPos = 0;
Single leftMargin = e.MarginBounds.Left;
Single topMargin = e.MarginBounds.Top;

Image img = Image.FromFile("c:\\printimage.png");

RectangleF chart;

using (Font printFont = new Font("Arial", 15))
{
yPos += 10;
e.Graphics.DrawString(this.hHippoChart1.Titles.Label.Text, printFont, Brushes.Black, 25, yPos, new StringFormat());

yPos += 50;
chart = new RectangleF(leftMargin - 35 + e.MarginBounds.Width / 2 - this.hHippoChart1.Width / 2, (int)yPos, this.hHippoChart1.Width, this.hHippoChart1.Height);

e.Graphics.DrawImage(img, chart.X, chart.Y, chart.Width, chart.Height);
}

yPos += this.hHippoChart1.Height + 50;

// 그리드

// 그리드 열 카운트
int hoCount = this.hHippoChart1.SeriesListDictionary[0].SeriesCollection.Count + 1;

// 그리드 행 카운트
int verCount = this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].items.Count + 1;

int tempLeft = (int)(leftMargin - 35);

for(int i = 0; i < hoCount; i++)
{
RectangleF recCell = new RectangleF(tempLeft, yPos, 170, 50);

using (SolidBrush sol = new SolidBrush(Color.WhiteSmoke))
{
e.Graphics.FillRectangle(sol, recCell.X, recCell.Y, recCell.Width, recCell.Height);
}

using (Pen p = new Pen(Color.Gray))
{

e.Graphics.DrawRectangle(p, recCell.X, recCell.Y, recCell.Width, recCell.Height);

StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;

using (Font printFont = new Font("굴림", 14))
{
if (i == 0)
{
e.Graphics.DrawString("Product/Brand", printFont, Brushes.Black, recCell, format);
}
else
{
e.Graphics.DrawString(this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[i - 1].Name, printFont, Brushes.Black, recCell, format);
}
}
}

tempLeft += 170;
}

yPos += 50;

for(int j = 1; j < verCount; j++)
{
tempLeft = (int)(leftMargin - 35);

for(int i = 0; i < hoCount; i++)
{
using (Pen p = new Pen(Color.Gray))
{
RectangleF recCell2 = new RectangleF(tempLeft, yPos, 170, 50);

e.Graphics.DrawRectangle(p, recCell2.X, recCell2.Y, recCell2.Width, recCell2.Height);

StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Far;
format.LineAlignment = StringAlignment.Center;

using (Font printFont = new Font("굴림", 14))
{
if (i == 0)
{
format.Alignment = StringAlignment.Near;
e.Graphics.DrawString(this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[0].items[j - 1].Name, printFont, Brushes.Black, recCell2, format);
}
else
{
e.Graphics.DrawString(this.hHippoChart1.SeriesListDictionary[0].SeriesCollection[i - 1].items[j - 1].YValue.ToString(), printFont, Brushes.Black, recCell2, format);
}
}
}

tempLeft += 170;
}

yPos += 50;
}


yPos += 50;

RectangleF rec = new RectangleF(leftMargin - 35, yPos, e.MarginBounds.Width + 70, 222);

using (Pen p = new Pen(Color.Gray))
{
//e.Graphics.DrawRectangle(p, rec.X, rec.Y, rec.Width, rec.Height);

using (Font printFont = new Font("굴림", 10))
{
e.Graphics.DrawString(this.textBox1.Text, printFont, Brushes.Black, rec);
}
}
}
}
}


VB
 

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Text
Imports System.Windows.Forms
Imports Hippo

Namespace WindowsApplication3
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs)
Dim sList As New. SeriesList()
sList.ChartType = ChartType.Column
sList.AxisFactor.YAxis.IsShorterFigures = True

Dim r As New. Random()
For i As Integer = 0 To 2
Dim sr As New. Series()
sr.Name = "Brand" + i.ToString()

sr.UnAxisFactor.PieTypes = PieType.TwoDemention

For x As Integer = 0 To 3
Dim item As New. SeriesItem()
item.Name = "product" + x.ToString()
item.IsShowFigureText = True

item.YValue = r.[Next](999999)

sr.items.Add(item)
Next
sList.SeriesCollection.Add(sr)
Next

Me.hHippoChart1.LegendBox.Location = LegendLocation.Top
Me.hHippoChart1.LegendBox.Header.NameLabel.Text = "product111"
Me.hHippoChart1.LegendBox.Visible = True
Me.hHippoChart1.Titles.Label.Text = "2015년 상반기 제품별 판매 현황"
Me.hHippoChart1.SeriesListDictionary.Add(sList)
Me.hHippoChart1.DrawChart()

Me.hHippoChart1.SaveImage("c:\\printimage.png", System.Drawing.Imaging.ImageFormat.Png)
End Sub

Private Sub button1_Click(sender As Object, e As EventArgs)
Dim pd As New. PrintDocument()
pd.PrintPage += New PrintPageEventHandler(AddressOf Me.pd_PrintPage)

Dim printdlg As New. PrintDialog()
Dim printPrvDlg As New. PrintPreviewDialog()

printPrvDlg.Document = pd
printPrvDlg.ShowDialog()

printdlg.Document = pd

If printdlg.ShowDialog() = DialogResult.OK Then
pd.Print()
End If
End Sub

Private Sub pd_PrintPage(sender As Object, e As PrintPageEventArgs)
Dim yPos As [Single] = 0
Dim leftMargin As [Single] = e.MarginBounds.Left
Dim topMargin As [Single] = e.MarginBounds.Top

Dim img As Image = Image.FromFile("c:\printimage.png")

Dim chart As RectangleF

Using printFont As New. Font("Arial", 15)
yPos += 10
e.Graphics.DrawString(Me.hHippoChart1.Titles.Label.Text, printFont, Brushes.Black, 25, yPos, New StringFormat())

yPos += 50
chart = New RectangleF(leftMargin - 35 + e.MarginBounds.Width / 2 - Me.hHippoChart1.Width / 2, CInt(yPos), Me.hHippoChart1.Width, Me.hHippoChart1.Height)

e.Graphics.DrawImage(img, chart.X, chart.Y, chart.Width, chart.Height)
End Using

yPos += Me.hHippoChart1.Height + 50

` 그리드

` 그리드 열 카운트
Dim hoCount As Integer = Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection.Count + 1

` 그리드 행 카운트
Dim verCount As Integer = Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).items.Count + 1

Dim tempLeft As Integer = CInt(leftMargin - 35)

For i As Integer = 0 To hoCount - 1
Dim recCell As New. RectangleF(tempLeft, yPos, 170, 50)

Using sol As New. SolidBrush(Color.WhiteSmoke)
e.Graphics.FillRectangle(sol, recCell.X, recCell.Y, recCell.Width, recCell.Height)
End Using

Using p As New. Pen(Color.Gray)

e.Graphics.DrawRectangle(p, recCell.X, recCell.Y, recCell.Width, recCell.Height)

Dim format As New. StringFormat()
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center

Using printFont As New. Font("굴림", 14)
If i = 0 Then
e.Graphics.DrawString("Product/Brand", printFont, Brushes.Black, recCell, format)
Else
e.Graphics.DrawString(Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(i - 1).Name, printFont, Brushes.Black, recCell, format)
End If
End Using
End Using

tempLeft += 170
Next

yPos += 50

For j As Integer = 1 To verCount - 1
tempLeft = CInt(leftMargin - 35)

For i As Integer = 0 To hoCount - 1
Using p As New. Pen(Color.Gray)
Dim recCell2 As New. RectangleF(tempLeft, yPos, 170, 50)

e.Graphics.DrawRectangle(p, recCell2.X, recCell2.Y, recCell2.Width, recCell2.Height)

Dim format As New. StringFormat()
format.Alignment = StringAlignment.Far
format.LineAlignment = StringAlignment.Center

Using printFont As New. Font("굴림", 14)
If i = 0 Then
format.Alignment = StringAlignment.Near
e.Graphics.DrawString(Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(0).items(j - 1).Name, printFont, Brushes.Black, recCell2, format)
Else
e.Graphics.DrawString(Me.hHippoChart1.SeriesListDictionary(0).SeriesCollection(i - 1).items(j - 1).YValue.ToString(), printFont, Brushes.Black, recCell2, format)
End If
End Using
End Using

tempLeft += 170
Next

yPos += 50
Next


yPos += 50

Dim rec As New. RectangleF(leftMargin - 35, yPos, e.MarginBounds.Width + 70, 222)

Using p As New. Pen(Color.Gray)
`e.Graphics.DrawRectangle(p, rec.X, rec.Y, rec.Width, rec.Height);

Using printFont As New. Font("굴림", 10)
e.Graphics.DrawString(Me.textBox1.Text, printFont, Brushes.Black, rec)
End Using
End Using
End Sub
End Class
End Namespace



※ 히포차트 샘플 코드는 버전별로 상이한 결과를 나타낼 수 있습니다.

이 코드 관련 문의 사항은 페이스북 리플을 달아주시거나 아래 이메일로 이 페이지 주소와 함께 문의주세요.

helpdesk@hippochart.com





Copyright © 2009-2024 히포소프트(Hipposoft)   All Rights Reserved.