// Create an instance of the class that exports Excel file, having two sheets ExcelDocument workbook = new ExcelDocument(2); // Set the sheet names workbook.easy_getSheetAt(0).setSheetName("First tab"); workbook.easy_getSheetAt(1).setSheetName("Second tab"); // Protect Excel sheet workbook.easy_getSheetAt(0).setSheetProtected(true); // Get the table of data for the first worksheet that will keep the data ExcelTable xlsFirstTable = ((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_getExcelTable(); ... // Add data to cells for report values for (int row=0; row<100; row++) { for (int column=0; column<5; column++) { xlsFirstTable.easy_getCell(row+1, column).setValue( "Data " + (row + 1) + ", " + (column + 1)); } } // Create a formatting style for cells ExcelStyle xlsStyleData = new ExcelStyle(); xlsStyleData.setHorizontalAlignment(Alignment.ALIGNMENT_LEFT); xlsStyleData.setForeground(Color.DarkGray); xlsStyleData.setWrap(false); xlsStyleData.setDataType(DataType.STRING); // Apply locked cells property to the formatting style xlsStyleData.setLocked(true); xlsFirstTable.easy_setRangeStyle("A2:E101", xlsStyleData); // Export Excel file workbook.easy_WriteXLSXFile("C:\\Samples\\Protected Excel sheet.xlsx");

Click here to see Continuous Code Listing

' Create an instance of the class that exports Excel file, having two sheets Dim workbook As New ExcelDocument(2) ' Set the sheet names workbook.easy_getSheetAt(0).setSheetName("First tab") workbook.easy_getSheetAt(1).setSheetName("Second tab") ' Protect Excel sheet workbook.easy_getSheetAt(0).setSheetProtected(True) ' Get the table of data for the first worksheet that will keep the data Dim xlsFirstTab As ExcelWorksheet = workbook.easy_getSheetAt(0) Dim xlsFirstTable = xlsFirstTab.easy_getExcelTable() ... ' Add data to cells for report values For row As Integer = 0 To 99 For column As Integer = 0 To 4 xlsFirstTable.easy_getCell(row + 1, column).setValue( _ "Data " & (row + 1) & ", " & (column + 1)) Next Next ' Create a formatting style for cells Dim xlsStyleData As New ExcelStyle xlsStyleData.setHorizontalAlignment(Alignment.ALIGNMENT_LEFT) xlsStyleData.setForeground(Color.DarkGray) xlsStyleData.setWrap(False) xlsStyleData.setDataType(DataType.STRING) ' Apply locked cells property to the formatting style xlsStyleData.setLocked(True) xlsFirstTable.easy_setRangeStyle("A2:E101", xlsStyleData) // Export Excel file workbook.easy_WriteXLSXFile("C:\Samples\Protected Excel sheet.xlsx")

Click here to see Continuous Code Listing

// Create an instance of the class that exports Excel file, having two sheets ExcelDocument *workbook = new ExcelDocument(2); // Set the sheet names workbook->easy_getSheetAt(0)->setSheetName("First tab"); workbook->easy_getSheetAt(1)->setSheetName("Second tab"); // Protect Excel sheet workbook->easy_getSheetAt(0)->setSheetProtected(true); // Get the table of data for the first worksheet that will keep the data ExcelWorksheet *xlsFirstTab = __try_cast<ExcelWorksheet*>(workbook->easy_getSheetAt(0)); ExcelTable *xlsFirstTable = xlsFirstTab->easy_getExcelTable(); ... // Add data to cells for report values for (int row=0; row<100; row++) { for (int column=0; column<5; column++) { xlsFirstTable->easy_getCell(row+1,column)->setValue(String::Concat( "Data ", (row + 1).ToString(), ", ", (column + 1).ToString())); } } // Create a formatting style for cells ExcelStyle *xlsStyleData = new ExcelStyle(); xlsStyleData->setHorizontalAlignment(Alignment::ALIGNMENT_LEFT); xlsStyleData->setForeground(Color::DarkGray); xlsStyleData->setWrap(false); xlsStyleData->setDataType(DataType::STRING); // Apply locked cells property to the formatting style xlsStyleData->setLocked(true); xlsFirstTable->easy_setRangeStyle("A2:E101", xlsStyleData); // Export Excel file workbook->easy_WriteXLSXFile("C:\\Samples\\Protected Excel sheet.xlsx");

Click here to see Continuous Code Listing

// Create an instance of the class that exports Excel file, having two sheets ExcelDocument workbook = new ExcelDocument(2); // Set the sheet names workbook.easy_getSheetAt(0).setSheetName("First tab"); workbook.easy_getSheetAt(1).setSheetName("Second tab"); // Protect Excel sheet workbook.easy_getSheetAt(0).setSheetProtected(true); // Get the table of data for the first worksheet that will keep the data ExcelTable xlsFirstTable = ((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_getExcelTable(); ... // Add data to cells for report values for (int row=0; row&glt;100; row++) { for (int column=0; column<5; column++) { xlsFirstTable.easy_getCell(row+1, column).setValue( "Data " + (row + 1) + ", " + (column + 1)); } } // Create a formatting style for cells ExcelStyle xlsStyleData = new ExcelStyle(); xlsStyleData.setHorizontalAlignment(Alignment.ALIGNMENT_LEFT); xlsStyleData.setForeground(Color.get_DarkGray()); xlsStyleData.setWrap(false); xlsStyleData.setDataType(DataType.STRING); // Apply locked cells property to the formatting style xlsStyleData.setLocked(true); xlsFirstTable.easy_setRangeStyle("A2:E101", xlsStyleData); // Export Excel file workbook.easy_WriteXLSXFile("C:\\Samples\\Protected Excel sheet.xlsx");

Click here to see Continuous Code Listing

// Create an instance of the class that exports Excel file, having two sheets ExcelDocument workbook = new ExcelDocument(2); // Set the sheet names workbook.easy_getSheetAt(0).setSheetName("First tab"); workbook.easy_getSheetAt(1).setSheetName("Second tab"); // Protect Excel sheet workbook.easy_getSheetAt(0).setSheetProtected(true); // Get the table of data for the first worksheet that will keep the data ExcelTable xlsFirstTable = ((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_getExcelTable(); ... // Add data to cells for report values for (int row=0; row<100; row++) { for (int column=0; column<5; column++) { xlsFirstTable.easy_getCell(row+1, column).setValue( "Data " + (row + 1) + ", " + (column + 1)); } } // Create a formatting style for cells ExcelStyle xlsStyleData = new ExcelStyle(); xlsStyleData.setHorizontalAlignment(Alignment.ALIGNMENT_LEFT); xlsStyleData.setForeground(Color.LIGHT_GRAY); xlsStyleData.setWrap(false); xlsStyleData.setDataType(DataType.STRING); // Apply locked cells property to the formatting style xlsStyleData.setLocked(true); xlsFirstTable.easy_setRangeStyle("A2:E101", xlsStyleData); // Export Excel file workbook.easy_WriteXLSXFile("C:\\Samples\\Protected Excel sheet.xlsx");

Click here to see Continuous Code Listing

// Create an instance of the class that exports Excel file $workbook = new COM("EasyXLS.ExcelDocument"); // Create two sheets $workbook->easy_addWorksheet_2("First tab"); $workbook->easy_addWorksheet_2("Second tab"); // Protect Excel sheet $workbook->easy_getSheetAt(0)->setSheetProtected(true); // Get the table of data for the first worksheet that will keep the data $xlsFirstTable = $workbook->easy_getSheetAt(0)->easy_getExcelTable(); ... // Create a formatting style for cells $xlsStyleData = new COM("EasyXLS.ExcelStyle"); $xlsStyleData->setHorizontalAlignment($ALIGNMENT_ALIGNMENT_LEFT); $xlsStyleData->setForeground((int)$COLOR_DARKGRAY); $xlsStyleData->setWrap(false); // Apply locked cells property to the formatting style $xlsStyleData->setLocked(true); $xlsStyleData->setDataType($DATATYPE_STRING); // Add data to cells for report values for ($row=0; $row<100; $row++) { for ($column=0; $column<5; $column++) { $xlsFirstTable->easy_getCell($row+1,$column)->setValue( "Data " . ($row + 1) . ", " . ($column + 1)); $xlsFirstTable->easy_getCell($row+1,$column)->setStyle($xlsStyleData); } } // Export Excel file $workbook->easy_WriteXLSXFile("C:\Samples\Protected Excel sheet.xlsx");

