One of my project i had a requirement like convert SSRS report to Document format. It is very simple to convert ssrs report to Doc using the following code.
The first method (ConvertSSRS()) is reading the SSRS report through rendering time. It will be convert the report to Byte formate and this byte array is passed to next method to write Word format.
It will be very easy to convert another format like excel,Csv by changeing the Format.
/// <summary>
The first method (ConvertSSRS()) is reading the SSRS report through rendering time. It will be convert the report to Byte formate and this byte array is passed to next method to write Word format.
It will be very easy to convert another format like excel,Csv by changeing the Format.
///
<summary>
/// Convert to SSRS to Document
/// </summary>
public void ConvertSSRS()
{
Microsoft.Reporting.WinForms.Warning[] warnings;
string[]
streamids;
string
mimeType;
string
encoding;
string
extension;
byte[]
bytes = this.reportViewer1.LocalReport.Render(
"DOC", null,
out mimeType, out
encoding,
out extension,
out streamids, out
warnings);
WriteToSSRS(bytes);
}
/// Write byte to File
/// </summary>
/// <param
name="mydata"></param>
public void WriteToSSRS(byte[]
mydata)
{
FileStream
fs = new FileStream(@"c:\transcript.doc",
FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
No comments:
Post a Comment