Forum Discussion
aimonFatima
Jun 23, 2020Copper Contributor
How to lock certain excel cells or make them read-only using X++in AX?
Hi All,
I'm new in this community working in Microsoft Dynamics 365 F&O . Looking forward to gain more knowledge from all of you..
I want to lock some of excel cells (not all) using X++ in my Export to Excel utility class.
When someone opens the excel file, they will be able to edit any cell except those cells. And if someone wishes to delete all editable data then read-only cells will retain their value and other editable cells will lose their value. Because the same file I have to use for import and these fields will used to identify unique values from Dyamics 365 FO/ AX
using (var package = new OfficeOpenXml.ExcelPackage(memoryStream))
{
var currentRow = 10;
var worksheets = package.get_Workbook().get_Worksheets();
var worksheet = worksheets.Add("@ApplicationFoundation:DMFExportOperation");
var cells = worksheet.get_Cells();
//<---- Start---> Setup Header creation
//Want to make lock below field
cell=null;
value="XYZ";
cell=cells.get_Item(4,2);
cell.set_Value(value);
this.setCellBold(cell);
}
Thanks in Advance!!!
Regards,
Aimon Fatima
1 Reply
- JKPieterseSilver ContributorI don't know X++, but I do know that in Excel protecting cells consists of two things:
- Setting locked property to False for cells that must be editable (default is True)
- Protecting the worksheet in question