Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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
(no name)158.9K
v3

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 Andreas Gieriet 100
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 14 Mar 2013
Copyright © CodeProject, 1999-2014
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