簡體   English   中英

如何在不替換以前的.pdf文件的情況下將Crystal報表轉換為.pdf?

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

有什么想法如何在不替換以前的.pdf文件的情況下將Crystal報表轉換為.pdf? 我確實輸入了“小時,分鍾,秒”,但它仍然替代了前一個。 謝謝。

//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());

您可以使用GUID或DateTime.Now的刻度。

或者,如果以前找到該文件,則可以添加索引:

        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