sosreporttoxls

以前、モーゼさんに言われていたこと。「???のシートみたいに、各シートの上部分に日本語ファイル名が書ければ良いよね?」ということで修正。ちなみに入力ファイルは、1カラム目から、「Excel化したい実体のファイルPATH」、「各シートの上部分に記述する名称」、「シート名称」の以上3カラムを「,」で区切って記述すること。

df,dfファイルです,dfのシートです
proc/cpuinfo,cpuinfo file,cpuinfo sheet

で、完成版。なんと、こいつが役に立つときが来そうな悪寒。

#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;
use Jcode;
use Unicode::String qw(utf8 utf16);


open (SOS, 'sosreportlist.txt') or die "df: $!";

my $workbook = Spreadsheet::WriteExcel->new('sosreport.xls');
my $uni_font = $workbook->add_format(font => 'Arial Unicode MS');

foreach my $list(readline SOS) {

chomp($list);

my @array = $list;
my $num = @array;
my @list2;

for (my $i = 0; $i < $num; $i++) {

@list2 = split(/,/, $array[$i]);
chomp(@list2);

}

# Make the Excel sheet here.
my $temp = $workbook->add_worksheet(utf8( Jcode->new($list2[2])->utf8 )->utf16,1);

# Open the output files of SOSREPORT.
open (TEMP, $list2[0]) or die "open error: $!";

# Row and column are indexed
my $row = 1;

while () {

chomp;

my @Fld = split(',', $_);
my $col = 1;

foreach my $token (@Fld) {

$temp->write_unicode(0, 0, utf8(Jcode->new($list2[1])->utf8 )->utf16);
$temp->write_unicode($row, $col, utf8(Jcode->new($token)->utf8 )->utf16);
$col++;

}
$row++;
}

close(TEMP);
}
close(SOS);