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

Add document properties to the generated Excel workbook #8

Open
arathorn2005 opened this issue Jan 21, 2013 · 0 comments
Open

Add document properties to the generated Excel workbook #8

arathorn2005 opened this issue Jan 21, 2013 · 0 comments

Comments

@arathorn2005
Copy link

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant