ターミナルでスプレッドシートを閲覧するvex-tuiを使ってみる

はじめに

ターミナルでの作業中、ちょっとしたExcelやCSVファイルを確認したいときがある。
しかしGUIのExcelを起動するのは少し大げさだし、単純なテキストエディタでは構造が見にくい。

そんな中、TUIで操作できるvex-tuiというものを見つけたので使ってみる。
ターミナル上で動作し、Vimライクなキーバインドで操作できるスプレッドシートビューアーとなっている。
複数シートの切り替え、検索、データの視覚化など、閲覧に便利な機能を備えている。

環境

Ubuntu 24.04 LTS
Go 1.23.5
vex-tui v1.1.1

インストール

Goがインストールされていれば、go installコマンドで簡単にインストールできる。

go install github.com/CodeOne45/vex-tui@latest
ログ
go: downloading github.com/CodeOne45/vex-tui v1.1.1
go: github.com/CodeOne45/[email protected] requires go >= 1.25; switching to go1.25.6
go: downloading go1.25.6 (linux/amd64)
go: downloading github.com/charmbracelet/bubbles v0.18.0
go: downloading github.com/xuri/excelize/v2 v2.8.0
go: downloading github.com/charmbracelet/lipgloss v0.9.1
go: downloading github.com/charmbracelet/bubbletea v0.25.0
go: downloading github.com/atotto/clipboard v0.1.4
go: downloading github.com/muesli/termenv v0.15.2
go: downloading github.com/muesli/reflow v0.3.0
go: downloading github.com/mattn/go-runewidth v0.0.15
go: downloading github.com/rivo/uniseg v0.4.6
go: downloading github.com/mattn/go-localereader v0.0.1
go: downloading github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81
go: downloading github.com/muesli/cancelreader v0.2.2
go: downloading golang.org/x/sync v0.1.0
go: downloading github.com/mattn/go-isatty v0.0.18
go: downloading github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b
go: downloading golang.org/x/term v0.11.0
go: downloading github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
go: downloading golang.org/x/net v0.14.0
go: downloading github.com/xuri/nfp v0.0.0-20230819163627-dc951e3ffe1a
go: downloading golang.org/x/crypto v0.12.0
go: downloading github.com/richardlehane/mscfb v1.0.4
go: downloading golang.org/x/text v0.12.0
go: downloading github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading golang.org/x/sys v0.12.0
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading github.com/richardlehane/msoleps v1.0.3

バイナリを直接ダウンロードする場合は、GitHubのリリースページから各プラットフォーム向けのバイナリを入手できる。

# バイナリが正しくインストールされたか確認
vex-tui --version
ログ
vex-tui --version
vex version 1.1.1
A beautiful terminal-based Excel and CSV viewer

Project: https://github.com/CodeOne45/vex-tui

基本的な使い方

ファイルを開く

ExcelファイルやCSVファイルを引数に指定して起動する。

vex-tui c01.csv

CSVデータ元: 国勢調査 時系列データ CSV形式による主要時系列データ

vex-tui-01
vex-tui Book1.xlsx
vex-tui-01

サポートされているファイル形式

  • Excel形式: .xlsx, .xlsm, .xls
  • CSV形式: .csv

起動時のオプション

テーマを指定して起動することもできる。

# Nordテーマで起動
vex-tui report.csv --theme nord

# Tokyo Nightテーマで起動
vex-tui sales.xlsx --theme tokyo-night

利用可能なテーマ一覧はヘルプで確認できる。

vex-tui --help
ヘルプ
vex v1.1.1 - Terminal Excel Viewer

USAGE:
  vex [OPTIONS] <file>

ARGUMENTS:
  <file>    Path to Excel (.xlsx, .xlsm, .xls) or CSV file

OPTIONS:
  -t, --theme <name>    Set color theme (default: catppuccin)
  --version             Show version information
  --help                Show this help message

AVAILABLE THEMES:
  • catppuccin
  • nord
  • rose-pine
  • tokyo-night
  • gruvbox
  • dracula

EXAMPLES:
  vex data.xlsx
  vex report.csv --theme nord
  vex sales.xlsx -t tokyo-night

KEYBOARD SHORTCUTS:
  Navigation:  ↑↓←→ / hjkl, PgUp/PgDn, Home/End
  Sheets:      Tab / Shift+Tab
  Search:      / (search), n (next), N (prev)
  Actions:     Enter (details), Ctrl+G (jump), c (copy)
  Data viz:    V (select range), v (visualize)
  Other:       e (export), t (theme), f (formulas), ? (help), q (quit)

For more information, visit: https://github.com/CodeOne45/vex-tui

機能

ナビゲーション

Vimスタイルのキーバインドで操作できる。

キー操作
h, j, k, l または矢印キーセルの移動
Ctrl+U / Ctrl+Dページアップ/ダウン
0 / $行の先頭/末尾へ移動
g / G最初の行/最後の行へ移動
Ctrl+G特定のセルへジャンプ(例: A100, 500, 10,5など)
Tab / Shift+Tabシートの切り替え

セル詳細の表示

キー操作
Enterセル詳細を表示

データ操作

キー操作
cセルの内容をコピー

ファイル操作

キー操作
eCSV/JSON形式でエクスポート
q終了

検索機能

ファイル内のデータを素早く検索できる。

キー操作
/検索モード
n次の検索結果
N前の検索結果
Esc検索をクリア

データビジュアライゼーション

範囲選択したデータを視覚化する機能もある。

# 1. 'V'キーで範囲選択開始
# 2. 範囲の終点で再度'V'キー
# 3. 'v'キーでビジュアライゼーションを開く
# 4. 1-4キーでグラフタイプを切り替え
グラフタイプ説明
バーチャート値を棒グラフで比較
ラインチャートトレンドを線グラフで表示
スパークラインコンパクトなインライングラフ
パイチャート割合を円グラフで表示

その他の便利機能

キー操作
f数式の表示/非表示を切り替え
tテーマを変更
?ヘルプを表示

実践例

サンプルデータで試す

簡単なCSVファイルを開いて試してみる。

vex-tui sales.csv
  • hjklまたは矢印キーでセルを移動
  • /で検索モードに入り、特定のデータを検索
  • Enterでセルの詳細を表示
  • cでセルの内容をコピー
  • eでCSVまたはJSON形式でエクスポート

大きなファイルの閲覧

vex-tuiは大規模なファイルの閲覧にも対応している。
遅延読み込み機能により、50,000行以上のファイルでも快適に動作する。

# 大きなCSVファイルを開く
vex-tui large_dataset.csv

# Ctrl+Gでジャンプ機能を使って素早く移動
# 例: "5000"と入力して5000行目へ

テーマの変更

実行中にtキーを押すとテーマセレクターが表示され、リアルタイムでテーマを切り替えられる。

利用可能なテーマ一覧

  • Catppuccin Mocha(デフォルト)
  • Nord
  • Rosé Pine
  • Tokyo Night
  • Gruvbox
  • Dracula

参考

おわりに

ターミナル上でスプレッドシートを閲覧できるvex-tuiを使ってみた。
Vimライクな操作感、データビジュアライゼーションなど、ターミナルでのデータ確認が簡単かつ快適だった。
さくっとターミナルでデータを確認したい場合にはよさそうだ。

いつも、explorer.exeでエクスプローラ開いてエディタで開いたり、code .VSCodeを開いて確認していたが、TUI上でできるならこっちで確認しようかなと思う。

Hugo で構築されています。
テーマ StackJimmy によって設計されています。