Click here to see Continuous Code Listing

' Create an instance of the class that exports Excel file set workbook = Server.CreateObject("EasyXLS.ExcelDocument") ' Create two sheets workbook.easy_addWorksheet_2("First tab") workbook.easy_addWorksheet_2("Second tab") ' Protect Excel sheet workbook.easy_getSheetAt(0).setSheetProtected(true) ' Get the table of data for the first worksheet that will keep the data Set xlsFirstTable = workbook.easy_getSheetAt(0).easy_getExcelTable() ... ' Create a formatting style for cells Set xlsStyleData = Server.CreateObject("EasyXLS.ExcelStyle") xlsStyleData.setHorizontalAlignment(ALIGNMENT_ALIGNMENT_LEFT) xlsStyleData.setForeground(CLng(COLOR_DARKGRAY)) xlsStyleData.setWrap(False) ' Apply locked cells property to the formatting style xlsStyleData.setLocked(True) xlsStyleData.setDataType(DATATYPE_STRING) ' Add data to cells for report values for row = 0 to 99 for column = 0 to 4 xlsFirstTable.easy_getCell(row+1,column).setValue( _ "Data " & (row + 1) & ", " & (column + 1)) xlsFirstTable.easy_getCell(row+1,column).setStyle(xlsStyleData) next next // Export Excel file workbook.easy_WriteXLSXFile ("C:\Samples\Protected Excel sheet.xlsx")

Click here to see Continuous Code Listing

// Create an instance of the class that exports Excel file EasyXLS::IExcelDocumentPtr workbook; hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument), NULL, CLSCTX_ALL, __uuidof(EasyXLS::IExcelDocument), (void**) &workbook); // Create two sheets workbook->easy_addWorksheet_2("First tab"); workbook->easy_addWorksheet_2("Second tab"); // Protect Excel sheet workbook->easy_getSheetAt(0)->setSheetProtected(true); // Get the table of data for the first worksheet that will keep the data EasyXLS::IExcelWorksheetPtr xlsFirstTab = (EasyXLS::IExcelWorksheetPtr)workbook->easy_getSheetAt(0); EasyXLS::IExcelTablePtr xlsFirstTable = xlsFirstTab->easy_getExcelTable(); ... // Create a formatting style for cells EasyXLS::IExcelStylePtr xlsStyleData; hr = CoCreateInstance(__uuidof(EasyXLS::ExcelStyle), NULL, CLSCTX_ALL, __uuidof(EasyXLS::IExcelStyle), (void**) &xlsStyleData) ; xlsStyleData->setHorizontalAlignment(ALIGNMENT_ALIGNMENT_LEFT); xlsStyleData->setForeground(COLOR_DARKGRAY); xlsStyleData->setWrap(false); // Apply locked cells property to the formatting style xlsStyleData->setLocked(true); xlsStyleData->setDataType(DATATYPE_STRING); // Add data to cells for report values char* rowNumber = (char*)malloc(sizeof(char)); for (int row=0; row<100; row++) { for (int column=0; column<5; column++) { strcpy(cellValue, "Data "); _itoa(column+ 1, columnNumber , 10); _itoa(row + 1, rowNumber , 10); strcat(cellValue, rowNumber); strcat(cellValue, ", "); strcat(cellValue, columnNumber); xlsFirstTable->easy_getCell(row+1,column)->setValue(cellValue); xlsFirstTable->easy_getCell(row+1,column)->setStyle(xlsStyleData); } } // Export Excel file workbook->easy_WriteXLSXFile("C:\\Samples\\Protected Excel sheet.xlsx");

Click here to see Continuous Code Listing

