473,465 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Code is not running while reading large values from excel

4 New Member
I have written the javascript code for client side using Google Map API that is running well when i am reading excel sheet having 170 rows but when i tried to run it on excel having 237 rows so it gives error in the array "farah[...]5 is null or not an object",then i ok to debugg but debugger doesn't show anything and map opens but as i want to plot polygon doesn't appears.The same code is showing polygons well for excel of 170 rows.

In the excel sheet,i used latitude value in col 3 and longitude value in col 2,ID is in col 5 for which i want to store values and plot polygon is after col 6 and onwards.

Below is my code.Please can anyone solve this problem.
Collapse

Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  2. <head>
  3. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  4. <title>Google Maps API Sample</title>
  5. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q" type="text/javascript"></script>
  6. <script type="text/javascript">
  7. document.write("<pre>");
  8. function initialize() {
  9. farah=new Array()
  10. samrah=new Array()
  11. var Excel;
  12. Excel = new ActiveXObject("Excel.Application");
  13. Excel.Visible = false;
  14. var a=Excel.Workbooks.Open("C:/desktop/Book5.xlsx").sheets(1);
  15. for(var r=1;r<=a.usedrange.rows.count;r++)
  16. {
  17. farah[r-1]=new Array()
  18. for(var c=1;c<=a.usedrange.columns.count;c++)
  19. farah[r-1][c-1]=a.Cells(r,c).Value;
  20. }
  21. n=prompt("ENTER THE ID","");
  22. var x,y,a;
  23. for(a=1;a<farah.length;a++)
  24. {if(n==farah[a][5])
  25. {x=farah[a][1];
  26. y=farah[a][2];}}
  27. if (GBrowserIsCompatible()) {
  28. var map = new GMap2(document.getElementById("map_canvas"));
  29. map.setCenter(new GLatLng(y,x), 15);
  30. map.addControl(new GSmallMapControl());
  31. map.addControl(new GMapTypeControl());
  32. map.addControl(new GMapTypeControl());
  33.  
  34. for(m=1;m<farah.length;m++)
  35. {
  36. bsc=farah[m][5];
  37. if(n==bsc)
  38. {
  39. samrah=new Array()
  40. u=0;y=6;
  41. if(farah[m][6]!=null)
  42. {
  43. do
  44. {samrah[u]=farah[m][y];
  45. u++;
  46. y++;
  47. }
  48. while(farah[m][y]!=null);
  49. u--;
  50. }
  51. }
  52. m++;
  53. bsc1=farah[m][5];
  54.  
  55. if(n==bsc1)
  56. {
  57. samrah=new Array()
  58. u=0;y=6;
  59. if(farah[m][6]!=null)
  60. {
  61. do
  62. {samrah[u]=farah[m][y];
  63. u++;
  64. y++;
  65. }
  66. while(farah[m][y]!=null);
  67. u--;
  68. }}
  69. m++
  70. bsc2=farah[m][5];
  71.  
  72.  
  73. if(n==bsc2)
  74. {
  75. samrah=new Array()
  76. u=0;y=6;
  77. if(farah[m][6]!=null)
  78. {
  79. do
  80. {samrah[u]=farah[m][y];
  81. u++;
  82. y++;
  83. }
  84. while(farah[m][y]!=null);
  85. u--;
  86. }}
  87.  
  88. }
  89.  
  90.  
  91.  
  92. for(t=1;t<farah.length;t++)
  93. {cell=farah[t][5]
  94. for(j=0;j<samrah.length;j++)
  95. {
  96.  
  97. if(samrah[j]==cell)
  98. {
  99. c3=farah[t][0];
  100. lat =farah[t][2];
  101. lon = farah[t][1];
  102. var latOffset = 0.05;
  103. var lonOffset = 1;
  104. var latOffset2 = 0.05;
  105. var lonOffset2 = 1;
  106.  
  107. switch(c3)
  108. {
  109. case "1":
  110. {polygon = new GPolygon([
  111. new GLatLng(lat , lon ),
  112. new GLatLng(lat - (latOffset2-0.049), lon + (lonOffset-0.9995)),
  113. new GLatLng(lat - (latOffset2-0.049), lon - (lonOffset-0.9995)),
  114. new GLatLng(lat , lon ),
  115. ], "0x987654", 0.1 , 0.9, "0x987654", 0.9);
  116.  
  117. map.addOverlay(polygon);
  118. break;}
  119. case "2":
  120. {polygon2 = new GPolygon([
  121. new GLatLng ( lat, lon),
  122. new GLatLng(lat ,lon + (lonOffset2-0.999)),
  123. new GLatLng(lat + (latOffset-0.049),lon + (lonOffset2-0.999)),
  124. new GLatLng(lat,lon),
  125. ], "0x987654", 0.1 , 0.9, "0x987654", 0.9);
  126. map.addOverlay(polygon2);
  127. break;}
  128. default:
  129. {polygon3 = new GPolygon([
  130. new GLatLng( lat, lon),
  131. new GLatLng( lat, lon - (lonOffset2-0.999)),
  132. new GLatLng( lat + (latOffset-0.049), lon - (lonOffset2-0.999)),
  133. new GLatLng( lat ,lon),
  134. ], "0x987654", 0.1 , 0.9, "0x987654", 0.9);
  135. map.addOverlay(polygon3);
  136. break;}}
  137. }
  138. }
  139. }
  140. }
  141. }
  142. </script>
  143. </head>
  144. <body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
  145. <div id="map_canvas" style="width: 1000px; height: 900px"></div>
  146. </body>
  147. </html>
Nov 26 '10 #1
1 1268
acoder
16,027 Recognized Expert Moderator MVP
You may want to double-check your Excel file. It may be that one of the rows has something missing.
Nov 28 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: leke | last post by:
Hi, I am trying to learn PHP but am having some problems getting my code running in Explorer 6. <html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?>...
1
by: Pls Help | last post by:
Hi, I've encountered a weird TrackBar issue, it seems to hang completely when the TrackBar.Maximum is set to certain large values.. what's going on? Have tried this on a few different 2000/XP...
8
by: Axter | last post by:
I normally use a program call Doxygen to document my source code.(http://www.stack.nl/~dimitri/doxygen) This method works great for small and medium size projects, and you can get good...
1
by: tito | last post by:
Hi All, I am trying to write a code which will convert the Excel sheet document to Pie Diagarm using Perl Script.I have already searched in CPAN which gives the details of...
5
by: Martin Walke | last post by:
Hi all, I have an ASP application where I need to not only read the selected item from a combo box on a web page but also all the options in the combo box. Can someone point me in the right...
1
by: sathyan8294 | last post by:
what is vb.net code for changing the values in datagrid and save the changed values using vb.net windows application
3
by: ramona chauhan | last post by:
Hi This is ramona . i want to know the code for reading an excel file. please provide the required code.
0
by: JFKJr | last post by:
I have an excel file, which has columns C and D grouped together, I am trying to delete blank columns and rows from the excel file, ungroup the columns and import the file to MS Access using Access...
1
by: =?Utf-8?B?U2hlZXMgQWJpZGk=?= | last post by:
I read an article on the link: http://support.microsoft.com/default.aspx?scid=kb;en-us;306572 related to reading data from Excel using OLEDB The topic's heading is: How to query and display excel...
1
by: ronakinuk | last post by:
how to mark comment on a block of code in one click in excel vba
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.