我动态创建的报告,即,我也没有办法打开一个设计师RDLC并修复它。 我创建一个表,并通过数据集填充它。 获取XML文件,并将其导出为PDF文件。 但是,即使我写的
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>11in</PageWidth>" +
" <PageHeight>8.5.0in</PageHeight>" +
" <MarginTop>0.05in</MarginTop>" +
" <MarginLeft>0.05in</MarginLeft>" +
" <MarginRight>0.05in</MarginRight>" +
" <MarginBottom>0.05in</MarginBottom>" +
" <KeepWithGroup>After</KeepWithGroup>" +
" <RepeatOnNewPage>true</RepeatOnNewPage>" +
" <FixedData>true</FixedData>"+
" <RepeatHeaderOnNewPage>true</RepeatHeaderOnNewPage>" +
"</DeviceInfo>";
try
{
byte[] bytes = reportViewer1.LocalReport.Render(
"PDF", deviceInfo, out mimeType, out encoding, out filenameExtension,
out streamids, out warnings);
using (FileStream fs = new FileStream(filename, FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
return filename;
}
//....
我只看到1页标题帮助解决问题! 谢谢!
private Rdl.HeaderType CreateHeader()
{
Rdl.HeaderType header = new Rdl.HeaderType();
header.Items = new object[]
{
CreateHeaderTableRows(),
true,
};
header.ItemsElementName = new Rdl.ItemsChoiceType20[]
{
Rdl.ItemsChoiceType20.TableRows,
Rdl.ItemsChoiceType20.RepeatOnNewPage,
};
return header;
}
//....
public string ExportReport(string filename)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>11in</PageWidth>" +
" <PageHeight>8.5.0in</PageHeight>" +
" <MarginTop>0.05in</MarginTop>" +
" <MarginLeft>0.05in</MarginLeft>" +
" <MarginRight>0.05in</MarginRight>" +
" <MarginBottom>0.05in</MarginBottom>" +
"</DeviceInfo>";
try
{
byte[] bytes = reportViewer1.LocalReport.Render(
"PDF", deviceInfo, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
using (FileStream fs = new FileStream(filename, FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
return filename;
}
catch (Exception e)
{
Program.WriteLogEx.WriterLogErr(e.Message);
return "";
}
}
文章来源: How to show a title on each page of the report dynamically created reportviewer