1
Vote

workSheet.Dimension.End.Column throws null reference for empty worksheets

description

When trying to find the last column in a empty worksheet using...

var lastColumn = sheet.Dimension.End.Column;

...a null reference error occurs (none of sheet, .Dimension or .End are null) as consequence of calling the integer property .Column.

This appears to be consistent for empty worksheets that have never had any data added to them.

comments