/// <summary>
/// Save the file. The extension determines the type of file to save.
/// </summary>
/// <param name="FileName">Name of the file to be saved to.</param>
/// <param name="ext">Type of file to save. Should be "pdf", "xml", "html", mht.</param>
private void SaveAs(Report report, string FileName, string type)
{
string ext = type.ToLower();
OneFileStreamGen sg=null;
try
{
if (ext == "tifb")
FileName = FileName.Substring(0, FileName.Length - 1); // get rid of the 'b'
sg = new OneFileStreamGen(FileName, true); // overwrite with this name
switch(ext)
{
case "pdf":
if (this._StampInfo == null)
report.RunRender(sg, OutputPresentationType.PDF);
else
SaveAsPdf(report, sg);
break;
case "xml":
report.RunRender(sg, OutputPresentationType.XML);
break;
case "mht":
report.RunRender(sg, OutputPresentationType.MHTML);
break;
case "html": case "htm":
report.RunRender(sg, OutputPresentationType.HTML);
break;
case "csv":
report.RunRender(sg, OutputPresentationType.CSV);
break;
case "xlsx":
report.RunRender(sg, OutputPresentationType.Excel);
break;
case "rtf":
report.RunRender(sg, OutputPresentationType.RTF);
break;
case "tif": case "tiff":
report.RunRender(sg, OutputPresentationType.TIF);
break;
case "tifb":
report.RunRender(sg, OutputPresentationType.TIFBW);
break;
default:
Console.WriteLine("Unsupported file extension '{0}'. Must be 'pdf', 'xml', 'mht', 'csv', 'xslx', 'rtf', 'tif', 'tifb' or 'html'", type);
returnCode = 8;
break;
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
returnCode = 8;
}
finally
{
if (sg != null)
{
sg.CloseMainStream();
}
}
if (report.ErrorMaxSeverity > 0)
{
// have errors fill out the msgs
Console.WriteLine("{0} has the following runtime errors:", FileName);
foreach (string emsg in report.ErrorItems)
{
Console.WriteLine(emsg); // output message to console
}
report.ErrorReset();
}
return;
}