StiReport打印出空白标签

发布时间 2023-04-20 09:28:08作者: 未风

解决方法:

  

                DataSet dsPrintLotLabelID = new DataSet();
                dsPrintLotLabelID.Tables.Add(dataPrint.Tables[0].Copy());
                //设置数据集名称这句是关键,有时候不设置也可以打印,有时候打印出来空白
                dsPrintBoxLabelID.DataSetName = "SQLDataSet";
                dsPrintBoxLabelID.Tables[0].TableName = "t1";

                StiReport stireport2 = new StiReport();
                stireport2.Load(path + BoxLabelID + ".mrz");
                stireport2.RegData(dsPrintLotLabelID);
                stireport2.Dictionary.Synchronize();
                if (cbIsPrint.Checked)
                {
                    stireport2.Show();
                }
                else
                {
                    stireport2.Print(false, printerSettings);
                }