PDA

View Full Version : مشکل در کار با DataBand در StimulReport



SokooteShab1
دوشنبه 04 اردیبهشت 1391, 12:48 عصر
سلام دوستان.
یه گزارش دارم که با stiReport ایجادش کردم، که این StiReport یه DataBand داره. می خوام موقع اجرا مقدار Height از DataBand رو تغییر بدم ولی پراپرتیش رو پیدا نمی کنم.
خواهش می کنم اگر کسی می تونه کمکم کنه.

crazy_1892
سه شنبه 05 اردیبهشت 1391, 09:15 صبح
دوست عزیز یعنی چی موقع اجرا !!؟؟؟
منظورتون زمانی که گزارش را از برنامه خود فراخوانی می کنید!!!!؟

amir3321
سه شنبه 05 اردیبهشت 1391, 11:01 صبح
ببین اگر از stimul ورژن ultime استفاده کنی همیشه کد اون report رو هم در کنارش داره و می تونی خیلی از اون استفاده کنی و گزینه هایی که می خواهی تغییر بدهی در برنامه باید قبل از compile تغییر بدی
this.DataBand1.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 0.4, 19, 2.13);
بجای this نام report خودت و حتما refrence مربوطه به همراه using فراموش نشود

SokooteShab1
سه شنبه 05 اردیبهشت 1391, 13:11 عصر
منظورتون زمانی که گزارش را از برنامه خود فراخوانی می کنید!!!!؟
دقیاقا منظورم همینه..


this.DataBand1.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 0.4, 19, 2.13);
بجای this نام report خودت و حتما refrence مربوطه به همراه using فراموش نشود
من هم از این کد می خواستم استفاده کنم ولی مشکل ایجاست که DataBand1 رو نمی شناسه(کدC#‎‎‎). منظورت از refrence رو متوجه نشدم (چون موقع استفاده از کنترل stireport خودش Add میشه که). در مورد using هم از using های زیر استفاده کردم.

using Stimulsoft.Controls;
using Stimulsoft.Base.Drawing;
using Stimulsoft.Report;
using Stimulsoft.Report.Dialogs;
using Stimulsoft.Report.Components;
اگه بیشتر راهنماییم کنید ممنون میشم.

amir3321
سه شنبه 05 اردیبهشت 1391, 13:34 عصر
ببین این کد مستقیم دسترسی به اون در حالت runtime قبل از کامپایل ببین بدردت می خوره

report.Pages[0].Components["DataDataSource2"].Height = 5;

report نام گزارش شما
DataDataSource2 نام اون databound مورد نظر که از properties خود گزارش تو حالت design پیدا کن

SokooteShab1
پنج شنبه 07 اردیبهشت 1391, 08:59 صبح
با این کد height تغییر نکرد ولی برای این کار Marginصفحه رو زمان فراخوانی گزارش تغییر می دم. و برای اینکه DataBand قابل کوچک شدن باشه، پراپرتی CanBreak مربوط به DataBand رو از دیزاینِ استیمال، True گذاشتم و مشکلم حل شد. در هر حال ممنون.


Report1.Pages[i].Margins.Top = s.MarginT.Value;
Report1.Pages[i].Margins.Bottom = s.MarginB.Value;
Report1.Pages[i].Margins.Left = s.MarginL.Value;
Report1.Pages[i].Margins.Right = s.MarginR.Value;

amir3321
پنج شنبه 07 اردیبهشت 1391, 11:21 صبح
احتمالا یک جا داری اشتباه می کنی چون من براحتی از این کد استفاده می کنم و مشکلی در تغییر دیتابایند هم نداره یک نمونه از کارهای استاد اسماعیل خواه که در ان یک گزارش بوسیله کد نویسی ایجاد می کنه (که برای گزارش گیری از دیتاگرید ایشون ساختند) رو برات می زارم انشاالله بدرت بخورد

public static void PrintDataGrid(DataGridView sender, bool Landscape, string ReportTitle)
{
DataTable dt = GetDataGridViewDataSource(sender as DataGridView);

foreach (DataColumn dc in dt.Columns)
{
dc.ColumnName = ReplaceSpaceWithUnderline(dc.ColumnName);
}
DataView dataView = dt.DefaultView;
StiReport report = new StiReport();
report.ScriptLanguage = StiReportLanguageType.CSharp;


report.RegData("view", dataView);

//Fill dictionary
report.Dictionary.Synchronize();
StiPage page = report.Pages.Items[0];
if (Landscape)
page.Orientation = StiPageOrientation.Landscape;


//Create Report Title Band
StiReportTitleBand rt = new StiReportTitleBand();
rt.Height = 1.5f;
rt.Name = "ReportTitleBand";
StiText st = new StiText(new RectangleD(0, 0, page.Width, 1f));
st.Text.Value = ReportTitle;
st.HorAlignment = StiTextHorAlignment.Center;
st.Name = "TitleText1";
st.Font = new Font("B Mitra", 16f);
rt.Components.Add(st);
page.Components.Add(rt);


//Create HeaderBand
StiHeaderBand headerBand = new StiHeaderBand();
headerBand.Height = 0.5f;
headerBand.Name = "HeaderBand";
page.Components.Add(headerBand);

//Create Dataaband
StiDataBand dataBand = new StiDataBand();
dataBand.DataSourceName = "view" + dataView.Table.TableName;
dataBand.Height = 0.5f;
dataBand.Name = "DataBand";
page.Components.Add(dataBand);


//Create texts
Double pos = 0;
Double columnWidth = StiAlignValue.AlignToMinGrid(page.Width / dataView.Table.Columns.Count, 0.1, true);
int nameIndex = 1;


for (int i = dataView.Table.Columns.Count - 1; i != -1; i--)
{
DataColumn column = dataView.Table.Columns[i];


//Create text on header
StiText headerText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5f));
headerText.Text.Value = ReplaceUnderLineWithSpace(column.Caption);
// headerText.Text.Value = column.Caption;
headerText.HorAlignment = StiTextHorAlignment.Center;
headerText.Name = "HeaderText" + nameIndex.ToString();
headerText.Brush = new StiSolidBrush(Color.LightGreen);
headerText.Border.Side = StiBorderSides.All;
headerBand.Components.Add(headerText);
headerText.Font = new Font("Tahoma", 8f);



//Create text on Data Band
StiText dataText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5f));
dataText.Text.Value = "{view" + dataView.Table.TableName + "." + Stimulsoft.Report.CodeDom.StiCodeDomSerializator.R eplaceSymbols(column.ColumnName) + "}";
dataText.Name = "DataText" + nameIndex.ToString();
dataText.Border.Side = StiBorderSides.All;
dataText.HorAlignment = StiTextHorAlignment.Center;
dataText.Font = new Font("Tahoma", 8f);
//dataText.WordWrap = true;
//dataText.CanGrow = true;


