Skip to content

Commit 1b11370

Browse files
committed
update utility to check for null
1 parent 8d19536 commit 1b11370

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

samples/common/ExampleUtilities.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ public static void InsertText(SpreadsheetDocument sd, string sheetName, string t
127127
cell.CellValue = new CellValue(index.ToString());
128128
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
129129

130+
if (worksheetPart.Worksheet == null)
131+
{
132+
throw new InvalidOperationException("Worksheet is null. Unable to save changes.");
133+
}
134+
130135
// Save the new worksheet.
131-
worksheetPart.Worksheet?.Save();
136+
worksheetPart.Worksheet!.Save();
132137
}
133138
}
134139
}

0 commit comments

Comments
 (0)