AutofitRowHeight メソッドを高速に実行するには?
対象製品
El Tabelle for .NET 2.0J
詳細
シートの行の高さを自動調整する AutofitRowHeight メソッドを全ての行に対して実行すると、行数によっては著しく実行速度が低下します。
次のように、表示範囲に対してのみ逐次処理を行うことで最適なパフォーマンスで AutofitRowHeight メソッドを利用できます。
[Visual Basic]
[C#]
なお、印刷を実行する場合などは予め全ての行に対して AutofitRowHeight メソッドを実行する必要があります。
次のように、表示範囲に対してのみ逐次処理を行うことで最適なパフォーマンスで AutofitRowHeight メソッドを利用できます。
[Visual Basic]
Private Sub Sheet1_Scroll(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Sheet1.Scroll
Dim intTopRow As Integer = Sheet1.TopLeft.Row
Dim intBottomRow As Integer = Sheet1.BottomRight.Row
Dim intPageRows As Integer = intBottomRow - intTopRow
'1ページ先読みして処理する
If (intBottomRow + intPageRows) < Sheet1.MaxRows - 1 Then
intBottomRow = intBottomRow + intPageRows
Else
intBottomRow = Sheet1.MaxRows - 1
End If
Sheet1.Redraw = False
For i As Integer = intTopRow To intBottomRow
Sheet1.AutofitRowHeight(i)
Next
Sheet1.Redraw = True
End Sub
ByVal e As System.EventArgs) Handles Sheet1.Scroll
Dim intTopRow As Integer = Sheet1.TopLeft.Row
Dim intBottomRow As Integer = Sheet1.BottomRight.Row
Dim intPageRows As Integer = intBottomRow - intTopRow
'1ページ先読みして処理する
If (intBottomRow + intPageRows) < Sheet1.MaxRows - 1 Then
intBottomRow = intBottomRow + intPageRows
Else
intBottomRow = Sheet1.MaxRows - 1
End If
Sheet1.Redraw = False
For i As Integer = intTopRow To intBottomRow
Sheet1.AutofitRowHeight(i)
Next
Sheet1.Redraw = True
End Sub
[C#]
private void Sheet1_Scroll(object sender, System.EventArgs e)
{
int intTopRow = Sheet1.TopLeft.Row;
int intBottomRow = Sheet1.BottomRight.Row;
int intPageRows = intBottomRow - intTopRow;
if ((intBottomRow + intPageRows) < Sheet1.MaxRows - 1) {
intBottomRow = intBottomRow + intPageRows;
} else {
intBottomRow = Sheet1.MaxRows - 1;
}
Sheet1.Redraw = false;
for (int i = intTopRow; i <= intBottomRow; i++) {
Sheet1.AutofitRowHeight(i);
}
Sheet1.Redraw = true;
}
{
int intTopRow = Sheet1.TopLeft.Row;
int intBottomRow = Sheet1.BottomRight.Row;
int intPageRows = intBottomRow - intTopRow;
if ((intBottomRow + intPageRows) < Sheet1.MaxRows - 1) {
intBottomRow = intBottomRow + intPageRows;
} else {
intBottomRow = Sheet1.MaxRows - 1;
}
Sheet1.Redraw = false;
for (int i = intTopRow; i <= intBottomRow; i++) {
Sheet1.AutofitRowHeight(i);
}
Sheet1.Redraw = true;
}
なお、印刷を実行する場合などは予め全ての行に対して AutofitRowHeight メソッドを実行する必要があります。
キーワード
HowTo
この文書は、以前は次のFAQ IDで公開されていました : 6608