使用EPPLUS导出excel时如何通过代码进行打印设置 [英] How to do print setting through code while exporting excel using EPPLUS

查看:694
本文介绍了使用EPPLUS导出excel时如何通过代码进行打印设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用EPPLUS导出excel。我想通过代码进行打印设置。我也尝试了它,但问题是如果excel上有这么多列,那么print不可读,它看起来很小。当我增加excel单元格字体然后只有它是可读的但我想要excel上的普通字体和打印可读..有什么解决方案吗?

i试过以下:



I am exporting excel using EPPLUS. i want to do print setting throuhg code. I have tried it also but problem is that if there are so many columns on excel then print is not readable it looks to small. when i increase the excel cell font then only it is readable but i want normal font on excel and print make readable..is there any solution?
i have tried following:

worksheet.Cells.Style.Font.Size = 14;
worksheet.Cells.Style.Font.Name = "Veranda";
worksheet.Cells.Style.WrapText = true;
worksheet.Row(1).Style.WrapText = true;
worksheet.PrinterSettings.PaperSize = ePaperSize.A4;
worksheet.PrinterSettings.FitToPage = true;
worksheet.PrinterSettings.FitToHeight = 150;
worksheet.PrinterSettings.Orientation = eOrientation.Landscape;





我已将字体14设置为看起来可读,但实际上我想要字体10并且打印看起来可读。



I have set font 14 to look print readable but actually i want font 10 and print will look readable.

推荐答案

您的问题的解决方案在您的代码中。由于您已将纸张大小设置为A4并将FitToPage属性设置为true,因此当没有列增加时,此属性会尝试挤压A4页面中的所有列,这使得单元格内容难以阅读。您可以尝试以下方法:

1.删除属性FitToPage = true。

2.更改纸张的纸张尺寸,即将纸张尺寸设置为A3,例如单元格内容更具可读性。
Solution to your problem lies within your code. As you have set the paper size to A4 and set the FitToPage property to true, when no of columns increases this property tries to squeeze all the columns in A4 page which make the cell contents hard to read. You can try the following:
1. Remove the property FitToPage = true.
2. Change the paper size of sheet i.e. set paper size to A3 for example that will make cell contents more readable.


这篇关于使用EPPLUS导出excel时如何通过代码进行打印设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