Skip to content
This repository was archived by the owner on Jun 6, 2021. It is now read-only.
This repository was archived by the owner on Jun 6, 2021. It is now read-only.

Add document properties to the generated Excel workbook #8

@arathorn2005

Description

@arathorn2005

First things first, thanks for this nice and fast Excel writer. With a few lines of code it'll be easy to add a few properties to the workbook, like this:

class ExportDataExcel extends ExportData {

    ... 
    public $encoding = 'UTF-8'; // encoding type to specify in file. 
    // Note that you're on your own for making sure your data is actually encoded to this encoding

   public $title = 'MyReport'; // title for Workbook
   public $subject = 'MySubject'; // subject for Workbook 
   public $author = 'Me!'; // author
   public $company = 'MyCompany'; // company

   public $sheet_title = 'Sheet1'; // title for Worksheet (i'verenamed it)

   function generateHeader() {

    // workbook header
    $output = stripslashes(sprintf(self::XmlHeader, $this->encoding)) . "\n";

    // set up summary properties
    $output .= stripslashes("<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">\n");
    $output .= "<Title>".htmlentities($this->title)."</Title>\n";
    $output .= "<Subject>".htmlentities($this->subject)."</Subject>\n";
    $output .= "<Author>".htmlentities($this->author)."</Author>\n";
    $output .= "<Company>".htmlentities($this->company)."</Company>\n";
    $output .= "</DocumentProperties>\n";

    // Set up styles
       ...followed by the rest of your code...

Like I said, easy to integrate. Feel free to use it in your code!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions