aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP
MIT License
142 stars 26 forks source link

Why is list of available fonts so limited? #18

Closed BARNZ closed 1 year ago

BARNZ commented 1 year ago

I would like to use the Calibri font but doing the following causes excel to complain about worksheet errors:

$sheet->writeHeader($headings, [
    Style::FONT => [
        Style::FONT_NAME => 'Calibri',
        Style::FONT_SIZE => 10,
        Style::FONT_STYLE => Style::FONT_STYLE_BOLD,
    ]
]);

I see theres a function Style::_getFamilyFont() which has $defaultFontsNames. If I add Calibri to this array then things work, but I cant see any way to add to this array from my application code:

$defaultFontsNames = [
    'Times New Roman' => [
        'name' => 'Times New Roman',
        'family' => 1,
    ],
    'Arial' => [
        'name' => 'Arial',
        'family' => 2,
    ],
    'Courier New' => [
        'name' => 'Courier New',
        'family' => 3,
    ],
    'Comic Sans MS' => [
        'name' => 'Comic Sans MS',
        'family' => 4,
    ],

    +++++
    'Calibri' => [
        'name' => 'Calibri',
        'family' => 5,
    ],
];

2 questions:

FYI just found this library and am currently trying to port some exports over from the now archived box\spout library,

aVadim483 commented 1 year ago

Was resolved in v3.1.3