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);
Ruby
  • 25
  • 6

1 Answers1

1

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
  • 75,627
  • 8
  • 79
  • 119