很多时候,我们希望表格控件像Excel打印一样,出现页眉页脚。令人惊喜的是,Spread完美的做到了,并能根据我们的需要,自定义设置页眉页脚的显示内容及方式。下面我们就赶紧通过实例来学习吧!
效果截图
参考代码
FarPoint.Win.Spread.PrintInfo printset = new FarPoint.Win.Spread.PrintInfo(); printset.Centering = FarPoint.Win.Spread.Centering.Horizontal; printset.BestFitCols = true; printset.BestFitRows = true; printset.ShowBorder = false; printset.ShowColor = true; printset.ShowGrid = true; printset.ShowShadows = false; printset.ZoomFactor = 2; printset.ShowColumnHeader = FarPoint.Win.Spread.PrintHeader.Hide; printset.ShowRowHeader = FarPoint.Win.Spread.PrintHeader.Hide; printset.Colors = new Color[] { Color.Red, Color.Blue }; printset.Header = "/fn\"Book Antiqua\" /c/fz\"20\" 打印销售情况表./n "; printset.Footer = "/r/cl\"4\"第 /p 页 总共 /pc 页"; printset.Preview = true; fpSpread1.Sheets[0].PrintInfo = printset; fpSpread1.PrintSheet(0); 复制代码
环境:VS 2010 && Spread for WinForm 6.0