打印字体和列宽默认就是我们看到spread中的字体和列宽,除此之外,字体大小和列宽可能受到一些打印设置的影响,比如设置BestFitCols或者SmartPrint,当单元格中文字超长时不同的设置,会显示不同的字体大小和列宽,代码如下:
- // 输入您想用于优化打印的类型;作为示例,这里使用了所有的类型
- // 定义打印优化设置
- FarPoint.Win.Spread.PrintInfo printset = new FarPoint.Win.Spread.PrintInfo();
- FarPoint.Win.Spread.SmartPrintRulesCollection prules = new FarPoint.Win.Spread.SmartPrintRulesCollection();
- // ... 使用自动最佳适应列和最佳适应行
- printset.BestFitCols = true;
- printset.BestFitRows = true;
- // ... 检查打印页尺寸
- printset.SmartPrintPagesTall = 1;
- printset.SmartPrintPagesWide = 1;
- // ... 使用定义的打印规则
- prules.Add(new FarPoint.Win.Spread.BestFitColumnRule(FarPoint.Win.Spread.ResetOption.None));
- prules.Add(new FarPoint.Win.Spread.LandscapeRule(FarPoint.Win.Spread.ResetOption.Current));
- prules.Add(new FarPoint.Win.Spread.ScaleRule(FarPoint.Win.Spread.ResetOption.None, 1, 0.6, 0.1));
- printset.SmartPrintRules = prules;
- printset.UseSmartPrint = true;
- // 把定义好的打印设置赋给表单,并打印该表单
- fpSpread1.Sheets[0].PrintInfo = printset;
- fpSpread1.PrintSheet(0);
复制代码 |