File: 45_oem-2.t

package info (click to toggle)
libspreadsheet-parseexcel-perl 0.6500-1.1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,852 kB
  • sloc: perl: 9,442; makefile: 12
file content (41 lines) | stat: -rwxr-xr-x 928 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!perl -w

use strict;
use Test::More tests => 14;

use utf8;
use Encode qw(encode);

use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::FmtJapan;

my $xl   = Spreadsheet::ParseExcel->new();
my $fmtj = Spreadsheet::ParseExcel::FmtJapan->new(Code => 'sjis');

my $book = $xl->Parse("t/excel_files/TestEncoding.xls", $fmtj);
ok $book, "load TestEncoding.xls";

my $sheet = $book->worksheet(0);

my @expected = (
	['This is a test file for Japanese encoding'],
	[qw(ローマ数字	Ⅰ	Ⅱ)],
	[qw(丸数字	①	②)],
	[qw(年号	㍻	㍼)],
	[qw(その他	㈱	~)],
);


my($rmin, $rmax) = $sheet->row_range();
my($cmin, $cmax) = $sheet->col_range();

#binmode STDOUT, ':encoding(cp932)';

for my $i($rmin .. $rmax){
	for my $j($cmin .. $cmax){
		my $cell = $sheet->get_cell($i, $j);
		next unless $cell && $cell->value;
		#print $cell->value, "\n";
		is $cell->value, encode(cp932 => $expected[$i][$j]), "[$i, $j]";
	}
}