0

I use the Microsoft.WebForms.ReportViewer version 10.0.0 to render reports the output rendered is a word document .

The rdlc file is set with the PaperSize Orientation with an orientation set to LandScape and a PaperSize to A4

  1. When the output is rendered in a pdf format the changes gets reflected where as when the same output is got in a DOC no changes are shown when the word document is opened . Infact it opens with a custom size ?

Is there any way i could get this to working for an Word document.

user581157
  • 1,327
  • 4
  • 26
  • 64

2 Answers2

1

I was able to fix the issue by refering to this article

<DeviceInfo><FixedPageWidth>True</FixedPageWidth><AutoFit>True</AutoFit></DeviceInfo>

Word Device Information Settings

user581157
  • 1,327
  • 4
  • 26
  • 64
0

I had to deal with this thing too. I disabled the native export menu from the toolbar and added a new button. The code I used to export the Word document with Specific Page Size is this:

Microsoft.Reporting.WinForms.Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;

string deviceInfo =
"<DeviceInfo>" +
"  <OutputFormat>Word</OutputFormat>" +
"  <PageWidth>8.5in</PageWidth>" +
"  <PageHeight>11in</PageHeight>" +
"  <MarginTop>0.5in</MarginTop>" +
"  <MarginLeft>0.5in</MarginLeft>" +
"  <MarginRight>0.5in</MarginRight>" +
"  <MarginBottom>0.5in</MarginBottom>" +
"  <FixedPageWidth>True</FixedPageWidth>" +
"  <AutoFit>True</AutoFit>" +
"</DeviceInfo>";

byte[] bytes = reportViewer1.LocalReport.Render(
    "WORDOPENXML", deviceInfo, out mimeType, out encoding, out extension, out streamIds, out warnings);

using (FileStream fs = new FileStream("myreport.docx", FileMode.Create))
{
    fs.Write(bytes, 0, bytes.Length);
}

Replace the "WORDOPENXML" with "Word" for .doc file export, as well as the filename "myreport.docx" to "myreport.doc"

user8581607
  • 169
  • 1
  • 5