背景 我正在使用winforms通过Visual Studio 2012创建报表。我的报告包括2个表,两个表上面都有一个带有表名的文本框。我知道要将表行组合在一起,您使用“保持在一起”属性,该属性修复了我的原始问题,即仅显示第一行,其余页面稍后。
问题: 但是,当我导出PDF时,例如使用第一个表,它会显示文本框,其中包含表格的名称,但表格不显示3页。
问题: 如何在报表中将控件保持在一起,而不会在每个控件之间出现重叠或大的空格?
保证金设定代码(XML代码段)
<Page>
<LeftMargin>1in</LeftMargin>
<RightMargin>1in</RightMargin>
<TopMargin>1in</TopMargin>
<BottomMargin>1in</BottomMargin>
<Style />
</Page>
.cs代码段
private void ExportPDF(LocalReport report, string filename)
{
Microsoft.Reporting.WinForms.ReportPageSettings rptPageSettings = report.GetDefaultPageSettings();
string width = "";
double tmp = ((double)rptPageSettings.PaperSize.Width) * .01;
width = tmp.ToString("#0.00",System.Globalization.CultureInfo.InvariantCulture) + "in";
string height = "";
tmp = ((double)rptPageSettings.PaperSize.Height) * .01;
height = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";
string topMargin = "";
tmp = ((double)rptPageSettings.Margins.Top) * .01;
topMargin = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";
string bottomMargin = "";
tmp = ((double)rptPageSettings.Margins.Bottom) * .01;
topMargin = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";
string rightMargin = "";
tmp = ((double)rptPageSettings.Margins.Right) * .01;
topMargin = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";
string leftMargin = "";
tmp = ((double)rptPageSettings.Margins.Left) * .01;
topMargin = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";
string deviceInfo = "<DeviceInfo><PageWidth>" + width + "</PageWidth><PageHeight>" + height + "</PageHeight><MarginTop>" + topMargin + "</MarginTop><MarginLeft>" + leftMargin + "</MarginLeft><MarginRight>" + rightMargin + "</MarginRight><MarginBottom>" + bottomMargin + "</MarginBottom></DeviceInfo>";
Warning[] warnings;
m_streams = new List<Stream>();
report.Render("PDF", deviceInfo, CreateStream, out warnings);
FileStream fs = new FileStream(filename, FileMode.Create);
m_streams[0].Position = 0;
for (int i = 0; i < m_streams[0].Length; i++)
{
fs.WriteByte((byte)m_streams[0].ReadByte());
}
fs.Close();
}
谢谢!
答案 0 :(得分:0)
bottomMargin,rightMargin和leftMargin设置为空字符串:
string bottomMargin = "";
tmp = ((double)rptPageSettings.Margins.Bottom) * .01;
bottomMargin = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";
string rightMargin = "";
tmp = ((double)rptPageSettings.Margins.Right) * .01;
rightMargin = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";
string leftMargin = "";
tmp = ((double)rptPageSettings.Margins.Left) * .01;
leftMargin = tmp.ToString("#0.00", System.Globalization.CultureInfo.InvariantCulture) + "in";