Round number to 6 decimal places Perl Excel :: Writer: XLSX

advertisements

How do I output a number rounded to 6 decimal places to an Excel sheet using the Excel::Writer::XLSX package in Perl?


I would round the number in Perl using sprintf function

use Excel::Writer::XLSX;

# Create a new Excel workbook
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );

$worksheet = $workbook->add_worksheet();
$worksheet->write( 'A1', sprintf("%.6f", 1/3) );

The cell A1 will contain 0.333333 value