{
    "mode": "perldoc",
    "parameter": "Spreadsheet::WriteExcel::Chart::Line",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Spreadsheet%3A%3AWriteExcel%3A%3AChart%3A%3ALine/json",
    "generated": "2026-06-02T23:30:29Z",
    "synopsis": "To create a simple Excel file with a Line chart using Spreadsheet::WriteExcel:\n#!/usr/bin/perl -w\nuse strict;\nuse Spreadsheet::WriteExcel;\nmy $workbook  = Spreadsheet::WriteExcel->new( 'chart.xls' );\nmy $worksheet = $workbook->addworksheet();\nmy $chart     = $workbook->addchart( type => 'line' );\n# Configure the chart.\n$chart->addseries(\ncategories => '=Sheet1!$A$2:$A$7',\nvalues     => '=Sheet1!$B$2:$B$7',\n);\n# Add the worksheet data the chart refers to.\nmy $data = [\n[ 'Category', 2, 3, 4, 5, 6, 7 ],\n[ 'Value',    1, 4, 5, 2, 1, 5 ],\n];\n$worksheet->write( 'A1', $data );\nEND",
    "sections": {
        "NAME": {
            "content": "Line - A writer class for Excel Line charts.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "To create a simple Excel file with a Line chart using Spreadsheet::WriteExcel:\n\n#!/usr/bin/perl -w\n\nuse strict;\nuse Spreadsheet::WriteExcel;\n\nmy $workbook  = Spreadsheet::WriteExcel->new( 'chart.xls' );\nmy $worksheet = $workbook->addworksheet();\n\nmy $chart     = $workbook->addchart( type => 'line' );\n\n# Configure the chart.\n$chart->addseries(\ncategories => '=Sheet1!$A$2:$A$7',\nvalues     => '=Sheet1!$B$2:$B$7',\n);\n\n# Add the worksheet data the chart refers to.\nmy $data = [\n[ 'Category', 2, 3, 4, 5, 6, 7 ],\n[ 'Value',    1, 4, 5, 2, 1, 5 ],\n];\n\n$worksheet->write( 'A1', $data );\n\nEND\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module implements Line charts for Spreadsheet::WriteExcel. The chart object is created via\nthe Workbook \"addchart()\" method:\n\nmy $chart = $workbook->addchart( type => 'line' );\n\nOnce the object is created it can be configured via the following methods that are common to all\nchart classes:\n\n$chart->addseries();\n$chart->setxaxis();\n$chart->setyaxis();\n$chart->settitle();\n\nThese methods are explained in detail in Spreadsheet::WriteExcel::Chart. Class specific methods\nor settings, if any, are explained below.\n",
            "subsections": []
        },
        "Line Chart Methods": {
            "content": "There aren't currently any line chart specific methods. See the TODO section of\nSpreadsheet::WriteExcel::Chart.\n",
            "subsections": []
        },
        "EXAMPLE": {
            "content": "Here is a complete example that demonstrates most of the available features when creating a\nchart.\n\n#!/usr/bin/perl -w\n\nuse strict;\nuse Spreadsheet::WriteExcel;\n\nmy $workbook  = Spreadsheet::WriteExcel->new( 'chartline.xls' );\nmy $worksheet = $workbook->addworksheet();\nmy $bold      = $workbook->addformat( bold => 1 );\n\n# Add the worksheet data that the charts will refer to.\nmy $headings = [ 'Number', 'Sample 1', 'Sample 2' ];\nmy $data = [\n[ 2, 3, 4, 5, 6, 7 ],\n[ 1, 4, 5, 2, 1, 5 ],\n[ 3, 6, 7, 5, 4, 3 ],\n];\n\n$worksheet->write( 'A1', $headings, $bold );\n$worksheet->write( 'A2', $data );\n\n# Create a new chart object. In this case an embedded chart.\nmy $chart = $workbook->addchart( type => 'line', embedded => 1 );\n\n# Configure the first series. (Sample 1)\n$chart->addseries(\nname       => 'Sample 1',\ncategories => '=Sheet1!$A$2:$A$7',\nvalues     => '=Sheet1!$B$2:$B$7',\n);\n\n# Configure the second series. (Sample 2)\n$chart->addseries(\nname       => 'Sample 2',\ncategories => '=Sheet1!$A$2:$A$7',\nvalues     => '=Sheet1!$C$2:$C$7',\n);\n\n# Add a chart title and some axis labels.\n$chart->settitle ( name => 'Results of sample analysis' );\n$chart->setxaxis( name => 'Test number' );\n$chart->setyaxis( name => 'Sample length (cm)' );\n\n# Insert the chart into the worksheet (with an offset).\n$worksheet->insertchart( 'D2', $chart, 25, 10 );\n\nEND\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "John McNamara jmcnamara@cpan.org\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright MM-MMX, John McNamara.\n\nAll Rights Reserved. This module is free software. It may be used, redistributed and/or modified\nunder the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "Line - A writer class for Excel Line charts.",
    "flags": [],
    "examples": [
        "Here is a complete example that demonstrates most of the available features when creating a",
        "chart.",
        "#!/usr/bin/perl -w",
        "use strict;",
        "use Spreadsheet::WriteExcel;",
        "my $workbook  = Spreadsheet::WriteExcel->new( 'chartline.xls' );",
        "my $worksheet = $workbook->addworksheet();",
        "my $bold      = $workbook->addformat( bold => 1 );",
        "# Add the worksheet data that the charts will refer to.",
        "my $headings = [ 'Number', 'Sample 1', 'Sample 2' ];",
        "my $data = [",
        "[ 2, 3, 4, 5, 6, 7 ],",
        "[ 1, 4, 5, 2, 1, 5 ],",
        "[ 3, 6, 7, 5, 4, 3 ],",
        "];",
        "$worksheet->write( 'A1', $headings, $bold );",
        "$worksheet->write( 'A2', $data );",
        "# Create a new chart object. In this case an embedded chart.",
        "my $chart = $workbook->addchart( type => 'line', embedded => 1 );",
        "# Configure the first series. (Sample 1)",
        "$chart->addseries(",
        "name       => 'Sample 1',",
        "categories => '=Sheet1!$A$2:$A$7',",
        "values     => '=Sheet1!$B$2:$B$7',",
        ");",
        "# Configure the second series. (Sample 2)",
        "$chart->addseries(",
        "name       => 'Sample 2',",
        "categories => '=Sheet1!$A$2:$A$7',",
        "values     => '=Sheet1!$C$2:$C$7',",
        ");",
        "# Add a chart title and some axis labels.",
        "$chart->settitle ( name => 'Results of sample analysis' );",
        "$chart->setxaxis( name => 'Test number' );",
        "$chart->setyaxis( name => 'Sample length (cm)' );",
        "# Insert the chart into the worksheet (with an offset).",
        "$worksheet->insertchart( 'D2', $chart, 25, 10 );",
        "END"
    ],
    "see_also": []
}