0

This code use to work in VB , can't pinpoint what i'm missing here.

System.IO.MemoryStream oStream = new System.IO.MemoryStream();

if (rptName == "rpt_BankFormatExCopy.rpt" | rptName == "GIS_reportExFormat.rpt" | rptName == "GPFDeductionRepExFormat.rpt")
    oStream = rptObject.ExportToStream(CrystalDecisions.Shared.ExportFormatType.ExcelRecord);
else
    oStream = rptObject.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
Lolly Molly
  • 27
  • 1
  • 8

1 Answers1

2

It looks like rptObject is a Stream

You can just use CopyTo in that case

var oStream = new MemoryStream();
Stream stream = null;

if (rptName == "rpt_BankFormatExCopy.rpt" | rptName == "GIS_reportExFormat.rpt" | rptName == "GPFDeductionRepExFormat.rpt")
    stream = rptObject.ExportToStream(CrystalDecisions.Shared.ExportFormatType.ExcelRecord);
else
    stream = rptObject.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);

stream.CopyTo(oStream);
TheGeneral
  • 79,002
  • 9
  • 103
  • 141