Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use Excel::Writer::XLSX;
- {
- my $output_fn = 'result.xlsx';
- my $input_fn = 'input.txt';
- my $workbook = Excel::Writer::XLSX->new( $output_fn );
- my $worksheet = $workbook->add_worksheet();
- my $data = read_file('input.txt');
- my $col = 0;
- for my $i (0..$#$data) {
- my $value = $data->[$i];
- my $row = $i;
- $worksheet->write( $row, $col, $value );
- }
- $workbook->close();
- }
- sub read_file {
- my ($fn) = @_;
- open ( my $fh, '<', $fn ) or die "Could not open file '$fn': $!";
- my @data = <$fh>;
- chomp @data;
- close $fh;
- return \@data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement