J
Josef Moellers
Hi,
I'm trying to record time differences in an Excel spreadsheet, but I'm
unable to do this for negative differences:
use strict;
use warnings;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new('timediff.xls');
my $HHMM = $workbook->add_format(
font => 'Arial',
size => 10,
num_format => 'hh:mm',
align => 'center',
border => 1,
);
my $worksheet = $workbook->add_worksheet('May');
my $diff = 10;
my $hhmm = sprintf('%02d', int($diff / 60))
. ':'
. sprintf('%02d', $diff % 60);
# The following is OK, prints "00:10"
$worksheet->write_date_time(0, 0, "T$hhmm", $HHMM);
# This prints "-T00:10"
$worksheet->write_date_time(1, 0, "-T$hhmm", $HHMM);
# This prints "T-00:10"
$worksheet->write_date_time(2, 0, "T-$hhmm", $HHMM);
$workbook->close();
I'm trying to record time differences in an Excel spreadsheet, but I'm
unable to do this for negative differences:
use strict;
use warnings;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new('timediff.xls');
my $HHMM = $workbook->add_format(
font => 'Arial',
size => 10,
num_format => 'hh:mm',
align => 'center',
border => 1,
);
my $worksheet = $workbook->add_worksheet('May');
my $diff = 10;
my $hhmm = sprintf('%02d', int($diff / 60))
. ':'
. sprintf('%02d', $diff % 60);
# The following is OK, prints "00:10"
$worksheet->write_date_time(0, 0, "T$hhmm", $HHMM);
# This prints "-T00:10"
$worksheet->write_date_time(1, 0, "-T$hhmm", $HHMM);
# This prints "T-00:10"
$worksheet->write_date_time(2, 0, "T-$hhmm", $HHMM);
$workbook->close();