xml - 如何在动态创建的报告查看器的每个页面上显示标题

标签 xml reportviewer rdlc dynamic-rdlc-generation

我动态创建报告,即,我无法打开设计器 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;
 }
 //....

我只在一页上看到标题 帮助解决问题!谢谢!

最佳答案

    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 "";
        }
    }

关于xml - 如何在动态创建的报告查看器的每个页面上显示标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10869315/

相关文章:

c# - 如何向 XDocument 添加多个命名空间声明?

java - 在 Recycler View 中展开/折叠卡片有时会导致空白和绘图错误

java - 当架构具有 elementFormDefault ="unqualified"时,为什么我无法在 xml 实例中使用默认命名空间?

javascript - 将 XML 转换为 Json。并获取特定数据(Javascript)

c# - 在服务器端以编程方式更改报表的 SSRS 数据源

winforms - WinForms 的 ReportViewer (.rdlc) 灯光设计器

c# - 如何加载数据表作为 ReportDataSource?

c# - 在 ASP.NET Core Web API 中创建 RDLC 报告

c# - 如何在 rdlc 中的表标题顶部而不是左侧显示按列分组

reporting-services - 多列 RDLC 报告,数据从左到右而不是从上到下流动