Update code sheet

This commit is contained in:
cangui 2024-12-12 09:19:49 +01:00
parent 4d6e744c7c
commit 03a473b19d
2 changed files with 6 additions and 20 deletions

View File

@ -7,7 +7,7 @@ import (
"github.com/xuri/excelize/v2"
)
func ReadExcel(path string)[]map[string]string {
func ReadExcel(path string,sheetSelect string)[]map[string]string {
// var sql []string
// var pathSite []string
@ -25,18 +25,9 @@ func ReadExcel(path string)[]map[string]string {
fmt.Println(err)
}
}()
// Get value from cell by given worksheet name and cell reference.
cell, err := f.GetCellValue("julien", "A2")
if err != nil {
fmt.Println(err)
return nil
}
fmt.Println("-------------------------------------")
fmt.Println(cell)
fmt.Println("-------------------------------------")
// Get all the rows in the Sheet1.
// Nom de la feuille
sheetName := "julien"
sheetName := sheetSelect
// Obtenir toutes les lignes
rows, err := f.GetRows(sheetName)

11
main.go
View File

@ -6,9 +6,7 @@ import (
"log"
"os"
"strings"
"time"
"canguidev.fr/pvnet/function"
simplyssh "canguidev.fr/pvnet/simply-ssh"
"github.com/TwiN/go-choice"
@ -17,13 +15,10 @@ import (
)
func main() {
//var path string="/Users/cangui/.ssh/julien_pvnet"
///Users/cangui/Documents/Dev peso/Golang dev/test.xlsx
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
var pathSsh string = os.Getenv("PATH_SSH")
var pathConfigSsh = os.Getenv("PATH_SSH_CONF")
var pathExcel string = os.Getenv("PATH_FOLDER")
@ -31,7 +26,7 @@ func main() {
var mysqlPswd string
var pathSaveSql string
var nameBase string
var sheetSelect string=os.Getenv("SHEET_SELECT")
// Chargement de la liste des hosts du fichier config ssh
d := simplyssh.GetHost(pathConfigSsh)
var s []string
@ -41,7 +36,7 @@ func main() {
}
// selectionne du host
choice, index, err := gochoice.Pick(
"What do you want to do?\nPick:",
"Sélectionner un vhost de connection?\nChoix:",
s,
)
selectHost := choice
@ -87,7 +82,7 @@ func main() {
return
}
if index == 0 {
excel := function.ReadExcel(pathExcel)
excel := function.ReadExcel(pathExcel,sheetSelect)
// Parcourir les résultats d'Excel
for _, value := range excel {
sessionBackup, err := client.NewSession()