For example if we have a excel sheet with tables in which we have data,
There are two sheets namely, PRESENT and DATESHEET.
In which the datesheet A1 cell consisting todays date in one format and C1 cell consisting report exported time and E1 consisting dateTime according to Database format. These three are required in our database to generate a report.
There is a requirement the report to be generated datewise format, But as we export the data from a website or database the date field is not present , so we need to export the data in a excel/csv format and we need to right a script in which the date field should be added.
suppose our data is exported to sheet namelt PRESENT ( here I have taken attendance report example)
As said earlier we have datesheet and present sheet. Now we need open a new tab/sheet in our excel file with name SCRIPT
In this script sheet we need to write the formula as stated below
=CONCATENATE("insert into daypresent(slno,office_name,today_date,report_time,db_datetime,tot_registered_emp,
tot_present) values('",$present.A4,"','",$present.B4,"','",$datesheet.$A$1,"','",
$datesheet.$C$1,"','",$datesheet.$E$1,"','",$present.C4,"','",$present.E4,"');")
Kindly observe in the above formula we are using Sheetname.Cell_reference prefixed with $ symbol. The symbol refer to that particular sheet and the specified cell. So here we are concatenating the two sheets cells in our script sheet.
Fine, after entering the formula in the first row in script sheet we can get the all records by simply dragging the cell to the rows (this is depends on our database record count). To the count we need to drag the formula.
Here is the case, The date is common for all the rows when we drag the cell formula the excel feature increment the cell value automatically we makes the next insert statement for row two . So in the next cell the formula becomes
=CONCATENATE("insert into daypresent(slno,office,tdate,rdate,rtime,regemp,present) values('",$present.A5,"','",$present.B5,"','",$datesheet.$A$1,"','",$datesheet.$C$1,"','",
$datesheet.$E$1,"','",$present.C5,"','",$present.E5,"');")
Present.A4 to Present.A5 , Present.B4 to Present.B5 ..... this is what we required but
what about the datesheet we need the same cell value for all the rows
to achieve this, we need to give $datesheet.$A$1
the cell values remains same even we drag the contents if we specify $A$1. That is the cell count wont increment