Excel Clone
Excel Clone
code Page 1
COLOR WALA ELEMENT //BUILDING UI PART --
Agar sift input tag mein dalte ho to side me ati hai
But we want it when we click on the A or fill so ham
Visibility 0 karenge , aur absolute display mein height full kardenge to poore div mein color element
hoga par dikhega icon hi -- matlab no icon ko over shadow nahi karega
Now cell prop banao jismein sari prop hogi har cell phir is cell prop ko sheet row mein add kardo
////defining properties
code Page 2
///////////////selectors for cell property
Active cell ka Address kese access karein -- directly address-bar se -> encoded hai "a1"-- use decode
karo to row, id and cell id
code Page 3
//// taki koi null value ka error na aie
///conversion logic
///adress decoding
///charCodeAt(index)
///pehle DATA CHANGE TAKI WE CAN BE SURE KI PEHLE DATA CHANGE HO CHUKA HAI
///storage mein change karo then ui mein change karo
code Page 4
Also define active inactive pehle hi
///// ALIGNMENT
code Page 5
Excel clone --> formula sheet
18 December 2023 14:34
Select cells // in general cell naam ki entity ko selet karrte hai {icon vese cell}
Put eventlistner of blur
//us particular cell ka address lere hai jaha pe hai
Address lo ui + db access karo address ke through
Blur islie lie use liya kyu focus gets triggers as soon as click happens -- uske baad ka jo bhi hai it
doesn’t care
Email sahi hai ya nahi etc ke liye blur use karna hota hai
Focus is just to see -- oh okay field empty nahi hai
For the same reasons as focus click use nahi kiya -- kyuki ye bhi atmost 1st value deta
////////////////formulaBar manipulation
Key down eventlistener -> agar enter press hota hai and formula bar ki value null nahi hai evaluate
function
Formula baar mein jaake dekhna hai -- 10+10 enter formula baar mein press karna hai
Enter trigger hua + Formula bar value hai ? [-> pass formula to evalualteformula() that contians eval ]
-> evaluated formula value lo -> ui update , db update
code Page 6
///////////////////
Handling dependence expressions
//adressdecode karke {jesa adress bar ke liye kiya tha } cell prop mein jake value field ko lena hai
phir evaluation easy hai
Direct value hoti to say '650' i=0 pe to single digit hi asakta hai [0 to 9]
To i=[0,1,2] hota then [6 5 0]
But agar 'a' hoga to value 65 ho karti hai
code Page 7
=======> HANDLING DYNAMIC CHANGING OF DATA + CHILDREN MEIN BHI USE REFLECT KARNA
<========
/////AGAR KUCH BHI CHANGE HOTA HAI TO IT SOULD BE REFLECTED TO CHILDREN CELLS TOO
/////DATA UPDATE INBETWEEN
-> PROBLEM CAN BE TACKLED VIA RECURSION
-> DEPENDENCE DEfINED NAHI HAI
Har cell ko batana padega ki uske pass children hai -- cellProp mein children array
//////////PROBLEM 2 -> WHAT IF FORMULA HI EDIT KARDIYA? -> PAR CHILD RELATIONSHIP BHI TO
CHANGE HOGI
----> jese hi formula change -purane par child rel ko tordo naye formula ko dekhke firse banao
code Page 8
// purana parent kese milega -> soln -> Old formula given in function
//what if dobara jo formula dala hai wo same hi ho -> check if formula has been changed or not
Old formula given taki pura relation mil sake aur use tora ja sake
///RCP MEIN A1 KA SIRF EK CHILD HI REMOVE KARNA HAI -> B1 baaki saare to wahi rahenge to
index dhoondna padega
//indexof //splice
code Page 9
///jab cel ki values change karein vo bhi formulae mein reflect honi chaie
code Page 10
Cycle detection
19 December 2023 12:12
-----> uni-directional only parent to child hi relation hai , child vapar parent pe nahi jata
code Page 11
---------> cycle detection
///// working
code Page 12
5 not visited since visited array mein 5 already visited hai so no calls made
code Page 13
5 not visited since visited array mein 5 already visited hai so no calls made
code Page 14
/////////cyclic mein path remains the same ----- agar clyclic nahia hai to path 2 hote hia -- same path
nahi rehta hai
3456 wala cyclic nahi hai -- u can see the arrows too they don’t form a cycle
code Page 15
///storage 2D matrix hogi jimein cellprop ki jagah - children ke naam honge
code Page 16
////
/////////////in Formlula.js
//// agar graph cyclic nikla to addChild wale relationship ko break bhi karna
padega
code Page 17
Initial dependency of all false
Sab 1 ke through visit nahi honge --> as done in eg 7,8,9 alag component that
was not visited thru 1
Islei for loop from 1 to 9 to visit all nodes
//component alag alag par graph same -- any component cyclic => graph cyclic
code Page 18
Function
Step 1) Set bith vis and dfs vis true of that particular cell
Step 2) checking graph connections till the depth and checking cyclic
condition at every point
Step 3) i)dfs stack se false kardo -- jo end ke baad visited wale hai
ii)Return false if no true condition found in step 3
code Page 19
Cycle color
19 December 2023 21:54
code Page 20
//CELL COLORING
code Page 21
Main cycle point dhondo - color it light salmon
Return karte samay transparent
///////////////color done
code Page 22
Even after this no color shown
Reason -- async in JS
Jo await sirf dfscycdettrp mein hi kaam karra hai ie bas isi function mein wait hoga
Baki code to run karra hi ho
code Page 23
Jo source hia uske baad jo orange hota hai uske just pehle wala cell blue hi reh jata hai kyuki
Ab baki sare to tranparent ho jaenge handled hai par src srcc ko tranparent karne keliey end mein bhi tenasparent lagana
padega
code Page 24
Excel clone - sheet
20 December 2023 20:32
Data isolation:
Ek bara array bano jismein har ek sheet ki data push hoti jae (Data -> 2 matrix)
code Page 25
Create a function that creates sheet dbs and adds sheet db to this big sheet db
//ALAG ALAG SHEET KELIYE alag alag DBD create ki --- alag graph matrix bhi create karni
hogi
1) Make a function
2) Access cell via [][]
3) Click on all cells
code Page 26
//ek sheet by default -- dikhni chaie
code Page 27
Now remove sheet ui and show default sheet ie sheet 1
Sheet rmove ke baad indexing bhi sahi karni padegi 1,2,3 -> 2 removed -> now rearrage
1 ,3 as 1,2
code Page 28
Excel clone - cut copy paste upload download
21 December 2023 11:09
2) Selecting range
code Page 29
vii) Fix ui -> add border
viii) Get the rid, cid of the cell - push it in range storage
3) Range length wala point improve karke -> agar karoge to 2 karoge varna -> karogehi nhai
Since baar baar different range select ho sakte hai
If more than 2 selected -> remove the previous 2 from the storage
Function -> when 3rd cell is selected autimatically -> 2 cells earlier -> remove selected ->empty range
storage
/////pasting
code Page 30
1) Select button - add a click listener
2) Calc row difference and col difference
3) Take target address via address bar
4) Implement a loop for pasting data
5) Access the cell + apply constraint -> agar cell limit over to return karo
6) sheetDB change karo by taking info from copyDB
7) Change the data in sheetDB [since new cell mein data jara hai]
8) Cellprop mein value etc copy karo from copyDB [yahi cells ka sara data copy hora hai]
9) UI change -> simply click since cell pe click listner hai in cellsprop.js that changes the ui
according to cell properties in db on click
Improvement in copy
-> start hote hi make a new copy[] so that har baar click hone pe it gets empty and only new info
exists
-> copy only when a range is given
///cut
1) Same paste wala loop chalake Access each cell
2) Then set all cellprop to default
3) Click to make ui changes
4) Remove green box via defaultSelectedCellsUI
code Page 31
code Page 32
Excel clone open save
21 December 2023 18:06
//BLOB() -> search online FILE JESI DATA iske through download upload etc karna is easy
// similarly google how to read a file in javascript for upload wala task
code Page 33