日期:2014-05-18 浏览次数:21317 次
/// <summary> /// 通用的打印表格方法 /// </summary> /// <param name="fpview"></param> /// <param name="fp"></param> /// <param name="index"></param> public static void CommonPrint(FarPoint.Win.Spread.SheetView fpview,FpSpread fp,int index) { try { if(fpview.RowCount==0) return; FarPoint.Win.Spread.PrintInfo pi = new FarPoint.Win.Spread.PrintInfo(); DialogResult result=MessageBox.Show("是否要横向打印?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question); FarPoint.Win.Spread.StyleInfo style = new FarPoint.Win.Spread.StyleInfo(); style.Border=new FarPoint.Win.LineBorder(Color.Black,1); style.BackColor=Color.White; fpview.ColumnHeader.DefaultStyle=style; fpview.RowHeader.DefaultStyle=style; if(result==DialogResult.Yes) { pi.Orientation =FarPoint.Win.Spread.PrintOrientation.Landscape; } else pi.Orientation =FarPoint.Win.Spread.PrintOrientation.Portrait; FarPoint.Win.Spread.PrintMargin pm = new FarPoint.Win.Spread.PrintMargin(); pm.Left = 100; pm.Right = 60; pm.Top = 100; pm.Bottom = 20; pi.FirstPageNumber = 1; pi.Footer = "当前第 /p 页/n共 /pc 页"; pi.Margin = pm; pi.PageStart = 1; pi.Preview = true; pi.ShowBorder = true; pi.ShowColor = false; pi.ShowColumnHeaders = true; pi.ShowGrid = true; pi.ShowPrintDialog = true; pi.ShowRowHeaders = true; pi.ShowShadows = true; pi.ZoomFactor = 1; pi.ShowPrintDialog=true; FarPoint.Win.Spread.PrintInfo clone = new FarPoint.Win.Spread.PrintInfo(pi); fpview.PrintInfo = clone; fp.PrintSheet(index); } catch { MessageBox.Show("打印发生错误,请确认是否有连接好打印机"); } }