2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Excel の xlsx を perlでパースする

Posted at

UNIX (厳密にはFreeBSD)でxlsxをパースしたい。

理由としては、Excelでホームページを作っているからです。

Spreadsheet::ParseXLSXを使用する

use Spreadsheet::ParseXLSX;
		my $xlsxfile="excel.xlsx";

		print "Parse start $xlsxfile\n";
		my $ExcelObj = Spreadsheet::ParseXLSX->new();  # ParseXLSXのオブジェクト定義
	    
		my $Book = $ExcelObj->parse($xlsxfile);        # xlsxファイル読み込み/book扱い
	    
		for my $Sheet ($Book->worksheets()) {          # worksheetオブジェクト取得
			&GetValuesFromSheet($Sheet,"$xlsxfile.txt");               # worksheetデータ取得へ
		}

これで、excel.xlsx.txt が UTF-8のタブ区切りテキストで出力されます。

※Excelのすべての関数を認識して、正しくパースしてくれます。
※Microsoft Excelのファイル以外動作保証はないようです。
※Excel VBA は解析できません。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?