' Create an instance of the class that exports Excel file Set workbook = CreateObject("EasyXLS.ExcelDocument") ' Create two sheets workbook.easy_addWorksheet_2 ("First tab") workbook.easy_addWorksheet_2 ("Second tab") ' Protect Excel sheet workbook.easy_getSheetAt(0).setSheetProtected (True) ' Get the table of data for the first worksheet that will keep the data Set xlsFirstTable = workbook.easy_getSheetAt(0).easy_getExcelTable() ... ' Create a formatting style for cells Set xlsStyleData = CreateObject("EasyXLS.ExcelStyle") xlsStyleData.setHorizontalAlignment (Alignment.ALIGNMENT_ALIGNMENT_LEFT) xlsStyleData.setForeground (CLng(Color.COLOR_DARKGRAY)) xlsStyleData.setWrap (False) ' Apply locked cells property to the formatting style xlsStyleData.setLocked (True) xlsStyleData.setDataType (DataType.DATATYPE_STRING) ' Add data to cells for report values For row = 0 To 99 For Column = 0 To 4 xlsFirstTable.easy_getCell(row + 1, Column).setValue ( _ "Data " & (row + 1) & ", " & (Column + 1)) xlsFirstTable.easy_getCell(row + 1, Column).setStyle (xlsStyleData) Next Next ' Export Excel file workbook.easy_WriteXLSXFile ("C:\Samples\Protected Excel sheet.xlsx")

Click here to see Continuous Code Listing

' Create an instance of the class that exports Excel file Set workbook = CreateObject("EasyXLS.ExcelDocument") ' Create two sheets workbook.easy_addWorksheet_2("First tab") workbook.easy_addWorksheet_2("Second tab") ' Protect Excel sheet workbook.easy_getSheetAt(0).setSheetProtected(true) ' Get the table of data for the first worksheet that will keep the data Set xlsFirstTable = workbook.easy_getSheetAt(0).easy_getExcelTable() ... ' Create a formatting style for cells Set xlsStyleData = CreateObject("EasyXLS.ExcelStyle") xlsStyleData.setHorizontalAlignment(ALIGNMENT_LEFT) xlsStyleData.setForeground(CLng(DARKGRAY)) xlsStyleData.setWrap(False) ' Apply locked cells property to the formatting style xlsStyleData.setLocked(True) xlsStyleData.setDataType(DATATYPE_STRING) ' Add data to cells for report values for row = 0 to 99 for column = 0 to 4 xlsFirstTable.easy_getCell(row+1,column).setValue( _ "Data " & (row + 1) & ", " & (column + 1)) xlsFirstTable.easy_getCell(row+1,column).setStyle(xlsStyleData) next next ' Export Excel file workbook.easy_WriteXLSXFile ("C:\Samples\Protected Excel sheet.xlsx")

Click here to see Continuous Code Listing

<!-- Create an instance of the class that exports Excel file --> <cfobject type="java" class="EasyXLS.ExcelDocument" name="workbook" action="CREATE"> <!-- Create two sheets --> <cfset ret = workbook.easy_addWorksheet("First tab")> <cfset ret = workbook.easy_addWorksheet("Second tab")> <!-- Protect Excel sheet --> <cfset workbook.easy_getSheetAt(0).setSheetProtected(true)> <!-- Get the table of data for the first worksheet that will keep the data --> <cfset xlsFirstTable = workbook.easy_getSheetAt(0).easy_getExcelTable()> ... <!-- Create a formatting style for cells --> <cfobject type="java" class="EasyXLS.ExcelStyle" name="xlsStyleData" action="CREATE"> <cfset xlsStyleData.setHorizontalAlignment(Alignment.ALIGNMENT_LEFT)> <cfset xlsStyleData.setForeground(Color.lightGray)> <cfset xlsStyleData.setWrap(false)> <!--Apply locked cells property to the formatting style --> <cfset xlsStyleData.setLocked(true)> <cfset xlsStyleData.setDataType(DataType.STRING)> <!-- Add data to cells for report values --> <cfloop from="0" to="99" index="row"> <cfloop from="0" to="4" index="column"> <cfset xlsFirstTable.easy_getCell(evaluate(row + 1),evaluate(column)).setValue( "Data " & evaluate(row + 1) & ", " & evaluate(column + 1))> <cfset xlsFirstTable.easy_getCell(evaluate(row + 1),evaluate(column)).setStyle( xlsStyleData)> </cfloop> </cfloop> <!-- Export Excel file --> <cfset ret = workbook.easy_WriteXLSXFile("C:\Samples\Protected Excel sheet.xlsx")>

Click here to see Continuous Code Listing