//Add highlight
//StiCondition condition = new StiCondition();
//condition.BackColor = Color.CornflowerBlue;
//condition.TextColor = Color.Black;
//condition.Expression = "(Line & 1) == 1";
//condition.Item = StiFilterItem.Expression;
//dataText.Conditions.Add(condition);

dataBand.Components.Add(dataText);

pos += columnWidth;

nameIndex++;
}


//Create FooterBand
//StiFooterBand footerBand = new StiFooterBand();
//footerBand.Height = 0.5f;
//footerBand.Name = "FooterBand";
//footerBand.Border = new StiBorder(StiBorderSides.All, Color.Black, 1, StiPenStyle.Solid);

//page.Components.Add(footerBand);


////Create text on footer
//StiText footerText = new StiText(new RectangleD(0, 0, page.Width, 0.5f));
//footerText.Text.Value = "تعداد = {Count()-1}";
//footerText.HorAlignment = StiTextHorAlignment.Right;
//footerText.Name = "FooterText";
//footerText.Brush = new StiSolidBrush(Color.WhiteSmoke);
//footerText.Font = new Font("Tahoma", 8f);

// footerBand.Components.Add(footerText);

//Render without progress bar
report.Render(true);
report.Show();
}

SokooteShab1
پنج شنبه 07 اردیبهشت 1391, 13:45 عصر
شاید دلیل اینکه من نتیجه نگرفتم اینکه از دیتا سورسِ DataBand استفاده نکردم و با تعریف متغیر بهش مقدار دادم. روش استاد اسماعیل خواه هم خیلی خوبه ولی من گزارشم رو از طریق Disign ایجاد کردم و حالا توی کد برنامه میخوام بهش حاشیه بدم تا برای سربرگ های مختلف سِت بشه. یه مشکل دیگه هم دارم، اینکه میشه فاصله بین خط ها(Linespacing) رو در Stimul مشخص کرد؟ پراپرتی در این رابطه پیدا نکردم اگر راهنماییم کنی ممنون میشم.

amir3321
پنج شنبه 07 اردیبهشت 1391, 23:22 عصر
متوجه فاصله بین خطوط نشدم منظورت چیه موقعیکه شما از چند دیتاباند استفاده میکنی ارتفاع اونها این کار رو می کنه یا چیز دیگه ای منظور شماست

SokooteShab1
شنبه 09 اردیبهشت 1391, 09:35 صبح
اگر چند تا خط داخل یه text از دیتاباند داشته باشیم، و بخواهیم فاصله بین خطوط را مثلا 1.5 تنظیم کنیم، و این فاصله ثابت باشه در حالی که تعداد خطوط و ارتفاع دیتاباند ممکنه کم یا زیاد بشه.

amir3321
شنبه 09 اردیبهشت 1391, 15:52 عصر
این پراپرتی که توضیح دادید تا اونجا که من چک کردم نداره

SokooteShab1
یک شنبه 10 اردیبهشت 1391, 10:14 صبح
این پراپرتی که توضیح دادید تا اونجا که من چک کردم نداره
ممنون از توجهتون ......
با کد نویسی چی؟ هیچکی تا حالا برخورد نکرده؟:متعجب:

SokooteShab1
یک شنبه 11 تیر 1391, 12:10 عصر
:کف:جواب پیدا شد:
Solution

1. Put a text component on a page and insert some text in it;
2. Set the AllowHtmlTags property to true. You may find this property in the "2. Text Additional" section of the Object Inspector;
3. Double click the Text component and invoke a dialog box. Select the HTML tag;
4. Set the line-height to a value you need.

Mohsen229266
شنبه 30 مرداد 1395, 17:32 عصر
dataText.Text.Value = "{view"+ dataView.Table.TableName + "."+ Stimulsoft.Report.CodeDom.StiCodeDomSerializator.R eplaceSymbols(column.ColumnName) + "}";

سلام با روش بالا تو وب جواب میده ولی در ویندوز ریپورت جواب نمیده کسی میدونه چرا؟