Hello,
This message was posted using Page2Forum from Product Overview - Aspose.Cells for .NET
Hello,
Hi Jim,
Thanks for considering Aspose.
Aspose.Cells for .NET supports your desired features for Excel 2007 formats.
For your desired features:
Yes, these features are supported for Excel 2007 formats, see the sample examples below:
To protect an entire sheet in an existing Excel 2007 Xlsx file.
//Instantiating a Workbook object
Workbook excel = new Workbook();
//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(“e:\test\Book1.xlsx”, FileMode.Open);
//Opening the Excel file through the file stream
excel.Open(fstream,FileFormatType.Excel2007Xlsx);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = excel.Worksheets[0];
//Protecting the worksheet with a password
worksheet.Protect(ProtectionType.All, “amjad”, null);
//Saving the modified Excel file in default (that is Excel 20003) format
excel.Save(“e:\test\outputBook1.xlsx”);
//Closing the file stream to free all resources
fstream.Close();
To Protect some cells in a sheet for Excel 2007 Xlsx format.
// Create a new workbook.
Workbook wb = new Workbook();
// Create a worksheet object and obtain the first sheet.
Worksheet sheet = wb.Worksheets[0];
// Define the style object.
Style style;
//Define the styleflag object
StyleFlag styleflag;
// Loop through all the columns in the worksheet and unlock them.
for (int i = 0; i <= 255; i++)
{
style = sheet.Cells.Columns[(byte)i].Style;
style.IsLocked = false;
styleflag = new StyleFlag();
styleflag.Locked = true;
sheet.Cells.Columns[(byte)i].ApplyStyle(style, styleflag);
}
// Lock the three cells…i.e. A1, B1, C1.
style = sheet.Cells[“A1”].Style;
style.IsLocked = true;
sheet.Cells[“A1”].Style = style;
style = sheet.Cells[“B1”].Style;
style.IsLocked = true;
sheet.Cells[“B1”].Style = style;
style = sheet.Cells[“C1”].Style;
style.IsLocked = true;
sheet.Cells[“C1”].Style = style;
// Finally, Protect the sheet now.
sheet.Protect(ProtectionType.All);
// Save the excel file.
wb.Save(“e:\test\lockedcells.xlsx”);
For further reference, please see the documents:
You may set add-ins formulas, see the document: