求助,循环中调用打印动作不起作用。
本帖最后由 rongqiye 于 2023-7-6 14:54 编辑代码的想法是,每个客户的资料格式化好后,调用打印,然后清除再打印第二个客户的资料。但在循环中调用打印动作,实际只打印最后一次的页面。
代码如下:
……
For Each vRow As DataRow In vTable.Rows
vSQL = String.Format("SELECT T.CUS_NAME,T.ITEM_NO,T.WIDTH,T.LENGTH,T.TOTAL,ROUND((TO_NUMBER(T.WIDTH)/12)*TO_NUMBER(T.LENGTH)*T.TOTAL*2,2) AS FT,A.ADDRESS,A.TEL FROM ETERNALM.TEMGDEL01 T,ETERNALM.CUSTOMER_M A WHERE T.DEL_DATE='{0}' AND T.CUS_NO='{1}' AND T.CUS_NO=A.CUS_NO ORDER BY T.ITEM_NO,TO_NUMBER(T.WIDTH),TO_NUMBER(T.LENGTH),T.TOTAL",
Me.txt_DEL_DATE10.Text.Trim, vRow.Item(0).ToString)
vDT = Nothing
vDT = objSCH.ANYTABLE_BYANY(vSQL)
If vDT.Rows.Count > 0 Then
getJJCHD(vDT) ‘这个函数作用是把数据格式化写入页面。
End If
PrintAllJJCHD()‘这个设置打印。
Next
……
Private Sub PrintAllJJCHD()
Try
'If fSpread8.Sheets.Count = 0 Then
' MsgBox("請先導出資料再列印")
' Exit Sub
'End If
Dim printset As New FarPoint.Win.Spread.PrintInfo()
Dim printmar As New FarPoint.Win.Spread.PrintMargin
printmar.Left = 15
printmar.Right = 10
printmar.Top = 20
printmar.Bottom = 40
printset.FirstPageNumber = 1
printset.Margin = printmar
printset.Opacity = 60
printset.Orientation = FarPoint.Win.Spread.PrintOrientation.Portrait
printset.ShowBorder = False
printset.ShowColor = True
printset.ShowColumnHeader = FarPoint.Win.Spread.PrintHeader.Hide
printset.ShowRowHeader = FarPoint.Win.Spread.PrintHeader.Hide
printset.ShowGrid = False
printset.ShowShadows = False
printset.PaperSize = New System.Drawing.Printing.PaperSize("Letter", 950, 550)
fSpread8.Sheets(0).PrintInfo = printset
printset.ShowPrintDialog = True
fSpread8.PrintSheet(0)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
那句SQL可以忽略,作用就是取得数据。 你可以尝试一下单线程打印看看
fpSpread1.PrintSheet(0, false); Richard.Ma 发表于 2023-7-6 18:56
你可以尝试一下单线程打印看看
fpSpread1.PrintSheet(0, false);
比较老的版本是不是没有这个参数,我昨天好像尝试加入这个参数提示说不行。现在不在电脑旁边 明天再试一下。 早期的版本我们也没法协助验证了,
页:
[1]