Command Line: Convert CSV to well formatted PDFs

Japanese translated version 日本語版

You can convert files using the command line with two distinct methods:

  [1] Using the 'Conversion Job' file (*.SII) as specified in the user interface

  [2] Using the specific command line switches for each option

Both methods have their pros and cons. The first method can be the fastest to get you going. The second method is by far more powerful and flexible, however it requires a detailed understanding of all the options and switches associated with the options.

[1] Use the 'Conversion Job' File Method

The easiest way to understand CSV to PDF conversions via the 'Convert XLS' command line is to first familiarize yourself with the process in the application's user interface. The first command-line approach utilizes a "conversion job" file, which stores your GUI-defined settings. To use this method, complete the following steps:

1.  See and follow "How to convert CSV to a a well formatted PDF file with 'Convert XLS' user interface"

2.  Once you've perfected the 'conversion job' within the user interface, go to the File\Save As\ menu item and save the conversion job. Save the 'conversion job' to: C:\In\CSV-to-PDF-Conversion-Job.SII

3. Create your command line using the /J switch, which points to the newly created 'conversion job' file.

 

ConvertXLS.exe  /J "C:\In\CSV-to-PDF-Conversion-Job.SII"  /V

 

/J{ConversionJobFile} is the fully qualified path of the 'conversion job' file previously created within the graphical user interface.

[/V] OPTIONAL: Verbose mode. Specify this switch to display a message box indicating success or failure after the job has run. If a failure occurred a reason is usually displayed. See also /L.

[/L{LogFile}] OPTIONAL: Log file path and name (e.g. d:\mylogs\MoreInfo.LOG). If this switch is specified a log file with the given path and name will be created and the results of the conversion will be written to it. See also /V.  

 

[2] Use option specific command line switches

QUICK START: After installation of 'Convert XLS', you can try this out by using this command line:

%appdata%\Softinterface, Inc\Convert XLS\Demo Batch Files\CSVtoPDF.bat

The basic structure of this batch file consists of 3 command lines, each performing a specific task, in a specific order. Each step is explained in detail below.

REM Step 1. Clear out contents of template.xlsx
  ConvertXLS.exe /S"C:\In\template.xlsx" /T"C:\In\template.xlsx" /P112 /1 2 /2 1 /3 A2:D100000 /V
REM Step 2. Copy contents to template.xlsx
  ConvertXLS.exe /S"C:\in\input.csv" /T"C:\In\template.xlsx" /P101 /1 1 /2 0 /4 TRUE /5 A2:D100000 /6 1 /7 /8 A2 /V
REM Step 3. Convert template.xlsx to output.pdf
  ConvertXLS.exe /S"C:\in\template.xlsx" /T"C:\In\output.pdf" /M1 /C-1 /V


Step 1: Clear out contents of template.xlsx
Clearing out the contents of the template.xlsx file allows for new data to be placed in it. Not clearing it out may result in old data being shown. For this we use 'Convert XLS' Special Process 112.

ConvertXLS.exe /S"C:\In\template.xlsx" /T"C:\In\template.xlsx" /P112 /1 2 /2 1 /3 A2:D100000 /V

/S = Input file  (C:\In\template.xlsx)
/T = Output file (C:\In\template.xlsx)
/P112 = Specify special process 112
/1 2 =  Specify what to clear: 2 = Clear CONTENTS
/2 1 =  Specify Sheet to clear. In this case we are doing the first sheet
/3 A2:D100000  = Range to clear
/V  Used for "V"erbose response. When Verbose switch is used, the app will tell you how the process went with pop up dialog boxes. You can remove this, as it is optional.


Step 2. Copy contents to template.xlsx

Copy the contents of the csv file into the template using 'Convert XLS' Special Process 101.

 

  ConvertXLS.exe /S"C:\in\input.csv" /T"C:\In\template.xlsx" /P101 /1 1 /2 0 /4 TRUE /5 A2:D100000 /6 1 /7 TRUE /8 A2 /V

 

/S = Input file  (C:\In\input.csv)
/T = Output file (C:\In\template.xlsx)
/P101 = Specify special process 101
/1 1 =  Specify what sheet to copy. Note: Normally this special process is used to copy from Excel workbook to Excel workbook.
/2 0 =  Specify what to copy. /2 0 = copy VALUES
/4 TRUE = Copy from specified range = TRUE
/5 A2:D100000 = Range to copy from. Note we're skipping the first row which is a header row in the csv file.
/6 1 = Specify output sheet. We are specifying to copy contents to the 1st sheet.
/7 Copy to specified range is TRUE.
/8 Copy data starting at cell A2
/V  Used for "V"erbose response. When Verbose switch is used, the app will tell you how the process went with pop up dialog boxes. You can remove this, as it is optional.

 

Step 3. Convert template.xlsx to output.pdf

Convert the template.xlsx to output.pdf.

 

  ConvertXLS.exe /S"C:\in\template.xlsx" /T"C:\In\output.pdf" /M1 /C-1 /V

 

/S = Input file  (C:\in\template.xlsx)
/T = Output file (C:\In\output.pdf)
/M = Conversion method to use. /M1 = Use MS Excel in this case.
/C-1 Specify output file type, PDF.
/V  Used for "V"erbose response. When Verbose switch is used, the app will tell you how the process went with pop up dialog boxes. You can remove this, as it is optional.

Try Our Software, Download 'Convert XLS'!