Академический Документы
Профессиональный Документы
Культура Документы
;llAlorkrpilrr:$
home
quickanswers
articles
discussions
features
sisnin
eommunity
Search for anicles, questions, tips
help
Articles
Browse Code
Bugs
Suggestions
Stats
Revisions (14)
ASP.NET ))
Next
Repoftlng
Tarun Dudhatra,
'S & e
"S'
&
lun 2011
4.85(121votes)
Rate this:
Type
Arti(le
Licence
CFot
Posted
First
Alternatives
comments {144)
About Article
20u
12 Mar
Views
637,003
Downloads
57,108
workspaee
Fork this Workspace
Download Crystal report from this link, orjust directly paste the link below to your address bar and it
will ask to save an EXE file.
4b sit
Connect using Git
http;l/dcwnloads.br"rsinessoh.!ects.cen:lakdlm/cr4vs2SlOldRforVS-13-0.exe
C#
ASP.NET C#4.O.NET4
CrystalReports
ffifl%,$ffi
$4. :ffiffi
Top News
klicrcsofl nial<es source
for M5-DOS and
cr:Ce
arrallabte to public
Get the ins;dir Flews free each
morning.
Related videos
In this artiele, I will show you simple report creation process with screenshots" A picture is worth more
than a thousand words, so I always believe in an article with screenshots"
Let's start by creating a new website in VS2010" See the following screen:
;i
i..i
J'i$arn
'n*+u",Onlffi
W
ffi
'I*r,v,'Snline*
m+sW"ffi$
^+
ir
,:\
*w
,ry',,A
Related Articles
Cry;lal Rcpor1 6aiiiirs arrtj
Si:i:il, ar{ls5-Tali
ari
sub R.ep.irl
')'
I of
18
814120141:56 PM
2ulu - u'"'
nllp:/ / w w w. uuutrPr
uJ
uvL.uur
li{?,q|1
Aci;aln
- ${19}
(r?6n:*-
k L{{d!*'d..- ?k ir
*+ E: L'{*!4i3!3 lrd
yr:,{ &l.
t di,
How
io
your pfojeci
-{i
**-
,* 'tr,
', ',t: r r,.
r. $ ': r
q,i.,, 1,";,r,.* *
rt.\
ir ,.,
f:t
Nor-iyl:ei
iirn
C#
iifatah
5SR! Sqri{il ParL j: Vijrli:,u:i w,lys
of R{ipoIt crei+l:iol, da:ployulilll
ard invoaaiioil
Figurc
'tlARloN-TARu...omer-ordets+i
I
i I
:
r
:
Dtsla
Column Neme
.,.
.....
TtFe ;
Cust ord id
int
Cuslomer-NEmE
varrhar{?o0}
."."....
f.{9w tlulls
L,5ing Fotmula
ii
fjryslal Eepilt
lrll
order-ID
inr
ProduEL-liame
vErchar[fuuJ
ll__i
Froducl-Qty
int
Ef,
.',...,
i:.
{,i;,'i
5hiircFoint
.............
E
,,,::
tr
Related Research
t. ,f]
l , s,
Figure 2
you some
The above figure shows the db table structure. And the below figure (Figure 3) will show
sample data in the table:
o;;#;'i'iinniolr-fi nil6;-Ja;;;r''
Frsduct-Name
Name order-lD
Froducl
CuslomBr 1
Produat 2
Cusllmer 1
ProduEt 3
2
Customtsr 1
Producl 4
?
1
Cuslomer
Pr0du't 5
2
CustomEr 1
Produrt I
3
Customer 2
ProduEl 2
3
austqmer Z
Product 3
3
fu5tomer 2
Product 4
4
CustBmBr 2
FroduEl 5
4
Curlomer 2
Froducl t
5
Cust0mer 3
Produrt a
5
Customtsr 3
Product 3
6
Customer 3
i.tiliifrrii[il.-;$;*
ll
'au.t
;r; id
1
2
fl
"1
I
l
il
t
ll
:li
i:
t:
{ustomer
.-....1".d.y-'j-sry
5
3
6
?
lr*n
I
I
i"
It
Figure 3
link
If you want to run this sample project directly, then you can download the database script from the
at the top.
type. Here
Now we have to create an xsd file as a blank data source as we are going to use strong data
I will divide this tutorial in 5 sub sections as mentioned below:
t
.
.
Sub repoft
,..i{ ,r"
i:iii\\t$f;li.ii
Group repoft
Chort report
cross tob report
..-:
Eest Praatiaes fcr 9ealJt|\1o'l
2 of 18
ar(
8l4l20l4l:56 PM
Ilttll:/
/w w
r.!.]
;i;,tl
ftfVtJ
sg5-;"**,.&1
k. - x.1",
g.&,
Csrtificatts
ilr,,r::i--:i
!-
The below figure shows you the pracess to create an XSD file. (O
,u*u, XS*
ilEW Frai}r{t
t* ;;"tu*,t -l*!
YY*
t;'j-:"#"+ig#j W .*ti iii:=.il
: b jo*us
ll;
"
li,i',e;ffi
*{6
ru Lrvrvr/
w.\.uuEPruJ eu r. uuu!
.,.:... ;:....,,
t..rir".
zulu - L"'
,nryr
Y.:?::::':ti
,l
rnilattiii r-qml*atai
lliud E{ct
udurl C*
..,,,,,,,,,,-,...,",,
Sd by, , pgrutL
*'
-i**
ffi
:.
ti$ual
v,r*us*reenm!
dlx
io".)..
ADO,NET
AC4,NET E
fii.ij
Am.
I'JET
Viffif Cf
EntitySalEt]o&l
*ityob,wt
5df
. T! ae
l.i''q
nillv Sener
..
viMI 6 f
!$w
(*
Sfui
Virffil
$-]f,
tii$$
s,*uu* riu
lrgsl Ct
crxs
viiBsl
#.1
,li".l
-1#::
;n:1
,'.*f
l-
ffi
ct*r
uror*
f*
tsusi L#
{r-}stal *eFtrts
visrEl CS
o*os*
rvjwul,(t
nrrur';enxa'r*u
ViffiiC*
i:r:r:.:=
I
lr:
.:.
i'issla,
GffiretDr
E
*"
ll
Figure 4
Click on the ok buttsn, so it will ask for confirmation to put that file in App-Code folder. Just click ok
and that file will open in the screen as a blank screen"
Now we will add one blank datatable to that XSDfile. Just right click on the file and select Add ->
Datatable. Itwill addoneDataTablel tothescreen.Figure5showshowtoadddatatabletoXSDfile.
:::::Sdd]:.=.:
,5hary ne-kiqion t
;r:l
::l
dhels.=.
,:..::1:1;i:i:r:'::.
rvleN;ig0dEr:i : i t:i:
Pron+lE9
Figure 5
of
18
814120141:56 PM
Detii;g
,.i'l* {' i u'lg;,,:}LY,"b.''.'},?orLt BuilJ...;...1
-.,r
d.
:i
#,il
,idr.i*r=.+sG
u"'
Illtp:// w w w.luuvyrvJvv!'vv
AFB-Codei dt56mdgrxsd*
Tlr.l(..\4;ili
Add
+r
ilNiif rr,|,
{ut
fr
{trl+f,
:::
eii*I..i.ii
{trl+C
L!Fy
ltrt::'
P6letB
Ckl+L
Cohrm
i.*
PS
f!d
*enara
4dfssi]']-9..:
ViEW'(o,Js
+I,1t *:iiF.s
Figute 6
asithasin
onceweaddall therequiredcolumnsindatatable,thensetpropertyforthedatacolumn
Pr6&ttt-Qty Datnfollmn
!:.{l
.:. *r
(u$[smrr-],larnB
':!rdor*Ir
Freduul-ruEm&
:;,
::
: .
'r
All6t!08f,lsll
True
&er,rytrft{r6ilent
False
8iltttrfl{rent"nfsee'l
,,.1
*uio!n{it$*nfStep
Ldr{lgfl
Prsdu,:t-qtf'
*,!ie:[yp{
gys|:*fi,5hing
t'3letiroelt*,ie
un*p6rifiEllo{El
ii#fllilrtaluc
s0BNull';,
I
I
rFr*a*i*R,
t
tJ*slq
"t
Prilduct*Qty
ll#1!r"S$s
{Thr4il axcetntlr:u)
*raddntr/
Fal$s
ilnqu*
r&ts6
Ftiilsndh
,,:-$n
lt (i4
,:+Ii ':,::
'i'
,':
X *d**
lH$rl.{,$uffi
-r,*a
-::l
l:i';
F,xinlstl
,.1
fbr
. ..:.
fiEdE.
Irg FrBHtis
r"a")!
fn:
,*i+iietr
*rc,
repoft design'
That's it. XSD file creation has been done. Now we will move to create Crystal
crystal reports" Name it
Just click on the Solution Explorer -> Right click on the project name and select
as per your choice and hit the add button.
Figure 8 will show you the creation process of Crystal reports'
4of18
814120141:56 PM
r u - u"
Generate a Report using Crystal Reports in Visual Stuc[o /u
'
IltLP./ /
WW
W.UUUllJr
uJ ww
$!
vv
ffiffi
!shilleil
Tmot*res,
?'lcml E&sie
Ui*sl C$
Figure
l=,
,@
li.irru*u'l
t*ri!i"il$.,
{hacre ar Ex$ert
e
[.i]cross-Tab
i,
:.:,
!1
i
i
:1i
-----
il.*,*,i-,!=-{
Figure 9
of
18
814120141:56 PM
tILLIJ.// W W W'vuuvPruJwer,vvr
zu I u - u' "
Generate a Report using Crystal Reports in Vrsual Studlo
Figurc 70
"
ta
,tr j: -
, t,i:. .:t1i:.i;
}|i'lll il i
q Lll..r,tu
'"8::::J.i9
tii::urFl=
tr:::;,iiiilritr'
:iJi.i!-!:..:=
i,,"i11
g s.E*lo
"" :rSBlri
1-L):
;:litllr.:
*1f: ll]', r
F,tkr8."iri
il
1,1
mLf:
&d!15:@s$j.si xy.w
sir*;*!
sJ,:*rrs
::.i{.hflliqs-ii,}lFr$E.l-rt-,,:au;;..=ii;i:i::::'a,
:::,:,sgii
':.,
riii
.lhe
4$.ie!j*4
N/@il-lS
3.,,",.'r'sx,,ot.
i if;ir'*ris,
i ;: r+rii ";d
+'d\?Jret4+
:rd
:ll*i:rr,Yt,'il-tit
1{#i;i*l
hzldild$,
J..
ii f,Ft
!t! rk?,
i.ilhhY
elrr r.]ff,
{i
4e@!4t
i]!B*3tF
4&ril'r&
(*,@t*r..$#t
i{rtra}!$:
(lf-..lt*
Figurc 17
once report file is added, you can see Field Explorer on the left side near server explorer.
earlier. Just
Expand Database Fields, under that you will be able to find Datatable that we have created
expand it and drag one by one filed from Field Explorer to the rpt file under detail section.
Now the repoft design part is over" Now we have to fetch the data from database and bind it to dataset
and then bind that dataset to the repo( viewer.
Let's Eo steP by step.
First Drag a
6of18
81412014 1:56 PM
Toalbox
,. r$3;
ii: 5tandard
lt Uala
f ryrtalReportvieHer
,i,l'laviEaLion
Ex!Br
oozv
\rsuErarE-a-rsPUr t-usr...
)$:
- Cry5tElReportvi6werl
+ Loqin
slAx
Asp4simdeReporl,a5px
.t
l he.d-v,l
ii..1rBiidatisn
i"n
http://www.cooeprojecl.com/Artlcres/
l?if-:,nr
rlD'ynanic Deta
iiiRelorLing
t
$
:f
3:
Fcnler
!s
r_rystBtRepotrPEt rsulE(4er
i};
fr'/rtalReporlsflure
f,eFsrltiEHer
CrustalReoortviewer
:.1
Figure 72
Now we will fetch the data, pass data to the dataset and then add that dataset to the Crystal Report.
Below is the C# code which will do the job:
E aollar3e I aopy Code
us
Sqlclienti
e)
thE naye
af dcta i1hl.e
ds.Tabtes[0].Menge (dt) ;
ll
))
SetDataSource(ds) i
= nptDocj
CrystalReportvieuerl.Reportsource
CATALOG=SanplelSj
"
"PEtSlSTSECURITY INr0=FALSE;Connect
Timeout=4";
Sqlcommand cmd =
Dataset ds = nu11.;
new Sq1commando;
SqlDataAdapter adapter;
try
con.openO i
It
ds = new Dataseto;
adapter = new SqlDataAdapten(cmd).;
adapter.Fil}(ds, "Users")r.
)
throw
new Exception(ex"Message);
f i.na11y
{
cmd.Dj.sposeO;
if
(Con"State l= Connectionstate,Closed)
Con"CloseOj
return ds.Tables[0];
)
Now just save everything and run repoft. It will look like the below figure:
7ofl8
814120141:56 PM
#)
F+v:rier lisk
F;+p
erLF,i/.((*.r::qgSq.6-#rArpx/;ftpleReF6ri.$r,
-.liii,,o'-"...,,.::.
:::3
f,laiE
REFcrt
!: l
$il
--.
lNrlrtrir
'l
Pndurl
tr.a.1
lii,r,fl
F,r..,.:L:c1
i.Itri*.m,irJ:r.siri
;rllnilqr
FD*urt
lr
Pl?aucl 4
FEdur.i
Frc:Lfl
r-' il
,]
1
Fr*ds(t:
:*itafior l
Figure
roo./.v Ltueflerate-a-report-usI...
,ie}+a$l
' Fa!0r+ei
http://www.codeproJect.com/41'tlcles/
!r
7i
Just add a repoft (.rpf) file to the solution. Select the appropriate
it's done, then select grouping option Iike flgure 1.4.
i
,
'
,
:
dataset
SsqF&p$r|"ry1:
i.i EataLa;EFidld*
EI Fomr*ia iitldr
Lrl
tnrrnlEiefsrlfJ
!EunnirgTcial
!1tr'l
i?iffi tiffii*
i:iLi{lLrr:l::. : i:,,
i..Lt
$i?:i::r::+:::rr r;.:-;
il
l*.t!:i:=
Fieid:
;;;;;.-*^
rl
ri
$.*3olt
Seii$n
I
!
I Srvien N,eprd
+ . rrtll LqiuEi
I
,3reup E*pext.""
i..---".--------
Swiriev: Rrperl
f'r:iti:f:I!1iw
Yir+
:an
:s
Figure 14
Now, right click on the report, select Report -> Group Experts and the resulting window will look like
figure 15:
gBUp.FoBSt X
I
:!!
FilabrrE Fanidt
Fermdl,
,r.1
r,i
| 3 r,i
vScaiolFw,-e:r,.",.
Fi$!d5
[? 0ar6Bs"6r aleld,
.8. trcu! llnm: I rtld:
Alrtilrhle ilEldr:
Jlj
i
1 !,r
!.s,r.{"r,i,r,8
r,.-
SaerF
ri.
BI
P.ep*rtFieidz
;r a(rtaffilt,hlsmE
r:lrear
l,
5 P.it<J6tt-l,litrt
! p,aCsat_Qt!
0iar$5r
16i$,". I ti*d
Fielii.",
Figure 15
8of18
81420141:56 PM
_ C.."
http://www.codeprqect"com/Articles/
629 I I Geterate-a-report-usi.
Now we want to group like Customer Name and Product name so first add Custome!- to the right
Panel. Then move product name to the right panel like figure 16:
it
*l
llrtabirs Firlr]l
Far$f li Fi4iil,
i?] Plrame.te',
i:-!:"1i-::.9
g
g
Lrr up
rurF'4q ,
S sp<;t) Fir:{d
Lrbbc4 x r tq
Aliii{?Eh ftEIri:
Etr:
m.rg
EepEFF,Eld::
_.
L',llldlal
t: tlucelrcr-i]eot
;:.
garirlrrer-iliir;*1$ars*
fi'i
lji
-&
hl*-L-pr$Cr{t-i.]jse - A
-3+lrZn
J) +rdef lD
.,ir Fr6dl:t-firtbe
-, Fioilr&-ql}
Figure 76
This time Crystal report design will be different than the previous time. See figure 17.
GroupHeaderSectj.onL and 6roupHeaderSection2 are added to the report designer. Here Group
#1 Name refers to Customer Name and Group #2 Name refers to Product Name.
And also GroupFootersectionl and
something to group footer"
6noupFcotersectionZ
1, !& Bltiil.nefili1:
l?l Paramgter
FieJdr:
, >4
n utf Jf, rldff t'!a,ct
P,Bftnift-q TotEi Fiald.
. =
-t. )pcirJl rrerul
|.: tJ[t]ru1{ ilrdi
?,9adi$3
F&gB
lt){$* i
GeEne+l$5rg.o"
Sroup #1 l{anr
EiouB #:
tlam
L,t+*q-.r*
.r:
FrJu*-la+
*qitH:,t
"2
se-iti{$ai
(-aoTlle1
ii:
Llsffi_igH - r l
#.ai6 fl1rFf
ld;;ebel.PFJ-C_13rc ..i i
Aj
:i;:i:
Figure 77
Now under every group, we want to show the number of orders per customer and productwise, so for
that, we have to add summary to the 6roupFootersectiofl2. Refer to Figure 18.
: dS SaGbarr FieliJ,
i i mBrkTiSld
aPtlurlnnrer-liasr
:
e7 ittleUl
:
q! F,oCuat_l.lrrrr
,r;i
r.3
{.
1m_sf:i'1,!!*tq.
F,i?$r
tl;,J
imelc! )rclJi
, '*' j d!c l"r.ri L,Ell:
.
,i.l.i-:
r-,. f,i."di"i,f,:
Prcluf-rllf
ikl F$rntir,,
B.orprqls!.apia :r
i EipErinllidd!
i : ,.lnbn*$d li:e5
h.ile.r.)[i
ti'iili
tliL$*:aii.!-tjfis:iuJ,
iir.iiLLriru:,,
fi,
9 of 18
j I J;,
1l.l
dd :rbld
t.tfte-tl
t:tea
lrtriri ii. o r
Sutrbore
I I ::j i
Tr'i 0n-iEc
t
l
..
ffi
.
Fe:
'vrtyrar,..
81412014 l:56 PM
http://wwwcocleproJ ect.com/Artlcles/
I bo
lv r I lJe,Jetate-a-repofl-usl..
Figure L8
selectlnsert->Summary,ltwillshowyouthenextscreen
RightClickontheGroupFoctersection
(section 3) pad.
lil.l..-".liJiliir*.:;;:-:rt
..si/lr.1r"lR
's!,irc du.1,i'itsme
t'*ou*'lT
r I:! Fsial*!6
i'
"1 r '':..-r
:5{ui:lrma;-tt;ma
F,EIJ:.
:kl:- Y
j.,.:-l::::.1:\\-\\
:::li:l:l'*:
t,r, 6*1"1"614"Pa*.t-*t,
h---.,-r..1
:i ::.
tt! :ra::.:.:!ti
iil-i;_l)i
:,.,. :.;r:ja::::l\
:.:l::l!.;l:lrtrA;r.airi;..,.:.r,r:!1,.i,il
.r .-lnE0unflfar)r
!iltrrnrary ib(i..11s6
i-r-;lllllllllllll
r''i Adri tc
alil
grcup
lllll*
ii+i:r-ntl
ler*l
Figure 19
In summary window, select the column which you want to summarize in the first dropdown.
Select Sum (First option) from the calculate drop down.
Sunrmary Location is already set to the report footer. So just click ok to place that summary field to the
report.
is added
ld irit
6,e.
+fE!Ba4F{..:g!1..
:: {Sll:::=". rt;;i;;;
ffi r-.--'sr.t
. e} (,"!tL n,rr iJ.n!.
, qtFrq*utt.ltunre
sg,Frejs{Ltbi
,
i M Fc,m!'la;ielCs
I li!,idh*r
t rrld:
! e:rqulsrirl(-'*ui
, $tunri*g3*trl iitld:
i t5tECi, r'0i
i.
.qrC{ciIrtl31
';;-"-
'.'-F:',----
:.
',
'
^..-",^.
:.]J-]4
:ru .A.
v 3rd*a&kanl
--.eo ii8s;'li Daal.ohl.:s@
-ir0up #{ IIam
,
r ;4w.+ady5*ds0; f4* tsffi !; f esTipel.Fmal ljme 3 ]
fi ro$P #? ll
'
,-
lmP
{,-
566a3ltHar.
^ ilr(ir
rD-
-1!.1!-"1X;qi,i$rffi,f,I _r|-iry+...1i!.e:s,#;,flS.,+,,T,$.,-!hj,!.fed.k:.
v (l,owimsSri r I ti@
? l;SrJiFwd lsfis
Fef *r +L $ddTab+
*i
iriffi -:(e,
{iffiliitiiiift"'--
Figure 20
Now save the report and run it finally. It looks Iike figure
10
of
18
21
814120141:56 PM
urder
Custamer
nttp://w-ww.cooeproJecl.aofiu-SItlulgb/
ProdLrct Qtv
ILJ
I
Frotluct
Produci 2
Froduct 3
Froduct d
J
Froduet 5
6
73.60
Customer 2
Froduct
Prsduct 2
J
Frgduet 3
5
Figure 27
Chart is the most important and visible part of the repofting tool. Crystal has very powerful feature to
add chart in report. Let's see how to add chart in CR. Here also, we will see only designing of the chart
for other thing. Please refer to Section 1.
Here we will show customer wise product ordered quantity in chart. X portion will display Customer
name and Y portion will display customens total ordered quantity.
G ri.r,SqllrttF$i i{
& Ortab$e
I't
Fieldt
:, I, i.
$drtruln fielde
t, !.1!
3 i r '4
r,5,
tA.
r'7.
r'8'
I'li'
I'18'
r'!,'
$6reup tl**r*Fitl$l
Eftu$nl*E tals, F:i*ld{
:L )pe{rBi I"r$d:
un&rlnd F'reidi
.vsatm},ffi l,
:
rfl5rrt
Seom4lEmn
,"@---,1
glurcei
'=:i;
qoeftal freld
l ,
, Srtrb.ru
Foas e.
v lerm5 ipae tpots 'i ou"gn
i-l
r:;;1i lut0bsect
**- {I
-
s"n
tontrot.'. i
iri:rrtra
r ., ..is::+
-.; A**'.,,
*----': m:i
I
--.*..*-,, ,i pt&;ew
F'cport
Sdctian "
:
,l
Sst[516lats";
f
$
I m,i S*ttePut*
L,fle
Eox
Caa't..
S
m-
Pielure'"
;;;;;:*-
Figurc 22
Once you add chart to the report, it will not show chart on the report file but with mouse pointeryou
can see one blank rectangle is moving. Sojust click on the Report header. lt will open popup for chart
style and other options. Refer to figure 23.
ll
of
18
814120141:56 PM
http://www.codeprolect.com/Artlcles/
,
r
/Uenerate-a-repofi-us1...
Mt
fkaet qxpe{t
t Oozy I
.*-.0 ni*,
*a l
l:X!
.r,
silrdrtt
ss.{E
f*lr,
s::'*
.
ri:j,!slrurt av-i
'
{2. &urg*
ii,e""tt
]Slunret
,
i,l' Hi*oo.ao
1I
Figure
i$l
!'.rtird
!l
'
qriFstni
2l
Now from type tab, select type of the charts like bar ehart, line chart, pie chart, etc. form the left side.
Select sub type from the right pane like side by side chart, percentage bar chart, etc. I am not going
into the detail of it. I am leaving it for you to practice work.
And also seleet vertical or horizontal radio button from the below section if you want to change the
chart style vertically or horizontally. Check Use depth effect check box ifyou need shadow effect on
the graph. Refer to figure 23.
Dita
icil*bl* iFlde
ir.{..-1::.&el$tfl
:li..r;iiLtrliu::.=r..
D{teTJgkl ,tlJtsms-1tr!flr
lf 5!ftFlslit$d-L &f3.ri!T
" ,q
{.tl}iL.j
u {Uit*tslsr.*}lerre
*r A"J-.!n
u Pr*aulrt-tlaoe
u 9lrdud,qiy
i.:,' rw;.,
t'--'-^..^-."-.1!^
id
{r,.n+-liri
i':rr.r.iiira
Figure 24
As per figure 24, move to the next tab data. There are three boxes, available fields, on change of and
show values. So move Customer Name from available fields to on changes of bo& and move Product
ok
Now you can see chart is added to the report header section as per figure 25.
12
of
18
81412014 1:56 PM
http://www.cooeproJecl.colll/l\rtIUles/
"epiFegsrl, rp:'
.
sN(iil Fie;c!
*X r-h^ ,-- a,-,rr
.:
1,{
3c"atrr!
t: r{
i,J.,
i.r,3
:ie.d hdH l
i.i",'i,
,
!.$.,
-,!(!jr,.,.....::r,,,
ri
1r' r'li')'r:'i
"
., :.irrl Li r,.,,,,.i,11
r,i,
:
'.
""'
;{:
eE
:l *.,"
'l
.r
iiI,ft, iu-!.Sr-.tf,#ilii,rr
Figure 25
Now,just
save the report and run it. You can see a Report as a chart on the screen.
Crystal reports provide reports inside report feature which are normally known as a subreport feature.
Let me explain it in detail. Here also, we will design only sub report design" For rest of the things, refer
to Section
1.
Add new report to the solutlon. Then add Report->Group and select only Customen name because
:-{
4$ Databa:e Fields
i.l;
tI
E] oataTsbkl
Fqrmula Fields
E
f
t
]
Llnkound Fidrls
{srupHeadqrFdion
1 16roup
-6 roup #1 flEffe
?:gF.tL?rln[- !k].:?"ffng.rks.fl1
A,{
F-'-..,tifl.lf .f,.,,lF,..4,,1lb,iliiiLLriii,,,,,,,
y..,.qpyFti,#.,fi s]-$mHr,Fifl,f=li.!4p,r,rHriliEt*g.g"ilrnr.,:#
)Edrod] lrEge
tmtr ,
tJumrei
Figure 26
Now right elick on Detail section and select Insert->Subreport. Refer to figure 27
13
of
18
814,20141:56 PM
:::
'j
6ozy I /uenerate-a-repofi-us1...
lublcprc.rpt }
Databast FitlCs
r"4 i.t
i,r 1 r';.r'3
v
Smiml {Eem* Hader l.
!-;-::::;: : :,::' l&-- }
it El DataTablel
l.-x-t Fcrmul'a FielC:
i.[?l?rrameter Field:
; E
http://www.codeprolect.com/Arhcles/
brouF Name
Frerf,E
Heff;r}
9ectrnz,{Page
r.fi.r,?.r
*r ., ..,*.;._..
.....
:-t
t-,.
';!
5Fenal Freldg
llnbn!,nC FlElCg
#Grcg;Nadasectiftil
roup #l llame
-G
trYt*rff
tctoup Header
Fffia
rt*:le
Custorer-Neme
'+r1i1g11tih*u(i$-i,,*rrH,,.;;srliiiiriir,;
' 5pecial F'iefd )
{i,!
J,*CItj:f
..
5c*t Csntrel..,
"t
9er$4n..,
flEl0 Hp{orer
f,rass-Tab.,,
Suhrepr*.,,
Eh
i.'r
:.t::.t::i
Group".".
Freview Repuri
i' i
..
Sumrnary.,,
i--'------
:i
,'r
Preriisus
Eepo*Yim' i
i Linq
;*;.;;;,;,'' .
il
dJL
Es
aharJ
Figure 27
;ili'1
0r-demand:subrepcrt
{similar to a lryperlink)
i
i*;;ffiiil;
Figure 28
create a subreport with Report Wizard (3rd radio button), we have to click on the Report Wizard button
to select report type and data sourcejust do as Part - 1 first. Then click on ok button so llke chart
report it will show a moving rectangle around mouse, click on the detail section where you want to
show subreport.
Now to edit the sub report refer to figure 29.
14
of
18
8l4l20l4l:56 PM
lrhPieFoE
nltp://w-ww.coocprujcut.uulrl-/futlurtrb/ruuzTrluururotu-s-rwyvr!
sDr"
rFl- o
.r,1
U"'
1'+"l
r":.
!,i
S^ec*rm3 iPaEe
liearer ]
l'3'l'3'l'i*'l
l'g','I
^GmrHeadsgs;or
. Sroup
#1 tlame
v Se*rs,.3
i
--;1 :tilelaEs :--
J aoie
l.Custmx-l{ame' A'i
iProduct'r't'ise
.i
Y"
--
EditSubrePstt
rb
Frrmat Sbjeet
"l-r
t
I
vsecryrltieltrIlPfEJ
v
&i
c
Y:,.
Smrm5{Fese .Fmter ;)
..
6.h;.
[ t'lumrei
Figure 29
Click on the edit subreport option and format the report as per your need. Here I will suggest add
product name and product quantity or you can add chart also for sub report. When you click on the
subreport button, it will open subreport designer, aetually CR will create a separate.rpt file but it will
remain hidden inside the main .rpf file so we can't see it..
Now run the report and you can see the result, repoft inside report like figure 30.
a:-$3.2[
E IUB
1 "ft1
"1.11 1
P ro
cuLl *
1,
1a!91
p!id*:t r:3:1f
fireil sls
li.4q
i:+i4
3n5:3
t
36ld
Red
ffa
ii
l"Jsril
!:: :t:
t:: t::::
jl
.. .
t.. j*t
Linne
.",
dni ,
NWi
;,i
*r
":ssy,
t:::::r:-::":: : r:1:11:r':a'a':l::'ll:
tr
l,,lain F.epcrt
Figure 30
Here number 1 is the main report and number 2 is the subreport it's showing title as Product wise
First, let me make it clear as to what is a Cross tab report. Normally, we generate report row wise like
first we show Customer name, then product Wise, etc. But Suppose we want to See report as column
wise like produet name should be displayed as column in report, then cross tab report comes into the
picture. See result of Cross Tab report in figure 31.
15
of
18
814120141:56 PM
http://www.codeproject.com/Afilcles/
I Obzy I
/uenerate-a-repofl-us1..
Itiih ftf,pert
Prsdu{t.l
Telsl
Procucl I
Prsduet 3
ii.0A
+.{}s
5.0q
3.0{
E,SS
ClstsmEr 3
2.0{
3.tls
5,0$
3-00
8.00
31,88
Ulnloltsr 3
9.0s
.{"tE
?.00
5,0{t
?.ss
3L06
f{6ttnx.4
6.0{
E,OE
fi,s0
?5.0{
IlL0s
$:1,i1$
1?,0{
5.S{
3-0s
0:ss
t.fls
{I.{}g
53"00
?6.0{
d!.08
36.ofl
1?.f,8
1s3.fl0
Cu$lGfr8{
C*gtsr.er
Toisi
Fr*durt
P,sdrst
Figurc 3L
Here also, I will show how to design cross tab report only, for rest of the things, refer to Section 1.
First add .rpt file to the solution. Then add cross report to the Report Header section as per the below
figure
to figure
(Refer
32).
Remember we can add cross tab report only in Report header or report footer section.
f,rpsilcl.Si:
. 1,1. I':'r,3,t
:e
"4't'F-
v lqyrl tPoglfeuioj"*
l,'*r+*!,d.
1Yry'
1
Insert
:
l
,l
#J;;;
Eepert
:1
BesiEn
1
.l
l
iil
i.i*:* illaq:rr:
Pr*.i*iftrp,rrt
ilErs gptorer
Fra.iou:
Repnrl'dlr*
ll*u'r:nu:*'
.. ...
i,:lr
htg
I
Line
tsot
f,hart.".
it
..:
Figure 32
Once we click on cross tab report options, it will show moving rectangle around mouse pointer just
place it to the report header section.
As we click on header section, it
33.
$dd
.
j
_.... .
ls lhE,iii$riM xh* reiirtti r;r14!
Bill lP dr:pl.Eu ,fl thE .dB df th! g< (a
rr@r-l!E
AYiil..Hs
tuldii
i:akmn$
*.
'i:; li&tilri**,((drre!-linFt
} 5!ryi.ofti61 lrDi.li[]:r
Ltsllnh;
= * .aeilr6.r^Ninr.
,
Its*Trl,nt-Pradu(
*iqi.
a !l
,:
1..,1
3i{1..!l
r .. _
t.-4,/. trr,",-
lsmniiYr,
,i q'.g{$,a4r^
:r:t.l
'1:::r.:.: .1.t_ -.
Fid$r:
I
I
:.ii
I
]-
. ....... ld
t,..,--les
ls. i
Figure 33
Asperthefigure,moveCustomeP
t6 of l8
namefieldtotheRowssection,Product namewewanttoshow
814l20l4l:56 PM
It's as simple as that. If you have any queries regarding any type of the above mentioned reports,
please let me know by way of comments. I will try my level best to fulfill yoLlr request.
Let's enjoy reportingl
;r'ir-,
-,:":
This article, along with any associated source code and files, is licensed under The Code Proiect 01:en
Lleensr (CPOL)
Tarun Dudhatra
Software Developer Working in
Ahmedabad, Gujarat, India
lndia;S
4.0,
C#, Javascrlpt, Crystal Reports, JQuery etc.
on;
Puhlish Artic!e
Follow on
!ix'lln'Lti
;S
l\'
ir?itier
Article Top
'r
'l:ll! l"!:p:
Normal
Perpaqe
2s
ffi$i;i,ffi
First Prev
Next
mostafataha
25-Feb-L4 20148
t*
SyedSaiiadHasan
2o-Jan-14 19:59
Menrbe.3s45689?
20-Dee-13 19:22
sri-kantho526
reports
Useful p*st
xp Reporting engine"..
18
'
of
l"!fd
r",+ Crysta!
17
1!-:-:l:c
$. jon-80
3-Dec-13 3:30
24-Nov-13 20:01
81412014 1:56 PM
ereate the
$p renu.iitkgp
15-Nov-13 2:53
sazzadST
27-Oct-13 0:36
bijumonjoseph
*f
Member 9115775
30-Sep-13 5:49
'
s";"nus
26-5ep-13 5:49
gcod job
Member 1O2U7O1
3-Sep-13 17:20
Member 10248199
3-Sep-l3 1L39
Litrle help
$f
jonisopara
My vote of 5
manish14982
30-Aug-13 2:30
rakeshojha12345
28-Aug-13 5:49
d+ crystal reFort
rakeshojha1234S
28-Aug-13 5:49
Member 10212959
durgeshj
kumaruasupalli
capFranc
4t
Ho$E
appiicati*n
**
FaIy
*,+--.
{$ w*b
wd
lEr
y*u
v+te of
Br
,i Myvate*f 5
' ExpNanat!cn
ri
15-Oct-13 22:54
My r/*te of 5
''
21-Sep-13 10:06
31-Aug-13
2t23
1s-Aug-13 21:48
30-Jul-13 0:48
25-Jul-13 19:13
23-Jul-13 3:20
th
{*
(d
Thankc
mudsshir alam
3-Jul-13 2:46
S.
pabiswain
2-Jul-13 5:50
clean 8r underst&nd
utiz.t
Last Visie
31-Dec-99
General
file
18:00
,' News r
:;, chancnkaj
8-Jul-13 8:27
Ll-Jun-13 15:37
t 23456
Suggestion
Question
4S'
erg i;
Answer
.g{}
Joke
S nant
Next"
{? admin
ijse Ctrl+Left/Right to switch messages, Ctrl+UplDown to switch threads, Ctrl+Shift+Left/Right to switch pages.
frermalin;( | y',Cve'li$e I Frivn.ri I Mobile
Web03 I 2.8.140406.1 | Last Updated 8 Jun 2011
l8 of
18
814120141:56 PM