szpzr
发表于 2017-2-23 13:35:25
本帖最后由 szpzr 于 2017-2-23 17:04 编辑
if (CheckBoxSaveToPrint.Checked == true)
{
//int J = FpSpread1.ActiveSheetView.RowCount;
ColorCard_Ar[] Rpt1 = new ColorCard_Ar{null,null};
for (int I = 0; I < 2; I++)
{
string CardNo = FpSpread1.ActiveSheetView.Cells.Text;
if (CardNo.Trim() != "")
{
//链接数据源,并取得记录集。。。
if (Dr.Read())
{
ContractNo = Dr["ContractNo"].ToString();
if (Convert.ToBoolean(Dr["BlankColor"]) == true)
{
Rpt1.Parameters["CardType"].Value = "上色卡";
}
else
{
Rpt1.Parameters["CardType"].Value = "炼白卡";
}
Dr.Close();
Dr.Dispose();
Cmd.Dispose();
var Rpt = Rpt1;
Rpt.Run();
//var sectionDocument = Rpt.Document;
//sectionDocument.Print(true, true, false);
WebViewer1.Report = Rpt;
WebViewer1.FlashViewerOptions.PrintOptions.StartPrint = true;
WebViewer1.Visible = true;
WebViewer1.Width = 0;
WebViewer1.Height = 0;
}
SqlCon.Close();
SqlCon.Dispose();
}
执行时出现如图:
szpzr
发表于 2017-2-23 13:36:30
Lenka.Guo ,能指教一下吗?
szpzr
发表于 2017-2-23 13:40:24
下列问题?
Lenka.Guo
发表于 2017-2-23 14:20:00
1. 抛参数异常
》》 应该是未找到报表参数对象,建议您把数组改成List 可能能更好的实现您的需求: List<SectionReport1> rptlist = new List<SectionReport1>();
for (int i = 0; i < 3; i++)
{
SectionReport1 sr = new SectionReport1();
//绑定上数据源
//...
//...
sr.Parameters.Value = "123";
rptlist.Add(sr);
}
//打印List
for (int j = 0; j < 3; j++)
{
rptlist.Document.Print(true, false, false);
}
2. 语句ColorCard_Ar[] Rpt1 = new ColorCard_Ar{null,null};中2可以用变量代替吗?
>> 这个应该是.Net语法规范的问题,您可以查下MSDN 数组初始化是否支持变量,或者使用List 可能会更好的解决问题
3. 找不到 print方法,需要给项目添加引用文件: GrapeCity.ActiveReports.Viewer.Win.v10 .dll
szpzr
发表于 2017-2-23 15:15:45
3. 找不到 print方法,需要给项目添加引用文件: GrapeCity.ActiveReports.Viewer.Win.v10 .dll
那需要安装ActiveReports,会有冲突吗?
szpzr
发表于 2017-2-23 15:16:45
打印时使用了下列语句,只能打印最后一张报表
for (int I = 0; I < J; I++)
{
//Rptlist.Document.Print(true, false, false);
Rptlist.Run();
WebViewer1.Report = Rptlist;
WebViewer1.FlashViewerOptions.PrintOptions.StartPrint = true;
WebViewer1.Visible = true;
WebViewer1.Width = 0;
WebViewer1.Height = 0;
}
Lenka.Guo
发表于 2017-2-23 16:00:45
szpzr 发表于 2017-2-23 15:15
3. 找不到 print方法,需要给项目添加引用文件: GrapeCity.ActiveReports.Viewer.Win.v10 .dll
那需要安 ...
3. 找不到 print方法,需要给项目添加引用文件: GrapeCity.ActiveReports.Viewer.Win.v10 .dll
那需要安装ActiveReports,会有冲突吗?
》》 这不需要安装 AR, 这个只是AR 自带的一个 dll文件, 把这个添加引用到 项目中就可以了。
这个dll 在安装目录下: C:\Program Files (x86)\Common Files\GrapeCity\ActiveReports 11
szpzr
发表于 2017-2-23 16:11:39
项目添加了引用:GrapeCity.ActiveReports.Viewer.Win.v11,还是不行?
Lenka.Guo
发表于 2017-2-23 16:31:51
szpzr 发表于 2017-2-23 16:11
项目添加了引用:GrapeCity.ActiveReports.Viewer.Win.v11,还是不行?
在调用Print这个文件中, 把包加进来 UsingGrapeCity.ActiveReports;
szpzr
发表于 2017-2-23 16:52:03
?