c#Crystal Report打印 [英] c# Crystal Report Print

查看:104
本文介绍了c#Crystal Report打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想打印一份账单清单。打印所有不是问题的账单。当我打印账单时,在两张账单之间有很多空间空置并且浪费。没有空间是细节,页面页脚和报告页脚然后页面也会流失。我想要没有固定大小的页面,无论帐单大小是什么,下一个帐单应该只在那之后打印。我的打印机是DMP(epson-EX 300)。和纸卷在一起。没有单张纸。



注意:以上情况只是一个例子。这不是任何项目或任务。只是为了知识,我问它。在练习的时候,我试着面对这个问题。



请帮助我。



我的代码是



第1部分:

Hi,

I want to print a list of bill. is printing all the bill that is not the problem. when I am printing the bill, in between two bill a lots of space is vacant and go wastage.there is no space is detail, page footer and report footer then also page is going wastage. I want no fixed size for pages, whatever the bill size is there, the next bill should print after that only. my printer is a DMP(epson-EX 300). and paper are in a roll. no single paper is there.

note: above scenario is just an example. This is not any project or assignment. just for knowledge i am asking it.At the time of practice i tried and face this problem.

Please help me.

my code is

part 1:

for (int i = 0; i < listBox1.Items.Count; i++)
            {
                str = listBox1.Items[i].ToString();
                BillReportPrint br = new BillReportPrint();
                br.textBox1.Text = str;
                br.MdiParent = this.MdiParent;
            }





第2部分:



part 2:

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|Store.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=true;";
            con.Open();
            SqlDataAdapter da3 = new SqlDataAdapter("select * from finalbill where billno='" + textBox1.Text + "' order by slno", con);
            DataSet ds3 = new DataSet();
            da3.Fill(ds3, "finalbill");

            //--
            SqlDataAdapter da4 = new SqlDataAdapter("select  vat as vat,amount,vatAmount from finalbill where billno='" + textBox1.Text + "' group by vat,Amount,vatAmount ", con);
            DataSet ds4 = new DataSet();
            da4.Fill(ds4, "finalbill");
            //--
            BillPrintReport abc = new BillPrintReport();
            
            abc.Subreports[0].SetDataSource(ds4);
            abc.SetDataSource(ds3.Tables[0]);
            crystalReportViewer1.ReportSource = abc;
            ReportDocument rd = (ReportDocument)crystalReportViewer1.ReportSource;
            rd.PrintToPrinter(1, false, 0, 0);
           
            crystalReportViewer1.Refresh();
            this.Close();
        }

推荐答案

据我所知,水晶报告没有其他选项。我遇到了类似的问题,搜索过互联网,但没有得到我想要的。我后来切换到DOS打印。我会建议你也这样做。
There is no other option with crystal reports as far as i know.I encountered a similar problem,searched the internet, but did not get what i wanted.I later switched to dos printing.I would advise you to do the same.


水晶报告将推出对应页面的页面在打印机设置中设置的尺寸,如果您想减少纸张的浪费,请将较小尺寸的页面设置为打印机设置,如果无法切换到Dos打印,您可以在其中将帐单内容写入文本文档并发送在打印机中打印的文档。
The crystal report will push out the page corresponding to the page size set in Printer setup,if you want to reduce wastage of paper,set a smaller sized page to the printer setup,if that is not possible switch to Dos Printing in which you can write the contents of the bill to a text document and send the document to print in a printer.


DOS打印是指将打印内容与打印机理解的一些命令一起写入文本文档,下面给出了一些命令。例如,

DOS Printing refers to writing the contents of the print to a text document along with some of the commands that the printer understands,some are given below.For example,
StreamWriter objStream;
objStream = File.CreateText("\\Bill.txt");
objStream.WriteLine(Convert.ToChar(14)+"Heading of Bill in Double Width"+Convert.ToChar(18));
String strCmd = Environment.GetEnvironmentVariable("COMSPEC");
                string strPrinterName = ">prn";              
                Process.Start(strCmd, "/C type \\Bill.txt > " +
                strPrinterName);



以下是一些不言自明的命令:


The following are some of the commands that are self explanatory:

prnALIGHN_LEFT = Chr(27) & Chr(97) & Chr(0)
prnALIGHN_CENTER = Chr(27) & Chr(97) & Chr(1)
prnALIGHN_RIGHT = Chr(27) & Chr(97) & Chr(2)
prnALIGHN_JUSTIFIED = Chr(27) & Chr(97) & Chr(3)
prnCONDENSED_MODE = Chr(15)
prnCONDENSED_MODE_CANCEL = Chr(20)
prnDOUBLE_WIDTH = Chr(14)
prnDOUBLE_WIDTH_CANCEL = Chr(18)
prnDOUBLE_WIDTH_CONDENSED_MODE = Chr(15) & Chr(14)
prnDOUBLE_WIDTH_CANCEL_SAME_LINE = Chr(20)
prnMODE_GRAPHICS = Chr(27) & "t" & "1"
prnFONT_DRAFT = Chr(18)
prnDOUBLE_STRIKE_MODE = Chr(27) & Chr(71)
prnDOUBLE_STRIKE_MODE_CANCEL = Chr(27) & Chr(72)
prn12CPI = Chr(27) & Chr(77)
prn10CPI = Chr(27) & Chr(80)
prnPAGE_LENGTH = Chr(27) & Chr(67)
prnPAGE_EJECT = Chr(12)


这篇关于c#Crystal Report打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