简体   繁体   English

从SSRS导出到Excel时,列宽会发生变化

[英]Column widths changing when exporting from SSRS to Excel

I have a simple SSRS report which contains a single table with a header row, footer row and any number of detail rows. 我有一个简单的SSRS报告,其中包含一个包含标题行,页脚行和任意数量详细信息行的表。 The width of the report and table is 7 inches and the report has .5 inch margins all the way around. 报告和表格的宽度为7英寸,报告的边距为0.5英寸。 But when I export this report to Excel, the width of each column is increased by about 8%, which causes the report to exceed 7.5 inches and overflow to a second page when printing it. 但是当我将此报告导出到Excel时,每列的宽度增加了大约8%,这导致报告超过7.5英寸并在打印时溢出到第二页。 I've simplified the report so that no extra or hidden columns are generated in Excel, but it still has this problem. 我已经简化了报表,因此在Excel中不会生成额外的或隐藏的列,但它仍然存在这个问题。 I know I can use Globals!RenderFormat.Name to determine if it's being generated in Excel, but since I can't use an expression in column widths, that doesn't appear to be of any help. 我知道我可以使用Globals!RenderFormat.Name来确定它是否在Excel中生成,但由于我不能在列宽中使用表达式,这似乎没有任何帮助。

How do I get SSRS to maintain the same column widths when exporting to Excel? 如何在导出到Excel时让SSRS保持相同的列宽?

I found that the dependency of the column widths when exporting to excel is linear. 我发现导出到excel时列宽的依赖性是线性的。 This is the reason why I made simple linear regression and I have the following results: 这就是我进行简单线性回归的原因,我得到以下结果:

If you need column width of X when exporting to excel, you should use the following formula for width in inches in SSRS (Y) 如果在导出到Excel时需要X的列宽,则应在SSRS(Y)中使用以下公式表示宽度(英寸)

Y = 0.072810 * X + 0.055624467 Y = 0.072810 * X + 0.055624467

Or of you need column width of 10 for the exported excel file, the width in inches in SSRS(Y) should be: 或者您需要导出的Excel文件的列宽为10,SSRS(Y)中的宽度(以英寸为单位)应为:

Y = 0.072810 * 10 + 0.055624467 so we have Y = 0.7837 Y = 0.072810 * 10 + 0.055624467所以我们有Y = 0.7837

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM