Problem mit LocalReport im MemoryStream
- From: Tom <tklapettek@xxxxxxx>
- Date: Wed, 21 Jan 2009 01:14:53 -0800 (PST)
Hallo zusammen,
ich habe ein Problem mit LocalReports unter C# mit .Net2005. Ich habe
mehrere Reports die im Hintergrund gedruckt werden sollen. Einer
dieser Reports ist 6 Seiten lang. Die Reports werden über diverse
DataSets gefüllt.
Von dem 6 Seiten langen Report werden jedoch nur 4 Seiten
ausgedruckt.
Die 4 Seiten erhalte ich auch nur, wenn
"report.LocalReport.GetTotalPages();" benutze.
Über "Byte[] firstPage = report.LocalReport.Render("Image",
deviceInfo, out mimeType, out encoding, out extension, out streamIDs,
out warnings); erhalte ich im streamsID nur ZERO length.
Kann mir jemand helfen, a) wie ich alle 6 Seiten gedruckt bekomme und
b) erklären, wie und warum streamsID gefüllt wird?
Zur Info: Wenn ich mir den Report im ReportViewer anschaue werden alle
6 Seiten angezeigt.
private void Export(ReportViewer report)
{
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>29.7cm</PageWidth>" +
" <PageHeight>21cm</PageHeight>" +
" <MarginTop>0.1in</MarginTop>" +
" <MarginLeft>0.1in</MarginLeft>" +
" <MarginRight>0.1in</MarginRight>" +
" <MarginBottom>0.1in</MarginBottom>" +
" <StartPage>0</StartPage>" +
"</DeviceInfo>";
if (m_streams != null)
{
m_streams = null;
}
m_streams = new List<Stream>();
string encoding;
string mimeType;
string extension;
Warning[] warnings;
string[] streamIDs ; //= null;
Byte[][] pages = null;
//Create Byte array containing the rendered image. of the
1st page.
Byte[] firstPage = report.LocalReport.Render("Image",
deviceInfo, out mimeType, out encoding, out extension, out streamIDs,
out warnings);
m_streams.Add(new MemoryStream(firstPage));
// The total number of pages of the report is 1 + the
streamIDs
// int m_numberOfPages = streamIDs.Length + 1;
m_numberOfPages = report.LocalReport.GetTotalPages();
pages = new Byte[m_numberOfPages][];
// The first page was already rendered
pages[0] = firstPage;
for (int pageIndex = 1; pageIndex < m_numberOfPages;
pageIndex++)
{
// Build device info based on start page
deviceInfo = String.Format(
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>29.7cm</PageWidth>" +
" <PageHeight>21cm</PageHeight>" +
" <MarginTop>0.1in</MarginTop>" +
" <MarginLeft>0.1in</MarginLeft>" +
" <MarginRight>0.1in</MarginRight>" +
" <MarginBottom>0.1in</MarginBottom>" +
" <StartPage>{0}</StartPage>" +
"</DeviceInfo>", pageIndex + 1);
//Render the page to a byte array.
pages[pageIndex] = report.LocalReport.Render("Image",
deviceInfo, out mimeType, out encoding, out extension, out streamIDs,
out warnings);
//create a stream of the page's byte array
m_streams.Add(new MemoryStream(pages[pageIndex]));
//set the position of the stream to 0 to make sure
when the stream is read
//it starts from the beginning.
m_streams[m_streams.Count - 1].Position = 0;
}
m_currentPageIndex = 0;
foreach (Stream stream in m_streams)
stream.Position = 0;
}
Vielen Dank in voraus
Gruß
Tom
.
- Follow-Ups:
- Re: Problem mit LocalReport im MemoryStream
- From: Stefan Simon
- Re: Problem mit LocalReport im MemoryStream
- Prev by Date: Re: Erstellen einer Excel-Datei mittels OpenXml SDK V2
- Next by Date: Re: Zugriff auf WPF-Resource
- Previous by thread: Zugriff auf WPF-Resource
- Next by thread: Re: Problem mit LocalReport im MemoryStream
- Index(es):
Relevant Pages
|