on edit copy values to another sheet dynamically google sheets

To copy values from one sheet to another dynamically in Google Sheets using the Go language, you can follow these steps:

  1. Import the necessary packages:
import (
    "fmt"
    "log"

    "github.com/360EntSecGroup-Skylar/excelize/v2"
)
  1. Open the source workbook:
srcFile, err := excelize.OpenFile("source.xlsx")
if err != nil {
    log.Fatal(err)
}
  1. Get the source sheet and destination sheet names:
srcSheet := "Sheet1"
destSheet := "Sheet2"
  1. Get the source sheet data:
srcData, err := srcFile.GetRows(srcSheet)
if err != nil {
    log.Fatal(err)
}
  1. Create a new destination workbook:
destFile := excelize.NewFile()
  1. Set the destination sheet as active:
destFile.SetActiveSheet(destFile.NewSheet(destSheet))
  1. Copy the source data to the destination sheet:
for rowIdx, rowData := range srcData {
    for colIdx, cellData := range rowData {
        destFile.SetCellValue(destSheet, fmt.Sprintf("%s%d", excelize.ToAlphaString(colIdx+1), rowIdx+1), cellData)
    }
}
  1. Save the destination workbook:
err = destFile.SaveAs("destination.xlsx")
if err != nil {
    log.Fatal(err)
}

This code imports the necessary packages, opens the source workbook, gets the source and destination sheet names, reads the data from the source sheet, creates a new destination workbook, sets the destination sheet as active, copies the source data to the destination sheet, and saves the destination workbook.

Make sure to replace "source.xlsx" and "destination.xlsx" with the actual file names and modify the sheet names as needed.