{
    "mode": "perldoc",
    "parameter": "Spreadsheet::ParseExcel::SaveParser",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Spreadsheet%3A%3AParseExcel%3A%3ASaveParser/json",
    "generated": "2026-07-27T13:51:57Z",
    "synopsis": "Say we start with an Excel file that looks like this:\n-----------------------------------------------------\n|   |      A      |      B      |      C      |\n-----------------------------------------------------\n| 1 | Hello       | ...         | ...         |  ...\n| 2 | World       | ...         | ...         |  ...\n| 3 | *Bold text* | ...         | ...         |  ...\n| 4 | ...         | ...         | ...         |  ...\n| 5 | ...         | ...         | ...         |  ...\nThen we process it with the following program:\n#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse Spreadsheet::ParseExcel;\nuse Spreadsheet::ParseExcel::SaveParser;\n# Open an existing file with SaveParser\nmy $parser   = Spreadsheet::ParseExcel::SaveParser->new();\nmy $template = $parser->Parse('template.xls');\n# Get the first worksheet.\nmy $worksheet = $template->worksheet(0);\nmy $row  = 0;\nmy $col  = 0;\n# Overwrite the string in cell A1\n$worksheet->AddCell( $row, $col, 'New string' );\n# Add a new string in cell B1\n$worksheet->AddCell( $row, $col + 1, 'Newer' );\n# Add a new string in cell C1 with the format from cell A3.\nmy $cell = $worksheet->getcell( $row + 2, $col );\nmy $formatnumber = $cell->{FormatNo};\n$worksheet->AddCell( $row, $col + 2, 'Newest', $formatnumber );\n# Write over the existing file or write a new file.\n$template->SaveAs('newfile.xls');\nWe should now have an Excel file that looks like this:\n-----------------------------------------------------\n|   |      A      |      B      |      C      |\n-----------------------------------------------------\n| 1 | New string  | Newer       | *Newest*    |  ...\n| 2 | World       | ...         | ...         |  ...\n| 3 | *Bold text* | ...         | ...         |  ...\n| 4 | ...         | ...         | ...         |  ...\n| 5 | ...         | ...         | ...         |  ...",
    "sections": {
        "NAME": {
            "content": "Spreadsheet::ParseExcel::SaveParser - Rewrite an existing Excel file.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Say we start with an Excel file that looks like this:\n\n-----------------------------------------------------\n|   |      A      |      B      |      C      |\n-----------------------------------------------------\n| 1 | Hello       | ...         | ...         |  ...\n| 2 | World       | ...         | ...         |  ...\n| 3 | *Bold text* | ...         | ...         |  ...\n| 4 | ...         | ...         | ...         |  ...\n| 5 | ...         | ...         | ...         |  ...\n\nThen we process it with the following program:\n\n#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nuse Spreadsheet::ParseExcel;\nuse Spreadsheet::ParseExcel::SaveParser;\n\n\n# Open an existing file with SaveParser\nmy $parser   = Spreadsheet::ParseExcel::SaveParser->new();\nmy $template = $parser->Parse('template.xls');\n\n\n# Get the first worksheet.\nmy $worksheet = $template->worksheet(0);\nmy $row  = 0;\nmy $col  = 0;\n\n\n# Overwrite the string in cell A1\n$worksheet->AddCell( $row, $col, 'New string' );\n\n\n# Add a new string in cell B1\n$worksheet->AddCell( $row, $col + 1, 'Newer' );\n\n\n# Add a new string in cell C1 with the format from cell A3.\nmy $cell = $worksheet->getcell( $row + 2, $col );\nmy $formatnumber = $cell->{FormatNo};\n\n$worksheet->AddCell( $row, $col + 2, 'Newest', $formatnumber );\n\n\n# Write over the existing file or write a new file.\n$template->SaveAs('newfile.xls');\n\nWe should now have an Excel file that looks like this:\n\n-----------------------------------------------------\n|   |      A      |      B      |      C      |\n-----------------------------------------------------\n| 1 | New string  | Newer       | *Newest*    |  ...\n| 2 | World       | ...         | ...         |  ...\n| 3 | *Bold text* | ...         | ...         |  ...\n| 4 | ...         | ...         | ...         |  ...\n| 5 | ...         | ...         | ...         |  ...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The \"Spreadsheet::ParseExcel::SaveParser\" module rewrite an existing Excel file by reading it\nwith \"Spreadsheet::ParseExcel\" and rewriting it with \"Spreadsheet::WriteExcel\".\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": []
        },
        "Parser": {
            "content": "new()\n$parse = new Spreadsheet::ParseExcel::SaveParser();\n\nConstructor.\n\nParse()\n$workbook = $parse->Parse($sFileName);\n\n$workbook = $parse->Parse($sFileName , $formatter);\n\nReturns a \"Workbook\" object. If an error occurs, returns undef.\n\nThe optional $formatter is a Formatter Class to format the value of cells.\n",
            "subsections": []
        },
        "Workbook": {
            "content": "The \"Parse()\" method returns a \"Spreadsheet::ParseExcel::SaveParser::Workbook\" object.\n\nThis is a subclass of the Spreadsheet::ParseExcel::Workbook and has the following methods:\n\nworksheets()\nReturns an array of \"Worksheet\" objects. This was most commonly used to iterate over the\nworksheets in a workbook:\n\nfor my $worksheet ( $workbook->worksheets() ) {\n...\n}\n\nworksheet()\nThe \"worksheet()\" method returns a single \"Worksheet\" object using either its name or index:\n\n$worksheet = $workbook->worksheet('Sheet1');\n$worksheet = $workbook->worksheet(0);\n\nReturns \"undef\" if the sheet name or index doesn't exist.\n\nAddWorksheet()\n$workbook = $workbook->AddWorksheet($name, %properties);\n\nCreate a new Worksheet object of type \"Spreadsheet::ParseExcel::Worksheet\".\n\nThe %properties hash contains the properties of new Worksheet.\n",
            "subsections": [
                {
                    "name": "AddFont",
                    "content": "$workbook = $workbook->AddFont(%properties);\n\nCreate new Font object of type \"Spreadsheet::ParseExcel::Font\".\n\nThe %properties hash contains the properties of new Font.\n"
                },
                {
                    "name": "AddFormat",
                    "content": "$workbook = $workbook->AddFormat(%properties);\n\nThe %properties hash contains the properties of new Font.\n"
                }
            ]
        },
        "Worksheet": {
            "content": "Spreadsheet::ParseExcel::SaveParser::Worksheet\n\nWorksheet is a subclass of Spreadsheet::ParseExcel::Worksheet. And has these methods :\n\nThe \"Worksbook::worksheet()\" method returns a \"Spreadsheet::ParseExcel::SaveParser::Worksheet\"\nobject.\n\nThis is a subclass of the Spreadsheet::ParseExcel::Worksheet and has the following methods:\n",
            "subsections": []
        },
        "AddCell": {
            "content": "$workbook = $worksheet->AddCell($row, $col, $value, $format [$encoding]);\n\nCreate new Cell object of type \"Spreadsheet::ParseExcel::Cell\".\n\nThe $format parameter is the format number rather than a full format object.\n\nTo specify just same as another cell, you can set it like below:\n\n$row            = 0;\n$col            = 0;\n$worksheet      = $template->worksheet(0);\n$cell           = $worksheet->getcell( $row, $col );\n$formatnumber  = $cell->{FormatNo};\n\n$worksheet->AddCell($row +1, $coll, 'New data', $formatnumber);\n",
            "subsections": []
        },
        "TODO": {
            "content": "Please note that this module is currently (versions 0.50-0.60) undergoing a major restructuring\nand rewriting.\n",
            "subsections": []
        },
        "Known Problems": {
            "content": "You can only rewrite the features that Spreadsheet::WriteExcel supports so macros, graphs and\nsome other features in the original Excel file will be lost. Also, formulas aren't rewritten,\nonly the result of a formula is written.\n\nOnly last print area will remain. (Others will be removed)\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Current maintainer 0.60+: Douglas Wilson dougw@cpan.org\n\nMaintainer 0.40-0.59: John McNamara jmcnamara@cpan.org\n\nMaintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org\n\nOriginal author: Kawai Takanori kwitknr@cpan.org\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 2014 Douglas Wilson\n\nCopyright (c) 2009-2013 John McNamara\n\nCopyright (c) 2006-2008 Gabor Szabo\n\nCopyright (c) 2000-2002 Kawai Takanori and Nippon-RAD Co. OP Division\n\nAll rights reserved.\n\nYou may distribute under the terms of either the GNU General Public License or the Artistic\nLicense, as specified in the Perl README file.\n",
            "subsections": []
        }
    },
    "summary": "Spreadsheet::ParseExcel::SaveParser - Rewrite an existing Excel file.",
    "flags": [],
    "examples": [],
    "see_also": []
}