-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I added argument -s Sheetname #9
Comments
Hi @kshji - if you submit this as a pull request I'd be very happy to review and merge it to the codebase. I don't know your background, but if you need help with the Pull Request process let me know. |
I have updated only my own github using git. Not yet pull for others. So short howto list of git commands to pull my version main.go could be helpful. Current version using csv writer and output is not so nice, because input already include quote chars around strings, csv.writer is not the best answer. Before csv.writer need to remove 1st and last " and then give string to the csv.writer would be nicer result. main_test.go fails with current version. Also parameter listed with comma in function call is not so nice to add new parameters, need always update function call. Maybe using some structured flag would be more stable version for function call. package main
import (
"flag"
"fmt"
)
type MyConfig struct {
xlsxPath string
sheetIndex int
sheetName string
delimiter string
}
func main() {
myParam := new(MyConfig)
flag.StringVar(&myParam.xlsxPath,"f", "", "Path to an XLSX file")
flag.IntVar(&myParam.sheetIndex,"i", 0, "Index of sheet to convert, zero based")
flag.StringVar(&myParam.sheetName,"s", "", "Name of sheet to convert")
flag.StringVar(&myParam.delimiter,"d", ";", "Delimiter to use between fields")
flag.Parse()
someFunction(*myParam) // using struct
}
func someFunction(Param MyConfig) {
fmt.Println(Param)
fmt.Println("xlsxPath",Param.xlsxPath)
fmt.Println("sheetIndex",Param.sheetIndex)
fmt.Println("sheetName",Param.sheetName)
fmt.Println("delimiter",Param.delimiter)
} Using Sheetname need only add // or like to use sheet name ?
if sheetName != "" {
sheet2, ok := xlFile.Sheet[sheetName]
if ok != true {
return errors.New("This XLSX file contains not named sheet.")
}
sheet=sheet2
} |
Sometimes it's easiert to make order to convert using Sheetname. Added param sheetName. Added open sheet using SheetName if not empty string.
The text was updated successfully, but these errors were encountered: