Ребят возникла следующая проблемка
Добавлено: 29 апр 2008, 07:08
Ребят возникла следующая проблемка, я создаю отчет в ручную, присоединяю к отчету reportdatasource , создаю колонки и StiDataBand. Запускаю отчет в дизайне все прекрасно работает все формируется код создается и в шапке у него проставлен источник данных reportdatasource, пытаюсь запустить отчет в рантайме, отчет падает не может найти reportdatasource, при генерации кода строка с источником данных почему то отсутствует , возможно я что-то упустил или не проставил, вот код отчета
public void PrintReport(NsgIGrid grid)
{
NsgReport report = new NsgReport();
report.ReportLoaded = true;
report.Clear(true);
/////////////////////////////////////////////////////////////////////////////////
StiReportDataSource stiReportDataSource1 = new StiReportDataSource();
NsgReportDataSource rdsSource = new NsgReportDataSource();
rdsSource.MasterComponent = grid.SourceObject;
rdsSource.Name = "ИсточникДанных";
rdsSource.Records = NsgSoft.Forms.NsgSourceRows.AllRows;
////////////////////////////////////////////////////////////////////////////////////////////////
stiReportDataSource1 = new NsgSoft.ReportBuilder.Design.StiReportDataSource("ИсточникДанных", rdsSource);
stiReportDataSource1.Item = rdsSource;
stiReportDataSource1.Name = "ИсточникДанных";
report.ReportAlias = "Отчет";
report.ReportDataSources.Add(stiReportDataSource1);
report.ReportSourceValue = "ИсточникДанных";
report.ReportGuid = "9a2378b551d54840b817c1a4634ed793";
report.ReportName = "Отчет";
report.ReportUnit = NsgSoft.ReportBuilder.StiReportUnitType.Centimeters;
report.ScriptLanguage = NsgSoft.ReportBuilder.StiReportLanguageType.CSharp;
report.ShowBookmarksPanel = false;
report.UseProgress = NsgSoft.ReportBuilder.NsgReport.ProgressType.EventProgress;
/////////
report.RegData(rdsSource.Name, rdsSource.UserData);
report.IsSyncMode = false;
report.OwnerForm = null;
report.ReferencedAssemblies = new string[] {
"System.Dll",
"System.Drawing.Dll",
"System.Windows.Forms.Dll",
"System.Data.Dll",
"System.Xml.Dll",
"NsgSoft.ReportControls.Dll",
"NsgSoft.ReportBase.Dll",
"NsgSoft.ReportBuilder.Dll",
"NsgSoft.Common.Dll",
"NsgSoft.Database.Dll",
"NsgSoft.DataObjects.Dll",
"NsgSoft.Design.Dll",
"NsgSoft.Forms.Dll"};
List list = new List(report.ReferencedAssemblies);
list.Add(grid.SourceObject.ConfigurationAssembly.ManifestModule.ToString());
report.LoadReport();
report.ReferencedAssemblies = list.ToArray();
StiComponentsCollection colec = report.GetComponents();
StiPage page = report.Pages[0];
StiDataBand dataBand = new StiDataBand();
dataBand.CountData = 1;
dataBand.CanBreak = true;
dataBand.Height = 0.5;
dataBand.Name = "DataBand1";
StiHeaderBand haderBand = new StiHeaderBand();
haderBand.CanBreak = true;
haderBand.Height = 0.5;
haderBand.Name = "Haderband1";
page.Components.Add(haderBand);
page.Components.Add(dataBand);
dataBand.DataSourceName = "ИсточникДанных";
report.ReportDataSources.Report.UpdateInheritedReport();
double widthAllCollumn = 0;
foreach (NsgIGrid.Column colum in grid.GetVisibleColumns())
{
widthAllCollumn += colum.Width;
}
double sizeIndex = 0;
double MoveColumn = 0;
foreach (NsgIGrid.Column colum in grid.GetVisibleColumns())
{
sizeIndex = (colum.Width*page.Width)/widthAllCollumn;
StiText dataTextHeder = new StiText(new RectangleD(MoveColumn, 0, MoveColumn+sizeIndex, 0.5));
StiText dataText = new StiText(new RectangleD(MoveColumn, 0, MoveColumn + sizeIndex, 0.5));
dataText.Text = "{ИсточникДанных." + colum.Name + "}";
dataText.Name = colum.Name+ "D";
dataText.Border = new StiBorder(StiBorderSides.All, Color.Black, 2, StiPenStyle.Solid);
dataText.Width = sizeIndex;
dataTextHeder.Text = colum.Name;
dataTextHeder.Name = colum.Name;
if (colum.TextPosition == ContentAlignment.MiddleLeft || colum.TextPosition == ContentAlignment.BottomLeft
|| colum.TextPosition == ContentAlignment.TopLeft)
{
dataText.HorAlignment = StiTextHorAlignment.Left;
}
else if (colum.TextPosition == ContentAlignment.MiddleRight || colum.TextPosition == ContentAlignment.TopRight
|| colum.TextPosition == ContentAlignment.BottomRight)
{
dataText.HorAlignment = StiTextHorAlignment.Right;
}
else
{
dataText.HorAlignment = StiTextHorAlignment.Center;
}
dataTextHeder.VertAlignment = StiVertAlignment.Center;
dataText.VertAlignment = StiVertAlignment.Center;
dataTextHeder.HorAlignment = StiTextHorAlignment.Center;
dataTextHeder.Height = 0.5;
dataText.Height = 0.5;
dataText.GrowToHeight = true;
dataText.CanGrow = true;
dataText.TextOptions = new NsgSoft.ReportBase.Drawing.StiTextOptions(false, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
dataTextHeder.GrowToHeight = true;
dataTextHeder.CanGrow = true;
dataTextHeder.TextOptions = new NsgSoft.ReportBase.Drawing.StiTextOptions(false, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
/////////////////////////////////////////////////////////////////
dataTextHeder.Border = new StiBorder(StiBorderSides.All, Color.Black, 2, StiPenStyle.Solid);
dataTextHeder.Width = sizeIndex;
dataBand.Components.Add(dataText);
haderBand.Components.Add(dataTextHeder);
MoveColumn += sizeIndex;
}
if (MoveColumn > page.Width)
page.Orientation = StiPageOrientation.Portrait;
report.ShowInWindow = NsgReport.WindowType.ParentWindow;
//report.Design();
report.ShowReport(null);
}
Зарание спасибо
public void PrintReport(NsgIGrid grid)
{
NsgReport report = new NsgReport();
report.ReportLoaded = true;
report.Clear(true);
/////////////////////////////////////////////////////////////////////////////////
StiReportDataSource stiReportDataSource1 = new StiReportDataSource();
NsgReportDataSource rdsSource = new NsgReportDataSource();
rdsSource.MasterComponent = grid.SourceObject;
rdsSource.Name = "ИсточникДанных";
rdsSource.Records = NsgSoft.Forms.NsgSourceRows.AllRows;
////////////////////////////////////////////////////////////////////////////////////////////////
stiReportDataSource1 = new NsgSoft.ReportBuilder.Design.StiReportDataSource("ИсточникДанных", rdsSource);
stiReportDataSource1.Item = rdsSource;
stiReportDataSource1.Name = "ИсточникДанных";
report.ReportAlias = "Отчет";
report.ReportDataSources.Add(stiReportDataSource1);
report.ReportSourceValue = "ИсточникДанных";
report.ReportGuid = "9a2378b551d54840b817c1a4634ed793";
report.ReportName = "Отчет";
report.ReportUnit = NsgSoft.ReportBuilder.StiReportUnitType.Centimeters;
report.ScriptLanguage = NsgSoft.ReportBuilder.StiReportLanguageType.CSharp;
report.ShowBookmarksPanel = false;
report.UseProgress = NsgSoft.ReportBuilder.NsgReport.ProgressType.EventProgress;
/////////
report.RegData(rdsSource.Name, rdsSource.UserData);
report.IsSyncMode = false;
report.OwnerForm = null;
report.ReferencedAssemblies = new string[] {
"System.Dll",
"System.Drawing.Dll",
"System.Windows.Forms.Dll",
"System.Data.Dll",
"System.Xml.Dll",
"NsgSoft.ReportControls.Dll",
"NsgSoft.ReportBase.Dll",
"NsgSoft.ReportBuilder.Dll",
"NsgSoft.Common.Dll",
"NsgSoft.Database.Dll",
"NsgSoft.DataObjects.Dll",
"NsgSoft.Design.Dll",
"NsgSoft.Forms.Dll"};
List list = new List(report.ReferencedAssemblies);
list.Add(grid.SourceObject.ConfigurationAssembly.ManifestModule.ToString());
report.LoadReport();
report.ReferencedAssemblies = list.ToArray();
StiComponentsCollection colec = report.GetComponents();
StiPage page = report.Pages[0];
StiDataBand dataBand = new StiDataBand();
dataBand.CountData = 1;
dataBand.CanBreak = true;
dataBand.Height = 0.5;
dataBand.Name = "DataBand1";
StiHeaderBand haderBand = new StiHeaderBand();
haderBand.CanBreak = true;
haderBand.Height = 0.5;
haderBand.Name = "Haderband1";
page.Components.Add(haderBand);
page.Components.Add(dataBand);
dataBand.DataSourceName = "ИсточникДанных";
report.ReportDataSources.Report.UpdateInheritedReport();
double widthAllCollumn = 0;
foreach (NsgIGrid.Column colum in grid.GetVisibleColumns())
{
widthAllCollumn += colum.Width;
}
double sizeIndex = 0;
double MoveColumn = 0;
foreach (NsgIGrid.Column colum in grid.GetVisibleColumns())
{
sizeIndex = (colum.Width*page.Width)/widthAllCollumn;
StiText dataTextHeder = new StiText(new RectangleD(MoveColumn, 0, MoveColumn+sizeIndex, 0.5));
StiText dataText = new StiText(new RectangleD(MoveColumn, 0, MoveColumn + sizeIndex, 0.5));
dataText.Text = "{ИсточникДанных." + colum.Name + "}";
dataText.Name = colum.Name+ "D";
dataText.Border = new StiBorder(StiBorderSides.All, Color.Black, 2, StiPenStyle.Solid);
dataText.Width = sizeIndex;
dataTextHeder.Text = colum.Name;
dataTextHeder.Name = colum.Name;
if (colum.TextPosition == ContentAlignment.MiddleLeft || colum.TextPosition == ContentAlignment.BottomLeft
|| colum.TextPosition == ContentAlignment.TopLeft)
{
dataText.HorAlignment = StiTextHorAlignment.Left;
}
else if (colum.TextPosition == ContentAlignment.MiddleRight || colum.TextPosition == ContentAlignment.TopRight
|| colum.TextPosition == ContentAlignment.BottomRight)
{
dataText.HorAlignment = StiTextHorAlignment.Right;
}
else
{
dataText.HorAlignment = StiTextHorAlignment.Center;
}
dataTextHeder.VertAlignment = StiVertAlignment.Center;
dataText.VertAlignment = StiVertAlignment.Center;
dataTextHeder.HorAlignment = StiTextHorAlignment.Center;
dataTextHeder.Height = 0.5;
dataText.Height = 0.5;
dataText.GrowToHeight = true;
dataText.CanGrow = true;
dataText.TextOptions = new NsgSoft.ReportBase.Drawing.StiTextOptions(false, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
dataTextHeder.GrowToHeight = true;
dataTextHeder.CanGrow = true;
dataTextHeder.TextOptions = new NsgSoft.ReportBase.Drawing.StiTextOptions(false, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
/////////////////////////////////////////////////////////////////
dataTextHeder.Border = new StiBorder(StiBorderSides.All, Color.Black, 2, StiPenStyle.Solid);
dataTextHeder.Width = sizeIndex;
dataBand.Components.Add(dataText);
haderBand.Components.Add(dataTextHeder);
MoveColumn += sizeIndex;
}
if (MoveColumn > page.Width)
page.Orientation = StiPageOrientation.Portrait;
report.ShowInWindow = NsgReport.WindowType.ParentWindow;
//report.Design();
report.ShowReport(null);
}
Зарание спасибо