csv2worksheet [ -f filename ] [ { -e | -n } sheet ] [ -d deliminator ] [ -o [ col ] , [ row ] ] [ -s cols ]
An Excel spreadsheet, also known as workbook, consists of one or more sheets, also known as worksheets. This worksheets are represented as named tabs in a workbook. With csv2worksheet it is possible to load a file that is structured into rows and the rows consist of fields separated by a deliminator into a worksheet. The row field separator defaults to ; but can be specified with the -d option.
This is an easy method to automatically create "nice looking" Excel reports based on plain ASCII data without the need to create Excel makros or to develop hard to maintain programs that create the whole Excel sheet on the fly. The idea is to load the data into a separate "data" worksheet and to perform the calculations, graphical data representation, statistics etc. in an other worksheet in the same Excel workbook which is not affected by the data load.
The advantage of this method is, that reports can be generated automatically without manual intervention (except the generation of the initial Excel sheet) even on non Windows systems, such as Unix or Linux.
It is possible to specify the name on an existing worksheet or to create a new worksheet while loading the data, dependent on your requirements.
However, the csv2worksheet command cannot overwrite existing data in a worksheet.
The origin of the data load can be specified. This does mean that data does not need to be loaded into a worksheet starting in cell A:1, a different cell can be specified. This enables the user to load multiple CSV data into the same worksheet as long as the data is loaded into ascending areas of an empty worksheet range.
The following examples are allowed specifications: -o 3,8 (start at cell C:8), -o ,8 (start at cell A:8), -o 3, (start at cell C:1), -o , (start at cell A:1).
Load file data.csv into the existing worksheet 'current' of file statistics.xlsx
[ h:\dat\exports ] [ fred@acme007 ][*wtshell*/cmd]: type data.csv | ^ csv2worksheet -f statistics.xlsx ^ -e current csv2worksheet - load a CSV file into an Excel sheet, by Chr. Walther load data ... sheet 'statistics.xlsx/current' opened. load origin is '1,1'. data deliminator is ';'. explicit text columns are ''. load rows ... 1 ....................................(36) 2 ....................................(36) 3 ....................................(36) 4 ....................................(36) 5 ...............(15) 6 ....................................(36) 7 ....................................(36) 8 ....................................(36) 9 .............................(29) 10 ....................................(36) done. done.
Load file data.csv into the new worksheet 'Date=01.08.2019' of file statistics.xlsx starting in cell C:5 using 'input redirection' instead of a pipe
[ h:\dat\exports ] [ fred@acme007 ][*wtshell*/cmd]: csv2worksheet < data.csv ^ -f statistics.xlsx ^ -n Date=%DATE% -o 3,5 csv2worksheet - load a CSV file into an Excel sheet, by Chr. Walther load data ... sheet 'statistics.xlsx/Date=01.08.2019' created. load origin is '3,5'. data deliminator is ';'. explicit text columns are ''. load rows ... 5 ....................................(36) 6 ....................................(36) 7 ....................................(36) 8 ....................................(36) 9 ...............(15) 10 ....................................(36) 11 ....................................(36) 12 ....................................(36) 13 .............................(29) 14 ....................................(36) done. done.
Load data into the existing worksheet 'DATA' of file io.xlsx using the 'in here' mechanism
[ h:\dat\exports ] [ fred@acme007 ][*wtshell*/cmd]: echo NAME;MIN;MAX^ More? More? alpha;100;200^ More? More? bravo;150;250^ More? More? charly;155;400 | csv2worksheet csv2worksheet - load a CSV file into an Excel sheet, by Chr. Walther load data ... sheet 'io.xlsx/DATA' opened. load origin is '1,1'. data deliminator is ';'. explicit text columns are ''. load rows ... 1 ...(3) 2 ...(3) 3 ...(3) 4 ...(3) done. done.
Set a single cell ( E:20 ) of an existing worksheet 'DATA' of file io.xlsx
[ h:\dat\exports ] [ fred@acme007 ][*wtshell*/cmd]: echo Load at: %DATE% | ^ csv2worksheet -o 5,20 csv2worksheet - load a CSV file into an Excel sheet, by Chr. Walther load data ... sheet 'io.xlsx/DATA' opened. load origin is '5,20'. data deliminator is ';'. explicit text columns are ''. load rows ... 20 .(1) done. done.
Load data into the existing worksheet 'DATA' of file io.xlsx using the 'in here' mechanism and explicitly load the columns 4 and 5 (of the input) as text into the worksheet.
[ h:\dat\exports ] [ fred@acme007 ][*wtshell*/cmd]: type b.csv NAME;MIN;MAX;SERIAL;PHONE alpha;100;200;2009063009250001;080007121941 bravo;150;250;2009063009250002;080006061944 charly;155;400;2009063009250003;080020071969
[ h:\dat\exports ] [ fred@acme007 ][*wtshell*/cmd]: type b.csv | csv2worksheet -s 4,5 csv2worksheet - load a CSV file into an Excel sheet, by Chr. Walther load data ... sheet 'io.xlsx/DATA' opened. load origin is '1,1'. data deliminator is ';'. explicit text columns are '4,5'. load rows ... 1 .....(3) 2 .....(3) 3 .....(3) 4 .....(3) done. done.
csv2worksheet uses "Jakarta POI - Java API To Access Microsoft Format Files " of the Apache Jakarta project. See http://jakarta.apache.org/poi/ for more information about the progress of the implementation.
Therefore if still jobs are present that operate with *.xls files, convert this files to *.xlsx.
This is free software; see WA2LWinTools/man/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.