EPPlus中的自动列宽 [英] Auto column width in EPPlus
本文介绍了EPPlus中的自动列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当列中的文本较长时,如何使列成为自动宽度?
How to make columns to be auto width when texts in columns are long?
我使用此代码
Worksheet.Column(colIndex).AutoFitColumn() 'on all columns'
Worksheet.cells.AutoFitColumns()
Worksheet.Column(colIndex).BestFit = True 'on all columns'
这些方法都不起作用
有什么方法可以使其工作?
Are there any ways to make it work?
注意:我的某些文本使用Unicode。
Note: Some of my texts use Unicode.
推荐答案
使用 AutoFitColumns
,但是您必须指定单元格,我认为是整个工作表:
Use AutoFitColumns
, but you have to specify the cells, i assume the entire worksheet:
VB.NET
Worksheet.Cells(Worksheet.Dimension.Address).AutoFitColumns()
C#
Worksheet.Cells[Worksheet.Dimension.Address].AutoFitColumns();
请注意,填写工作表后需要调用此方法。
这篇关于EPPlus中的自动列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文