// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android try { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + File.separator + "Aspose"); String filePath = myDir.getCanonicalPath(); // Create a new workbook. Workbook workbook = new Workbook(); //Accessing the first worksheet in the Excel file WorksheetCollection worksheets = workbook.getWorksheets(); Worksheet worksheet = worksheets.get(0); // Define the style object. Style style; // Define the styleflag object. StyleFlag flag; // Loop through all the columns in the worksheet and unlock them. for(int i = 0; i <= 255; i ++) { style = worksheet.getCells().getColumns().get(i).getStyle(); style.setLocked(false); flag = new StyleFlag(); flag.setLocked(true); worksheet.getCells().getColumns().get(i).applyStyle(style, flag); } // Get the first row style. style = worksheet.getCells().getRows().get(0).getStyle(); // Lock it. style.setLocked(true); // Instantiate the flag. flag = new StyleFlag(); // Set the lock setting. flag.setLocked(true); // Apply the style to the first row. worksheet.getCells().getRows().get(0).applyStyle(style, flag); workbook.save(filePath + File.separator + "ProtectARow_Out.xls", FileFormatType.EXCEL_97_TO_2003); } catch (Exception e) { Log.e(TAG, "Protect A Row", e); }