Click here to Skip to main content
12,070,942 members (60,461 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB Javascript .NET VB.NET
In this code excel cell are auto fill through database now i want to those cell are fill only they are locked

function CreateExcel() {
 
            document.all.OA1.CreateNew("Excel.Application");
            var testNo = document.getElementById("<%=txttestno.ClientID %>");
            var PlantCD = document.getElementById("<%=cmbPlant.ClientID %>");
 
            var sExcelData = Modules_masters_TestMethodMaster_TestMethodMaster.ReExcelScreen(testNo.value, PlantCD.value); // Take excel date to database

            var objExcel = document.OA1.GetApplication();
            var worksheet = objExcel.ActiveSheet; //Excel sheet
            var sdata = sExcelData.value;
            var aRow = sdata.split(',');//Data split

            for (i = 0; i < aRow.length; i++) {
                var aCol = aRow[i].split('#'); //Data split
                for (j = 0; j < aCol.length; j++) {
                    var result = worksheet.cells(i + 1, j + 1).Formula = aCol[j + 1]; // Data fill in excel cell
                  
  if (result != "") {
//For check cell data for locking, here i want to protect or lock my cell data those are fill, they are not change in fill cell only change in blank cell
                        worksheet.cells(i + 1, j + 1).Style.Locked = true; // this code is not work
                                              
                    }
                }
            }
        }
Posted 13-Mar-13 21:45pm
Edited 14-Mar-13 11:37am
Maciej Los213.8K
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 14 Mar 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100