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" "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 sql []string
// var pathSite []string // var pathSite []string
@ -25,18 +25,9 @@ func ReadExcel(path string)[]map[string]string {
fmt.Println(err) 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 // Nom de la feuille
sheetName := "julien" sheetName := sheetSelect
// Obtenir toutes les lignes // Obtenir toutes les lignes
rows, err := f.GetRows(sheetName) rows, err := f.GetRows(sheetName)

11
main.go
View File

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