/usr/bin/text2table is in libopenoffice-oodoc-perl 2.125-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
#-----------------------------------------------------------------------------
# $Id : text2table 0.2 2008-05-13 JMG$
#-----------------------------------------------------------------------------
=head1 NAME
text2table - flat text conversion to OpenDocument spreadsheet
=head1 SYNOPSIS
text2table sourcefile.csv mycalc.ods 32 20
=head1 DESCRIPTION
Creates an ODF spreadsheet file and populate its first sheet
from a delimited text file. Each line of the source file produces
a row in the target table. In the line, the field separator is ";".
The target file is created. Any existing file with the same name is
replaced.
The two last arguments are the length (lines) and the width (columns)
of the target table.
The input values are processed as text values.
=cut
use OpenOffice::OODoc 2.103;
my ($input_file, $output_file, $lines, $columns) = @ARGV;
die "Usage : txt2table <input file> <output OOo file> <lines> <columns>\n"
unless ($input_file && $output_file && $lines && $columns);
# create the OOo spreadsheet
my $doc = odfDocument(file => $output_file, create => 'spreadsheet');
# select & size the 1st (and only) sheet in the document
my $sheet = $doc->expandTable(0, $lines, $columns);
# rename it as the input file (why not ?)
$doc->renameTable($sheet, $input_file);
# populate the table
open INPUT, "<", $input_file or die "Input file $input_file unavailable\n";
my $line = undef;
my @rows = $doc->getTableRows($sheet);
for (my $i = 0 ; $i < $lines && ($line = <INPUT>) ; $i++)
{
my $row = $rows[$i];
my @cellvalues = split ';', $line;
my @cells = $doc->getRowCells($row);
for (my $j = 0 ; $j < $columns && @cellvalues ; $j++)
{
$doc->cellValue($cells[$j], shift @cellvalues);
}
}
# save the result
$doc->save;
exit;
|