Added conditional checks to Excel output.