| ... | ... |
@@ -11,11 +11,11 @@ license below), you may download the binary. |
| 11 | 11 |
|
| 12 | 12 |
Here are the SHA-256 checksums for the binaries: |
| 13 | 13 |
|
| 14 |
- 9cd013ac244c0d364302da1eab724ea93831f6088188bcaaae08545f00a4582a csv2xlsx_386.exe |
|
| 15 |
- 535c3937447497bd0769296d434c809b41e1ead7bc463f560888ec51cfb95794 csv2xlsx_amd64.exe |
|
| 16 |
- d491329c16f44d82c6d50bb4afa74bd704f25ade7e93b28d0ec0b747648c9a6e csv2xlsx_linux_386 |
|
| 17 |
- cfa63a9eb6ab4d9c418afe95cf54524b32611a01d970e95ed57831b1368406f1 csv2xlsx_linux_amd64 |
|
| 18 |
- daa9ff8f2ccb49b6ccf4fd7d7b600011a8bd4ba9fe1b3870ce15dcbbe6fa1092 csv2xlsx_osx |
|
| 14 |
+ 86fab8cdb756d612391bdfca36641414424cb0cfe7c9c196329124976f3d3a8c csv2xlsx_386.exe |
|
| 15 |
+ 91b94bb4c0acf91bcd2b3874d7ab7f96e204e6c0acb1d0119694bb740dedb6f4 csv2xlsx_amd64.exe |
|
| 16 |
+ d1b3dc8bfa72647f4e92dbafede0ee729ccb488a7b2a400304634bf03439b744 csv2xlsx_linux_386 |
|
| 17 |
+ 3e8661e7ef681c796452736e9004f19653ccf01c916f3c6a8b1e67d99f1e0ab5 csv2xlsx_linux_amd64 |
|
| 18 |
+ 2933cdca783beca8fbcfccc2d396f4ec115c898a9f69680d6c64806ac84e1804 csv2xlsx_osx |
|
| 19 | 19 |
|
| 20 | 20 |
### Usage |
| 21 | 21 |
|
| ... | ... |
@@ -44,6 +44,8 @@ Please see below for a list of command line options. |
| 44 | 44 |
-filemask |
| 45 | 45 |
bulk mode, specify a file mask here (e.g. "/use/docs/datalib/2018*.csv") |
| 46 | 46 |
make sure to quote the filespace to prevent shell globbing |
| 47 |
+ -headerlines |
|
| 48 |
+ specify number of header lines in the CSV file (default is 1, use 0 fpr no header) |
|
| 47 | 49 |
-h |
| 48 | 50 |
-help |
| 49 | 51 |
display usage information |
| ... | ... |
@@ -60,7 +62,7 @@ Please see below for a list of command line options. |
| 60 | 62 |
-silent |
| 61 | 63 |
do not display progress messages |
| 62 | 64 |
-noheader |
| 63 |
- do not use the first line as header (default is Yes) |
|
| 65 |
+ do not use the first line as header (DEPRECATED, use headerlines option instaead) |
|
| 64 | 66 |
|
| 65 | 67 |
Column ranges are a comma-separated list of numbers (e.g. 1,4,8,16), intervals (e.g. 0-4,18-32) or a combination. |
| 66 | 68 |
Each comma group can take a type specifiers for the column, |
| ... | ... |
@@ -27,6 +27,9 @@ var ( |
| 27 | 27 |
parmOutDir string |
| 28 | 28 |
parmFileMask string |
| 29 | 29 |
parmEncoding string |
| 30 |
+ parmHeaderLines int |
|
| 31 |
+ parmFontSize int |
|
| 32 |
+ parmFontName string |
|
| 30 | 33 |
parmColSep rune |
| 31 | 34 |
parmDateFormat string |
| 32 | 35 |
parmExcelDateFormat string |
| ... | ... |
@@ -144,9 +147,12 @@ func parseCommandLine() {
|
| 144 | 147 |
flag.StringVar(&parmSheet, "sheet", "fromCSV", "tab name of the Excel sheet") |
| 145 | 148 |
flag.StringVar(&tmpStr, "colsep", "|", "column separator (default '|') ") |
| 146 | 149 |
flag.StringVar(&parmEncoding, "encoding", "utf-8", "character encoding") |
| 150 |
+ flag.StringVar(&parmFontName, "fontname", "Arial", "set the font name to use") |
|
| 151 |
+ flag.IntVar(&parmFontSize, "fontsize", 12, "set the default font size to use") |
|
| 152 |
+ flag.IntVar(&parmHeaderLines, "headerlines", 1, "set the number of header lines (use 0 for no header)") |
|
| 147 | 153 |
// not settable with csv reader |
| 148 | 154 |
//flag.StringVar(&parmRowSep, "rowsep", "\n", "row separator (default LF) ") |
| 149 |
- flag.BoolVar(&parmNoHeader, "noheader", false, "no headers in first line, only data lines (default false)") |
|
| 155 |
+ flag.BoolVar(&parmNoHeader, "noheader", false, "DEPRECATED (use headerlines) no header, only data lines") |
|
| 150 | 156 |
flag.BoolVar(&parmAbortOnError, "abortonerror", false, "abort program on first invalid cell data type") |
| 151 | 157 |
flag.BoolVar(&parmSilent, "silent", false, "do not display progress messages") |
| 152 | 158 |
flag.BoolVar(&parmAutoFormula, "autoformula", false, "automatically format string starting with = as formulae") |
| ... | ... |
@@ -402,7 +408,8 @@ func processDataColumns(excelRow *xlsx.Row, rownum int, csvLine []string) {
|
| 402 | 408 |
colType, processColumn := colRangeParsed[colnum] |
| 403 | 409 |
if processColumn {
|
| 404 | 410 |
cell := excelRow.AddCell() |
| 405 |
- if rownum == 0 && !parmNoHeader {
|
|
| 411 |
+ isHeader := (parmHeaderLines > 0) || !parmNoHeader |
|
| 412 |
+ if isHeader && (rownum <= parmHeaderLines) {
|
|
| 406 | 413 |
// special case for the title row |
| 407 | 414 |
cell.SetString(csvLine[colnum]) |
| 408 | 415 |
if colType == "number" || colType == "currency" {
|
| ... | ... |
@@ -435,6 +442,9 @@ func getInputFiles(inFileSpec string) []string {
|
| 435 | 442 |
// return a string with the target file name |
| 436 | 443 |
func buildOutputName(infile string) string {
|
| 437 | 444 |
outfile := strings.TrimSuffix(infile, filepath.Ext(infile)) + ".xlsx" |
| 445 |
+ if parmOutFile != "" {
|
|
| 446 |
+ outfile = parmOutFile |
|
| 447 |
+ } |
|
| 438 | 448 |
if parmOutDir != "" {
|
| 439 | 449 |
if _, err := os.Stat(parmOutDir); err == nil {
|
| 440 | 450 |
outfile = filepath.Join(parmOutDir, filepath.Base(outfile)) |
| ... | ... |
@@ -452,6 +462,7 @@ func convertFile(infile, outfile string) {
|
| 452 | 462 |
setRangeInformation(len(rows), len(rows[0])) |
| 453 | 463 |
|
| 454 | 464 |
// excel stuff, create file, add worksheet, define a right-aligned style |
| 465 |
+ xlsx.SetDefaultFont(parmFontSize, parmFontName) |
|
| 455 | 466 |
workBook = xlsx.NewFile() |
| 456 | 467 |
workSheet, _ = workBook.AddSheet(parmSheet) |
| 457 | 468 |
rightAligned = &xlsx.Style{}
|