Kandankarunai has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, How to delete the workbook using spreadsheet::writeExcel?

Replies are listed 'Best First'.
Re: Excel workbook
by CountZero (Bishop) on May 02, 2011 at 12:20 UTC
    From the docs:
    An Excel file is a binary file within a binary file. It contains several interlinked checksums and changing even one byte can cause it to become corrupted.

    As such you cannot simply append or update an Excel file. The only way to achieve this is to read the entire file into memory, make the required changes or additions and then write the file out again.

    You can read and rewrite an Excel file using the Spreadsheet::ParseExcel::SaveParser module which is a wrapper around Spreadsheet::ParseExcel and Spreadsheet::WriteExcel. It is part of the Spreadsheet::ParseExcel package

    So read in the whole spreadsheet and then take care when writing it out again that you skip that worksheet.

    If that doesn't suit you, then you will have to use Win32::OLE.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Excel workbook
by moritz (Cardinal) on May 02, 2011 at 10:04 UTC