ExcelDumperTool is a lightweight C# console application designed to read Excel (.xlsx) files and dump the contents of a specific worksheet to the console (or a text file) in a structured, plain-text format.
This tool is particularly useful for AI agents or automated pipelines that need to read and parse Excel files without requiring complex programmatic interactions with Excel interop or UI applications.
- .NET SDK (Version 8.0 or compatible)
You can run this tool using the .NET CLI. The tool requires two arguments:
- Absolute path to the Excel file.
- Sheet identifier, which can be either the
Index(0-based) or aKeyword/Namecontained within the sheet's name.
dotnet run --project "<ABSOLUTE_PATH_TO_EXCEL_DUMPER_TOOL>" -- <path_to_excel_file> <sheet_index_or_keyword>Assuming your terminal is working within the ExcelDumperTool directory:
To read a sheet that contains the name "Thêm nhóm hàng hóa" (Add Product Group), pass a keyword:
dotnet run -- product-group-management.xlsx "Thêm nhóm"To read a specific sheet by its 0-based index instead of its name:
# Read the first sheet
dotnet run -- product-group-management.xlsx 0
# Read the second sheet
dotnet run -- product-group-management.xlsx 1To automatically iterate through and dump all sheets in the Excel file, use the keyword all:
dotnet run -- product-group-management.xlsx allNote: The output of each sheet will be separated by the header --- DUMPING SHEET: Sheet Name --- for easier AI parsing.
If you want to save the dumped data into a text file instead of printing it to the console, use the > redirect operator:
dotnet run -- "D:\path\to\your\file.xlsx" 0 > output.txtIf your terminal is located outside the ExcelDumperTool folder (e.g., in the parent project directory), you must specify the project path:
dotnet run --project ".\ExcelDumperTool" -- "D:\path\to\your\file.xlsx" 0If you are working inside your main test project directory (e.g. TestProductGroup) and want to dump all sheets into a single text file using an absolute path, use the full project path:
dotnet run --project "<ABSOLUTE_PATH_TO_EXCEL_DUMPER_TOOL>" -- "<ABSOLUTE_PATH_TO_EXCEL_FILE>" all > all_sheets_output.txtThe tool will automatically detect the used range of columns and rows dynamically. It will also strip empty trailing columns. Down-lines (Alt+Enter) within Excel cells are preserved and represented as \n characters in the output.
Example output:
--- DUMPING SHEET: Sheet1 ---
R001: [Header 1] [Header 2]
R002: [Data A] [Data B\nMulti-line here]