我最近要用C#编写POS机打印小票功能,可是不知道该如何写,还有就是小票打印完之后是POS机的自动裁纸,还是我的C#程序里自己编写裁纸功能啊。困惑啊,没有思路...能给个实例嘛。

解决方案 »

  1.   

    应该有对应的POST机,API函数,你可以问厂商要一下,如果是通用的,就没必要了。裁纸是自带的,因为他打印的区域是固定的
      

  2.   

    我都是在EXCEL里面建好模板,用C#把数据添加到模板里,直接打印
      

  3.   

    那我在用C#写程序的时候是不是就不用考虑写裁纸的代码了,只写打印的就可以???那如果是一卷纸如果没有裁纸代码,那POS自己会自动识别打印完自动裁纸吗?
      

  4.   

    你先创建一个EXCEL表格,设置好打印区域还有打印机打印的纸张大小。定义了打印纸张后打印,他就会自动停在你打印的位置...建好模板后,在C#中引用EXCEL就像这样
    Microsoft.Office.Interop.Excel.Application excel = null;
                Microsoft.Office.Interop.Excel.Workbook xBook = null;
                Microsoft.Office.Interop.Excel._Worksheet wks = null;
                string dataFilePath = System.Environment.CurrentDirectory + @"\Model.xls";
                try
                {
                    excel = new Microsoft.Office.Interop.Excel.Application();
                    excel.Visible = false;
                    excel.DisplayAlerts = false;
                    //excel.ActivePrinter = "Citizen CLP-521Z";
                    xBook = excel.Application.Workbooks._Open(dataFilePath, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);                if (xBook == null)
                    {
                        xBook = excel.Application.Workbooks.Add(true);
                    }                wks = (Microsoft.Office.Interop.Excel._Worksheet)xBook.ActiveSheet; //取得当前worksheet 
                    wks.Cells[2, 2] = "'" + sScheduleDate;//.Remove(10);
                    wks.Cells[3, 2] = "'" + sPatientID;
                    wks.Cells[4, 2] = "'" + sName;
                    wks.Cells[5, 2] = "'" + sSex;
                    wks.Cells[5, 4] = "'" + nAge;
                    wks.Cells[6, 2] = "'" + sCheckType;
                    object omo = new object();
                    //打印预览
                    //wks.PrintPreview(omo);
                    //不预览打印
                    wks.PrintOut(1, 1, 1, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    //wks.PrintOut(omo, omo, omo, omo, omo, omo, omo, omo);
                    //xBook.Saved = true;
                    xBook.Save();
                    excel.Application.Workbooks.Close();
                    excel.Application.Quit();
                    excel.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
      

  5.   

    http://download.csdn.net/detail/mjp1234airen4385/1664218
    以前使用pos打印机写一个类。
      

  6.   

    工具箱中拉一个printDocument直接在printDocument1_PrintPage写打印内容 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
              //你要做的事
            }
    在接Button事件中
    printDocument1.print()
      

  7.   

    http://apps.hi.baidu.com/share/detail/31171999
    http://gbigone.blog.163.com/blog/static/350015292009101831349542/