简体   繁体   English

如何在不替换以前的.pdf文件的情况下将Crystal报表转换为.pdf?

[英]How to convert crystal report to .pdf without replace the previous .pdf file?

Any ideas how to convert crystal report to .pdf without replace the previous .pdf file? 有什么想法如何在不替换以前的.pdf文件的情况下将Crystal报表转换为.pdf? I did put "Hour,Minute, Second" but it still replace the previous one. 我确实输入了“小时,分钟,秒”,但它仍然替代了前一个。 Thanks. 谢谢。

//String reportDate = dt.Year.ToString() + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0');
String reportPrefix = dt.Year.ToString() + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0') + dt.Hour.ToString().PadLeft(2, '0') + dt.Minute.ToString().PadLeft(2, '0') + dt.Second.ToString().PadLeft(2, '0') + dt.Millisecond.ToString();
String report = Report + "BillingReport-" + reportPrefix + ".pdf";
crRpt.ExportToDisk(ExportFormatType.PortableDocFormat, report);
Console.WriteLine("" + report + " " + DateTime.Now.ToLongTimeString());

You can use a GUID or the Ticks from DateTime.Now. 您可以使用GUID或DateTime.Now的刻度。

Alternatively, you could add an index if the file was previously found: 或者,如果以前找到该文件,则可以添加索引:

        String reportPrefix = Report + "BillingReport-" + dt.Year.ToString() + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0') + dt.Hour.ToString().PadLeft(2, '0') + dt.Minute.ToString().PadLeft(2, '0') + dt.Second.ToString().PadLeft(2, '0') + dt.Millisecond.ToString();
        String report;

        bool fDone = false;
        int wIndex = 0;

        // Cycle looking for the first file that doesn't exist
        do while (!fDone) {
            report = reportPrefix;
            // Include the index once we have checked the base file name
            if (wIndex > 0)
            {
                report += wIndex.ToString();
            }
            report += ".pdf";

            if (System.IO.File.Exists(report))
            {
                // If the file exists, increment the index and keep looking
                wIndex++;
            } else {
                // Otherwise, we are done
                fDone = true;
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM