Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please please... can anyone tell me why this code doesn't store all read values of Excel sheet in array "store".Here debugger is showing the error "store[...]is null or not an object".
Please help me in correcting this code and providing an errorless code for loading an Excel sheet via JavaScript.
<script type="text/javascript"> 
var i,l;
store=new Array();
for(l=1;l<7;l++);
 {for(i=1;i<4;i++)
   
      {var Excel;
	Excel = new ActiveXObject("Excel.Application");	
	Excel.Visible = false;
	store[l-1]=new Array;
        store[l-1][i-1].Value=Excel.Workbooks.Open("C:/desktop/text.xlsx").ActiveSheet.Cells(l,i).Value;	        
	document.write("value is" +store[l-1][i-1].Value+"\n")	
}
}
Excel.Quit()
</script> 
Posted
Updated 1-Jun-10 10:03am
v2
Comments
Sandeep Mewara 1-Jun-10 12:35pm    
Your coding for store looks totally wrong! What are you trying to achieve? What is the end result expected?

1 solution

I think your problem here is that you are creating a new Excel.Application object throught every iteration of your FOR loops (ouch!). The Excel object needs to be created only once, before you begin the FOR loops.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900