2020年2月26日 星期三

Crystal Report由指定印表機直接列印

Crystal Report由指定印表機直接列印

將Crystal Report報表直接由指定印表機輸出
事前:引用Crystal Report DLL(Visual Studio 2010 後沒有內建Crystal Report,需自行到SAP網站下載)
using CrystalDecisions.CrystalReports.Engine;

Step1:顯示Print Dialog讓User挑選印表機
PrinterSettings printerSettings = new PrinterSettings();
PrintDialog printDialog = new PrintDialog();
printDialog.PrinterSettings = printerSettings;
printDialog.AllowPrintToFile = false;
printDialog.AllowSomePages = true;             
printDialog.UseEXDialog = true;

Step2:指定Crystal Report輸出印表機
DataTable DT = new DataTable();//資料來源
ReportDocument rpDoc = new ReportDocument();
Rec.Load(string.Concat(System.Environment.CurrentDirectory, @"\RPT_FORM\檔名.rpt"));
Rec.SetDataSource(DT);
rpDoc.PrintOptions.PrinterName = printerSettings.PrinterName;
rpDoc.PrintToPrinter(printerSettings.Copies, false, 0, 0);

※ReportDocument.PrintToPrinter 方法※
public virtual void PrintToPrinter (int nCopies , bool collated , int startPageN , int endPageN );
參數:
nCopies       //指出列印份數。
collated        //指出是否自動分頁。
startPageN  //指出要列印的第一頁。參數設定為 0 即可列印所有頁面
endPageN   //指出要列印的最後一頁。參數設定為 0 即可列印所有頁面

3 則留言:

  1. According to Stanford Medical, It is indeed the SINGLE reason this country's women get to live 10 years longer and weigh 42 pounds less than we do.

    (And actually, it is not related to genetics or some secret diet and absolutely EVERYTHING related to "how" they are eating.)

    P.S, I said "HOW", and not "what"...

    Tap this link to reveal if this quick test can help you discover your true weight loss potential

    回覆刪除
  2. Do you realize there is a 12 word phrase you can speak to your man... that will trigger intense feelings of love and impulsive appeal for you deep within his chest?

    That's because hidden in these 12 words is a "secret signal" that fuels a man's instinct to love, admire and care for you with all his heart...

    ===> 12 Words Will Trigger A Man's Love Impulse

    This instinct is so built-in to a man's brain that it will drive him to work better than ever before to do his best at looking after your relationship.

    In fact, triggering this all-powerful instinct is so mandatory to having the best ever relationship with your man that the second you send your man a "Secret Signal"...

    ...You will immediately find him expose his mind and soul to you in a way he never expressed before and he will perceive you as the only woman in the world who has ever truly fascinated him.

    回覆刪除
  3. In this manner my friend Wesley Virgin's report starts in this SHOCKING and controversial VIDEO.

    As a matter of fact, Wesley was in the army-and soon after leaving-he unveiled hidden, "self mind control" tactics that the government and others used to get everything they want.

    THESE are the same methods many celebrities (notably those who "come out of nowhere") and the greatest business people used to become wealthy and famous.

    You've heard that you utilize only 10% of your brain.

    That's mostly because the majority of your brain's power is UNCONSCIOUS.

    Maybe that conversation has even taken place IN YOUR very own head... as it did in my good friend Wesley Virgin's head about seven years ago, while driving a non-registered, trash bucket of a car with a suspended driver's license and in his pocket.

    "I'm absolutely frustrated with living paycheck to paycheck! When will I get my big break?"

    You've taken part in those types of thoughts, isn't it so?

    Your own success story is waiting to start. All you need is to believe in YOURSELF.

    UNLOCK YOUR SECRET BRAINPOWER

    回覆刪除