从C#中的晶体报告中导出Pdf [英] Pdf export from crystal report in C#
本文介绍了从C#中的晶体报告中导出Pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试创建日期文件夹并将报告保存在同一文件夹中,创建文件夹,但文件不保存在该文件夹中,
请帮助我
我尝试过:
i try to create date wise folder and save report in same folder, folder created, but file not save in that folder,
please help me
What I have tried:
private void jayShahDailyReportsToolStripMenuItem_Click(object sender, EventArgs e)
{
var folderPath = (@"d:/");
var foldername = DateTime.Now.ToString("yyyy-MM-dd");
if (!Directory.Exists(folderPath + foldername))
Directory.CreateDirectory(folderPath + foldername);
var savepath = System.IO.Path.Combine(folderPath, foldername);
// Weaving Sales Pending Contract
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(Application.StartupPath + @"\Reports\Jay Shah\Weaving Sales Pending Contract Register.RPT");
crvContractRegister.ReportSource = cryRpt;
crvContractRegister.Refresh();
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "Weaving Sales Pending Contract Register.pdf");
MessageBox.Show("Exported Successful");
}
推荐答案
这是有问题的:
This is problematic:
var folderPath = (@"d:/");
应该是:
Should be:
var folderPath = (@"d:\");
另外,这个:
Also, this:
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "Weaving Sales Pending Contract Register.pdf");
应为:
should be:
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Application.StartupPath + @"\Weaving Sales Pending Contract Register.pdf");
但是会覆盖或iginal。
此外,在加入路径和文件名时,您应该执行以下操作:
but will override the original.
Also, when joining paths and filenames, you should do the following:
var filename = "Weaving Sales Pending Contract Register.pdf";
var fullFilePathAndName = System.IO.Path.Combine(Application.StartupPath, filename);
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, fullFilePathAndName);
这将确保正确创建路径。
This will ensure that the path is correctly created.
这篇关于从C#中的晶体报告中导出Pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文