我正在将此DeviceInfo传递给报告:
<DeviceInfo>
<OutputFormat>Word</OutputFormat>
<PageWidth>11in</PageWidth>
<PageHeight>8.5in</PageHeight>
<MarginTop>1in</MarginTop>
<MarginLeft>0.5in</MarginLeft>
<MarginRight>0.5in</MarginRight>
<MarginBottom>1in</MarginBottom>
</DeviceInfo>
但是,当报表呈现时(如Word或PDF),页面大小是11 x 11英寸,而不是11 x 8.5(横向)。为什么是这样?如何获得具有适当尺寸的报告?
这里是我呈现报告的位置:
byte[] bytes = Report.Render( // Report is an instance of the Microsoft.Reporting.WebForms.LocalReport class
reportType,
deviceInfo, // this contains the XML above
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
看来报告页面大小没有正确初始化,所以我这样做了:
var page = report.Page;
page.LeftMargin = LeftMargin;
page.RightMargin = RightMargin;
page.TopMargin = TopMargin;
page.BottomMargin = BottomMargin;
// I added these next two lines
page.PageWidth = PageWidth;
page.PageHeight = PageHeight;