{"id":15640617,"url":"https://github.com/noborus/xlsxsql","last_synced_at":"2025-04-19T13:48:55.182Z","repository":{"id":204828215,"uuid":"710174394","full_name":"noborus/xlsxsql","owner":"noborus","description":"A CLI tool that executes SQL queries on various files including xlsx files and outputs the results to various files","archived":false,"fork":false,"pushed_at":"2024-01-10T23:40:55.000Z","size":132,"stargazers_count":74,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-01-11T01:04:50.794Z","etag":null,"topics":["excel","sql","trdsql","xlsx"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noborus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-26T07:05:47.000Z","updated_at":"2024-04-15T00:34:41.154Z","dependencies_parsed_at":"2023-11-11T05:33:14.401Z","dependency_job_id":"1b02d811-fd2c-408b-bfe4-15ddcc21c756","html_url":"https://github.com/noborus/xlsxsql","commit_stats":null,"previous_names":["noborus/xlsxsql"],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fxlsxsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fxlsxsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fxlsxsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fxlsxsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noborus","download_url":"https://codeload.github.com/noborus/xlsxsql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249707106,"owners_count":21313769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["excel","sql","trdsql","xlsx"],"created_at":"2024-10-03T11:38:44.817Z","updated_at":"2025-04-19T13:48:55.165Z","avatar_url":"https://github.com/noborus.png","language":"Go","readme":"# xlsxsql\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/noborus/xlsxsql)](https://pkg.go.dev/github.com/noborus/xlsxsql)\n[![Actions Status](https://github.com/noborus/xlsxsql/workflows/Go/badge.svg)](https://github.com/noborus/xlsxsql/actions)\n\nA CLI tool that executes SQL queries on various files including xlsx files and outputs the results to various files.\n\n![xlsxsql query -H -o md \"SELECT a.id,a.name,b.price FROM testdata/test3.xlsx::.C1 AS a LEFT JOIN testdata/test3.xlsx::.F4 AS b ON a.id=b.id\"](docs/xlsxsql.png)\n\n| id |  name  | price |\n|----|--------|-------|\n|  1 | apple  |   100 |\n|  2 | orange |    50 |\n|  3 | melon  |   500 |\n\nA CLI tool that executes SQL queries on xlsx files and outputs the results to various files, and also executes SQL queries on various files and outputs them to xlsx files.\nBuilt using [excelize](https://github.com/qax-os/excelize) and [trdsql](https://github.com/noborus/trdsql).\n\n## Install\n\n### Go install\n\n```console\ngo install github.com/noborus/xlsxsql/cmd/xlsxsql@latest\n```\n\n### Homebrew\n\nYou can install Homebrew's xlsxsql with the following command:\n\n```console\nbrew install noborus/tap/xlsxsql\n```\n\n### Binary Downloads\n\nPrecompiled binaries for xlsxsql are available for various platforms and architectures. You can download them from the [GitHub Releases](https://github.com/noborus/xlsxsql/releases) page.\n\nThe following binaries can be downloaded from release.\n\n- Darwin_arm64\n- Darwin_x86_64\n- Linux_arm64\n- Linux_i386\n- Linux_x86_64\n- Windows_arm64\n- Windows_x86_64\n\nTo install a binary, download the appropriate file for your system, extract it, and place the `xlsxsql` executable in a directory included in your system's `PATH`.\n\nFor example, on a Unix-like system, you might do:\n\n```console\ntar xvf xlsxsql_Darwin_x86_64.tar.gz\nmv xlsxsql /usr/local/bin/\n```\n\n## Usage\n\n```console\n$ xlsxsql --help\nExecute SQL against xlsx file.\nOutput to CSV and various formats.\n\nUsage:\n  xlsxsql [flags]\n  xlsxsql [command]\n\nAvailable Commands:\n  completion  Generate the autocompletion script for the specified shell\n  help        Help about any command\n  list        List the sheets of the xlsx file\n  query       Executes the specified SQL query against the xlsx file\n  table       SQL(SELECT * FROM table) for xlsx\n\nFlags:\n      --clear-sheet        Clear sheet when outputting to xlsx file\n      --debug              debug mode\n  -H, --header             Input header\n  -h, --help               help for xlsxsql\n  -o, --out string         Output Format[CSV|AT|LTSV|JSON|JSONL|TBLN|RAW|MD|VF|YAML|XLSX] (default \"GUESS\")\n      --out-cell string    Cell name to output to xlsx file\n  -O, --out-file string    File name to output to file\n      --out-header         Output header\n      --out-sheet string   Sheet name to output to xlsx file\n  -s, --skip int           Skip the number of lines\n  -v, --version            display version information\n\nUse \"xlsxsql [command] --help\" for more information about a command.\n```\n\n### List sheets\n\n```console\n$ xlsxsql list test.xlsx\nSheet1\nSheet2\n```\n\n### Basic usage\n\nThe basic usage of xlsxsql is to run a SQL query against an Excel file.\nThe `query` command is used followed by the SQL query in quotes.\nThe SQL query should include the name of the Excel file. If no sheet is specified, the first sheet will be targeted.\n\n```console\nxlsxsql query \"SELECT * FROM test.xlsx\"\n```\n\nFor example, if test.xlsx contains the following data in its first sheet:\n\n| Name  | Age |\n| ----- | --- |\n| Alice | 20  |\n| Bob   | 25  |\n| Carol | 30  |\n\nThe output will be:\n\n```csv\nName,Age\nAlice,20\nBob,25\nCarol,30\n```\n\n`xlsxsql` is an extended version of [trdsql](https://github.com/noborus/trdsql),\nso you can execute SQL on files such as CSV and JSON.\n\n```console\nxlsxsql query \"SELECT * FROM test.csv\"\n```\n\nIn other words, you can also do CSV and JOIN.\n\n```console\nxlsxsql query -H -o md \\\n\"SELECT a.id,a.name,b.price \n  FROM testdata/test3.xlsx::.C1 AS a\n  LEFT JOIN test.csv AS b \n    ON a.id=b.id\"\n```\n\n### Specify sheet\n\nThe sheet can be specified by using a double colon \"::\" after the file name\n(the first sheet is selected by default if not specified).\n\n```console\nxlsxsql query \"SELECT * FROM test.xlsx::Sheet2\"\n```\n\n### Specify cell\n\nCell can be specified by using a dot \".\" after the sheet.\n\n```console\nxlsxsql query \"SELECT * FROM test3.xlsx::Sheet1.C1\"\n```\n\nOptional if the sheet is the first sheet.\n\n```console\nxlsxsql query \"SELECT * FROM test3.xlsx::.C1\"\n```\n\n\u003e [!NOTE]\n\u003e If cell is specified, the table up to the blank column is considered to be the table.\n​\nThis allows multiple tables to be specified on one sheet, and JOIN is also possible.\n\n```console\nxlsxsql query -H -o md \\\n\"SELECT a.id,a.name,b.price \n  FROM testdata/test3.xlsx::.C1 AS a\n  LEFT JOIN testdata/test3.xlsx::.F4 AS b \n    ON a.id=b.id\"\n```\n\n### Shorthand designation\n\nThe `table` command is a shorthand that allows you to quickly display the contents of a specified sheet in a table format.\nThe syntax is `xlsxsql table \u003cfilename\u003e::\u003csheetname\u003e.\u003ccellname\u003e`.\nIf no sheet name is specified, the first sheet of the Excel file will be targeted.\n\nHere is an example:\n\n```console\nxlsxsql table test.xlsx::Sheet2.C1\n```\n\nIt can be omitted for the first sheet.\n\n```console\nxlsxsql table test.xlsx::.C1\n```\n\n### Skip Options\n\nThe `--skip` or `-s` option skips the specified number of lines.\nFor example, you would use it like this:\n\n```console\nxlsxsql query --skip 1 \"SELECT * FROM test.xlsx::Sheet2\"\n```\n\nSkip is useful when specifying sheets, allowing you to skip unnecessary rows.\n(There seems to be no advantage to using skip when specifying Cell.)\n\n### Output format\n\n```console\nxlsxsql query --out JSONL \"SELECT * FROM test.xlsx::Sheet2\"\n```\n\nYou can choose from CSV, LTSV, JSON, JSONL, TBLN, RAW, MD, VF, YAML, (XLSX).\n\n### Output to xlsx file\n\nYou can output the result to an xlsx file by specifying a file name with the `.xlsx` extension as the `--out-file` option. For example:\n\n```console\nxlsxsql query --out-file test2.xlsx \"SELECT * FROM test.xlsx::Sheet2\"\n```\n\n\u003e [!NOTE]\n\u003e You can also output to the same xlsx file as the input file. Please be careful as the contents will be overwritten.\n\n\u003e [!NOTE]\n\u003e Even if you specify XLSX with --out, you must specify a file name with the extension `.xlsx`.\n\nThis command will execute the SQL query on the Sheet1 of test.xlsx and output the result to result.xlsx.\nIf the file does not exist, it will be created. If the file already exists, the results will be updated.\n\nYou can specify the `sheet` and `cell` to output, if you want to output to an xlsx file. For example:\n\n```console\nxlsxsql query --out-file test2.xlsx --out-sheet Sheet2 --out-cell C1 \"SELECT * FROM test.xlsx::Sheet2\"\n```\n\nYou can clear the sheet before outputting to an xlsx file by specifying the `--clear-sheet` option. For example:\n\n```console\nxlsxsql query --out-file test2.xlsx --clear-sheet \"SELECT * FROM test.xlsx::Sheet2\"\n```\n\n### Multiple queries\n\nIt is also possible to output after executing an update query.\nA SELECT query is required for output.\n\n```console\nxlsxsql query --header --out-header --out-file test.xlsx --out-sheet Sheet2 \\\n\"UPDATE test.xlsx SET Age=Age+1 WHERE Name='Alice';\n SELECT * FROM test.xlsx\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoborus%2Fxlsxsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoborus%2Fxlsxsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoborus%2Fxlsxsql/lists"}