How to show a title on each page of the report dynamically created reportviewer
Asked Answered
T

1

3

I create the report dynamically, i e, I have no way to open a designer RDLC and fix it. I create a table and fill it through the dataset. Getting XML file and export it to PDF file. But even if I write

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;
 }
 //....

I see the title only on 1 page Help solve the problem! Thanks!

Thermal answered 3/6, 2012 at 9:49 Comment(13)
I'm still waiting for an answer ... Please help me!Thermal
Thanks, RoboLover! I am waiting for an answer...Thermal
Np Irena, try to keep your question active by editing and adding new things you found out by your researches, good luck.I hope you can find a solution.Predict
I added a new node in the rdlc soThermal
//Add new node XmlNode newNode = xDocument.CreateNode("element", "RepeatOnNewPage", "schemas.microsoft.com/sqlserver/reporting/2005/01/…); newNode.InnerText = "true"; xDocument.ChildNodes[1].ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[1].ChildNodes[0].ChildNodes[0].AppendChild(newNode); But now I get an error "An error occurred during local report processing"Thermal
Add this part to your question Irena.Predict
hey Irena check this dynamic table rdlcPredict
Issue has been resolved! Anyone who read my question - thank you!Thermal
Well, Irena consider answering your own question with the solution you had, for those who may encounter the same problem.Predict
ok 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; }Thermal
<!-- language: c# --> (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>";Thermal
try { byte[] bytes = reportViewer1.LocalReport.Render( "PDF", deviceInfo, out mimeType, out encoding, out filenameExtension, //horizontal page out streamids, out warnings); using (FileStream fs = new FileStream(filename, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); fs.Close(); } return filename; }Thermal
Can you add those as anwer please, Irena? Not comments.Predict
T
2
    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 "";
        }
    }
Thermal answered 12/6, 2012 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.