What library are you using to create the Excel file? Doesn't it have a method for protecting the worksheet? For example Apache POI has a promisingly named method...