Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Perl编写excel创建图表,图表中的单元格包含各种工作表中的公式_Linux_Excel_Perl_Xlsx_Xlsxwriter - Fatal编程技术网

Linux Perl编写excel创建图表,图表中的单元格包含各种工作表中的公式

Linux Perl编写excel创建图表,图表中的单元格包含各种工作表中的公式,linux,excel,perl,xlsx,xlsxwriter,Linux,Excel,Perl,Xlsx,Xlsxwriter,是否可以使用perl的Excel::Writer::XLSX模块创建包含公式的单元格图表 以下是我正在做的: 1) 创建了包含多个工作表的xlsx文件-无问题 2) 使用其他工作表中的常量值在一个工作表中创建图表-无问题 3) 创建了包含公式的单元格的工作表-无问题(我可以在输出xlsx中看到值) 4) 试图从#3创建一个图表,它是空的,尽管我可以看到上面提到的值 请帮忙 第4项应该有效。以下是一个例子: #!/usr/bin/perl use strict; use warnings; us

是否可以使用perl的Excel::Writer::XLSX模块创建包含公式的单元格图表

以下是我正在做的:

1) 创建了包含多个工作表的xlsx文件-无问题

2) 使用其他工作表中的常量值在一个工作表中创建图表-无问题

3) 创建了包含公式的单元格的工作表-无问题(我可以在输出xlsx中看到值)

4) 试图从#3创建一个图表,它是空的,尽管我可以看到上面提到的值


请帮忙

第4项应该有效。以下是一个例子:

#!/usr/bin/perl

use strict;
use warnings;
use Excel::Writer::XLSX;

my $workbook   = Excel::Writer::XLSX->new( 'chart_column.xlsx' );
my $worksheet1 = $workbook->add_worksheet();
my $worksheet2 = $workbook->add_worksheet();
my $bold       = $workbook->add_format( bold => 1 );

# Add the worksheet data that the charts will refer to.
my $headings = [ 'Number', 'Batch 1', 'Batch 2' ];
my $data = [
    [ 2,  3,  4,  5,  6,  7 ],
    [ 10, 40, 50, 20, 10, 50 ],
    [ 30, 60, 70, 50, 40, 30 ],
];

# Add the data to worksheet2.
$worksheet2->write( 'A1', $headings, $bold );
$worksheet2->write( 'A2', $data );


# Add formulas in worksheet1 to refer to the data in worksheet2.
for my $row (1 .. 7) {
    $worksheet1->write( $row -1, 0, '=Sheet2!A' . $row );
    $worksheet1->write( $row -1, 1, '=Sheet2!B' . $row );
    $worksheet1->write( $row -1, 2, '=Sheet2!C' . $row );
}


# Create a new chart object. In this case an embedded chart.
my $chart = $workbook->add_chart( type => 'column', embedded => 1 );

# Configure the series.
$chart->add_series(
    name       => '=Sheet1!$B$1',
    categories => '=Sheet1!$A$2:$A$7',
    values     => '=Sheet1!$B$2:$B$7',
);
$chart->add_series(
    name       => '=Sheet1!$C$1',
    categories => '=Sheet1!$A$2:$A$7',
    values     => '=Sheet1!$C$2:$C$7',
);

# Insert the chart into the worksheet (with an offset).
$worksheet1->insert_chart( 'D2', $chart, 25, 10 );

$workbook->close();

__END__
以下是输出:


看起来它在Excel中工作。但是,它可能无法用于某些不计算公式结果的电子表格应用程序。

太好了,非常感谢您提供的示例。是的,我现在可以看到结果了。