crReportDocument.SetDataSource(Ds);
ExportOptions crExportOptions; //导出选项
DiskFileDestinationOptions crDiskFileDestinationOptions;
String Fname; //导出完整名称
//String FileName = "";
String FileName = "my.pdf";
String _SystemPath =Request.PhysicalApplicationPath;
if(!System.IO.Directory.Exists(_SystemPath))
System.IO.Directory.CreateDirectory(_SystemPath);
Fname = _SystemPath + FileName; //导出完整名称
crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crDiskFileDestinationOptions.DiskFileName = Fname; crExportOptions = crReportDocument.ExportOptions;
crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
crReportDocument.Export();
ExportOptions crExportOptions; //导出选项
DiskFileDestinationOptions crDiskFileDestinationOptions;
String Fname; //导出完整名称
//String FileName = "";
String FileName = "my.pdf";
String _SystemPath =Request.PhysicalApplicationPath;
if(!System.IO.Directory.Exists(_SystemPath))
System.IO.Directory.CreateDirectory(_SystemPath);
Fname = _SystemPath + FileName; //导出完整名称
crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crDiskFileDestinationOptions.DiskFileName = Fname; crExportOptions = crReportDocument.ExportOptions;
crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
crReportDocument.Export();
web打印要水晶报表10才能办到,其他的只能是在服务器端打印。
// 打印和导出水晶报表
//========================================================================================
/// <summary>
/// 打印一份crystal Report
/// </summary>
/// <param name="reportPath">报表路径</param>
/// <param name="reportSet">报表数据源的DataSet</param>
public void printReport(string reportPath,string PrinterPath,string passWrd)
{
ReportDocument crystalReportObject=new ReportDocument();
// crystalReportObject.
crystalReportObject.Load(reportPath);//"e://temp//crt.rpt"
// crystalReportObject.s
//crystalReportObject.SetDataSource(reportSet);
crystalReportObject.Refresh();
this.SetConnectionInfo(crystalReportObject,passWrd);
//crystalReportObject.PrintOptions.PrinterName =@"\\office1\HP1000";
crystalReportObject.PrintOptions.PrinterName =PrinterPath ;
try
{
crystalReportObject.PrintToPrinter(1,false, 0, 0);
}
catch
{
;
}
finally
{
crystalReportObject.Close();
}
// CrystalDecisions.Web.CrystalReportViewer myView=new CrystalDecisions.Web.CrystalReportViewer();
// myView.LogOnInfo
}
public void printReport(string PrinterPath,ReportDocument crystalReportObject)
{ crystalReportObject.PrintOptions.PrinterName =PrinterPath ;
try
{
crystalReportObject.PrintToPrinter(1,false, 0, 0);
}
catch
{
;
}
finally
{
crystalReportObject.Close();
}
// CrystalDecisions.Web.CrystalReportViewer myView=new CrystalDecisions.Web.CrystalReportViewer();
// myView.LogOnInfo
} // public ReportDocument InitReportDoc(DataSet myDs,string reportPath,string passWrd)
// {
// ReportDocument oRD = new ReportDocument();
// oRD.Load(reportPath);
// oRD.SetDataSource(myDs);
// oRD.Refresh();
// this.SetConnectionInfo(oRD,passWrd);
// return oRD;
//
// } public void ExportCrystalReport(string targetFileName,string reportPath,string docFormat,string passWrd)
{
ReportDocument oRD = new ReportDocument();
ExportOptions oExO ;
DiskFileDestinationOptions oExDo=new DiskFileDestinationOptions();
oRD.Load(reportPath);
//oRD.SetDataSource(myDS);
oRD.Refresh();
this.SetConnectionInfo(oRD,passWrd); oExDo.DiskFileName = targetFileName ;
oExO = oRD.ExportOptions;
oExO.ExportDestinationType = ExportDestinationType.DiskFile;
switch (docFormat)
{
case "pdf":
oExO.ExportFormatType = ExportFormatType.PortableDocFormat;
break;
case "doc":
oExO.ExportFormatType = ExportFormatType.WordForWindows;
break;
case "xls":
oExO.ExportFormatType = ExportFormatType.Excel;
break;
case "htm":
oExO.ExportFormatType = ExportFormatType.HTML40;
break;
case "html":
oExO.ExportFormatType = ExportFormatType.HTML40;
break;
default:oExO.ExportFormatType = ExportFormatType.Excel;break;
}
oExO.DestinationOptions = oExDo;
oRD.Export();
oRD.Close();
}
public void ExportCrystalReport(ReportDocument oRD,string docFormat,string targetFileName)
{
//ReportDocument oRD = new ReportDocument();
ExportOptions oExO ;
DiskFileDestinationOptions oExDo=new DiskFileDestinationOptions();
// oRD.Load(reportPath);
// oRD.SetDataSource(myDS);
//oRD.Refresh();
//this.SetConnectionInfo(oRD,passWrd); oExDo.DiskFileName = targetFileName ;
oExO = oRD.ExportOptions;
oExO.ExportDestinationType = ExportDestinationType.DiskFile;
switch (docFormat)
{
case "pdf":
oExO.ExportFormatType = ExportFormatType.PortableDocFormat;
break;
case "doc":
oExO.ExportFormatType = ExportFormatType.WordForWindows;
break;
case "xls":
oExO.ExportFormatType = ExportFormatType.Excel;
break;
case "htm":
oExO.ExportFormatType = ExportFormatType.HTML40;
break;
case "html":
oExO.ExportFormatType = ExportFormatType.HTML40;
break;
default:oExO.ExportFormatType = ExportFormatType.Excel;break;
}
oExO.DestinationOptions = oExDo;
oRD.Export();
oRD.Close();
}
获取本地打印机、打印到本地!
如何实现将导出文件保存到本地!!!
导出文件保存到服务器可以实现,
如何把文件保存到本地??!上面的方法只能将文件保存到服务器!!!!
不能保存到本地!!!
获取本地打印机、打印到本地!
如何实现将导出文件保存到本地!!!
导出文件保存到服务器可以实现,
如何把文件保存到本地??!上面的方法只能将文件保存到服务器!!!!
不能保存到本地!!!
获取本地打印机、打印到本地!
那可以通过activex来实现,
水晶报表10提供了客户端打印的功能。如何实现将导出文件保存到本地!!!
导出文件保存到服务器可以实现,
如何把文件保存到本地??!
可以先保存在服务器上,然后提供下载
请问,若我添加Button按扭
private void Button1_Click(object sender, System.EventArgs e)
{
}
那该怎样调用
ExportCrystalReport(string reportPath,string docFormat,string targetFileName)
方法呢?在线等呀