Forum Discussion

anumolu9999's avatar
anumolu9999
Contributor
8 years ago

my script is asking to open the excel file

Below is the function to get data from excel. But getting error while running if the file is closed. Do this need to add any line in the script to open excel in the background. Can any one help me out with this problem. function getControlData(index) { ctrlData = ODT.Classes.NewArray(); DatafileName="MCT_ControlsNtestData.xlsx"; sCurPath = Sys.OleObject("Scripting.FileSystemObject").GetAbsolutePathName("."); excelPath = sCurPath + "\\Data\\" + DatafileName; //Get files to upload from Excel Sheet DDT.ExcelDriver(excelPath,"WSI_Controls"); while(!DDT.CurrentDriver.EOF()) { colCount=DDT.CurrentDriver.ColumnCount for(var j=0;j<=colCount-1;j++) { if(DDT.CurrentDriver.Value("index")==index) ctrlData.AddItem(DDT.CurrentDriver.Value(j)); else break; } DDT.CurrentDriver.Next(); } DDT.CloseDriver(DDT.CurrentDriver.Name); return ctrlData; }

13 Replies

    • anumolu9999's avatar
      anumolu9999
      Contributor
      I am not able to see those options Under RichText. I think the network that I am currently in is blocking attachments/formatting text
      • baxatob's avatar
        baxatob
        Community Hero

        Ok. Please check:

         

        function getControlData(index) { 
        
        	ctrlData = ODT.Classes.NewArray(); 
        	DatafileName = "MCT_ControlsNtestData.xlsx"; 
        	sCurPath = Sys.OleObject("Scripting.FileSystemObject").GetAbsolutePathName("."); 
        	excelPath = sCurPath + "\\Data\\" + DatafileName;
        	DDT.ExcelDriver(excelPath, "WSI_Controls"); 
        	while(!DDT.CurrentDriver.EOF()) { 
        		colCount = DDT.CurrentDriver.ColumnCount 
        		for(var j=0; j<=colCount-1; j++) { 
        			if(DDT.CurrentDriver.Value("index")==index) 
        				ctrlData.AddItem(DDT.CurrentDriver.Value(j)); 
        			else break; 
        			} 
        		DDT.CurrentDriver.Next();
        		} 
        	DDT.CloseDriver(DDT.CurrentDriver.Name); 
        	return ctrlData; 
        	}

        What exact error do you receive?