Rob van der Woude's Scripting Pages

Help text for ExtractExcel.cs

(view help text of ExtractExcel.cs as plain text)

ExtractExcel,  Version 1.04
Filter values from a source spreadsheet and write them to a target spreadsheet

Usage:   ExtractExcel /SOURCE src /TARGET tgt /COLS "cols" [ options ]

Where:   src       is the source file name and optional sheet name or index
                   (e.g. source.xlsx "Sheet 2"; default sheet index 1)
         tgt       is the target file name and optional sheet name or index
                   (e.g. target.xlsx 3; default sheet index 1; file is created
                   if it does not exist, in which case sheet will be ignored)
         cols      is a list or range of columns to be read from the source file
                   (letters, e.g. "A..D,F,AA..AG", case insensitive, mandatory
                   unless rows are specified, default if rows specified: "A..Z")

Options: /ROWS     rows      list or range of rows to be used from source file
                             (numeric, e.g. "1,3,5..8,14", default: "1..100")
         /HEADER   rows      list of (header) rows to be included regardless of
                             /ISEMPTY, /NOTEMPTY or /WHERE query match.
         /SKIP     n         skip the first n rows in source file (if /ROWS is
                             specified, increments start and end of range by n)
         /OFFSET   startrow  first row in target sheet to be written
                             (numeric, default: 1)
         /WHERE    query     filter rule, source row will be skipped if it does
                             not comply (see notes; default: do not skip)
         /ISEMPTY  columns   skip row if any of specified columns is not empty
         /NOTEMPTY columns   skip row if any of specified columns is empty

Notes:   Queries format is "column operator value/column", e.g. "A < 0", "B > C"
         or "AF != 1.5"; whitespace is allowed; columns may be up to 3 letters
         (e.g. A for column 1, AA for column 27, AAA for column 703) and must be
         in upper case!
         Avoid combining "complex" /ROWS ranges with /SKIP argument.
         Also avoid using /HEADER and /OFFSET simultaniously.
         If the source file has an extension other than ".xlsx" (e.g. ".xlsm"),
         you may be prompted that Excel is still active, even if it is not.
         Queries are interpreted by mXparser (https://mathparser.org/)
         See its tutorial at https://mathparser.org/mxparser-tutorial/ for
         details on more complex filter expressions, e.g. "(A=10)|(B<0)".
         Return code ("errorlevel") -1 in case of errors, otherwise 0.

Credits: Code to replace column by cell value by Vladimir
         https://stackoverflow.com/a/62778031
         Query parsing by mXparser
         https://mathparser.org/
         Manipulating Excel files by Microsoft.Office.Interop.Excel
         https://www.nuget.org/packages/Microsoft.Office.Interop.Excel

Written by Rob van der Woude
https://www.robvanderwoude.com

page last uploaded: 2025-10-23; loaded in 0.0046 seconds