init
This commit is contained in:
commit
72a26edcff
22092 changed files with 2101903 additions and 0 deletions
59
lib/PhpSpreadsheet/Writer/Xls/Style/CellAlignment.php
Normal file
59
lib/PhpSpreadsheet/Writer/Xls/Style/CellAlignment.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Writer\Xls\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
|
||||
class CellAlignment
|
||||
{
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
private static array $horizontalMap = [
|
||||
Alignment::HORIZONTAL_GENERAL => 0,
|
||||
Alignment::HORIZONTAL_LEFT => 1,
|
||||
Alignment::HORIZONTAL_RIGHT => 3,
|
||||
Alignment::HORIZONTAL_CENTER => 2,
|
||||
Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6,
|
||||
Alignment::HORIZONTAL_JUSTIFY => 5,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
private static array $verticalMap = [
|
||||
Alignment::VERTICAL_BOTTOM => 2,
|
||||
Alignment::VERTICAL_TOP => 0,
|
||||
Alignment::VERTICAL_CENTER => 1,
|
||||
Alignment::VERTICAL_JUSTIFY => 3,
|
||||
];
|
||||
|
||||
public static function horizontal(Alignment $alignment): int
|
||||
{
|
||||
$horizontalAlignment = $alignment->getHorizontal();
|
||||
|
||||
if (is_string($horizontalAlignment) && array_key_exists($horizontalAlignment, self::$horizontalMap)) {
|
||||
return self::$horizontalMap[$horizontalAlignment];
|
||||
}
|
||||
|
||||
return self::$horizontalMap[Alignment::HORIZONTAL_GENERAL];
|
||||
}
|
||||
|
||||
public static function wrap(Alignment $alignment): int
|
||||
{
|
||||
$wrap = $alignment->getWrapText();
|
||||
|
||||
return ($wrap === true) ? 1 : 0;
|
||||
}
|
||||
|
||||
public static function vertical(Alignment $alignment): int
|
||||
{
|
||||
$verticalAlignment = $alignment->getVertical();
|
||||
|
||||
if (is_string($verticalAlignment) && array_key_exists($verticalAlignment, self::$verticalMap)) {
|
||||
return self::$verticalMap[$verticalAlignment];
|
||||
}
|
||||
|
||||
return self::$verticalMap[Alignment::VERTICAL_BOTTOM];
|
||||
}
|
||||
}
|
||||
40
lib/PhpSpreadsheet/Writer/Xls/Style/CellBorder.php
Normal file
40
lib/PhpSpreadsheet/Writer/Xls/Style/CellBorder.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Writer\Xls\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
|
||||
class CellBorder
|
||||
{
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
protected static array $styleMap = [
|
||||
Border::BORDER_NONE => 0x00,
|
||||
Border::BORDER_THIN => 0x01,
|
||||
Border::BORDER_MEDIUM => 0x02,
|
||||
Border::BORDER_DASHED => 0x03,
|
||||
Border::BORDER_DOTTED => 0x04,
|
||||
Border::BORDER_THICK => 0x05,
|
||||
Border::BORDER_DOUBLE => 0x06,
|
||||
Border::BORDER_HAIR => 0x07,
|
||||
Border::BORDER_MEDIUMDASHED => 0x08,
|
||||
Border::BORDER_DASHDOT => 0x09,
|
||||
Border::BORDER_MEDIUMDASHDOT => 0x0A,
|
||||
Border::BORDER_DASHDOTDOT => 0x0B,
|
||||
Border::BORDER_MEDIUMDASHDOTDOT => 0x0C,
|
||||
Border::BORDER_SLANTDASHDOT => 0x0D,
|
||||
Border::BORDER_OMIT => 0x00,
|
||||
];
|
||||
|
||||
public static function style(Border $border): int
|
||||
{
|
||||
$borderStyle = $border->getBorderStyle();
|
||||
|
||||
if (is_string($borderStyle) && array_key_exists($borderStyle, self::$styleMap)) {
|
||||
return self::$styleMap[$borderStyle];
|
||||
}
|
||||
|
||||
return self::$styleMap[Border::BORDER_NONE];
|
||||
}
|
||||
}
|
||||
46
lib/PhpSpreadsheet/Writer/Xls/Style/CellFill.php
Normal file
46
lib/PhpSpreadsheet/Writer/Xls/Style/CellFill.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Writer\Xls\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
|
||||
class CellFill
|
||||
{
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
protected static array $fillStyleMap = [
|
||||
Fill::FILL_NONE => 0x00,
|
||||
Fill::FILL_SOLID => 0x01,
|
||||
Fill::FILL_PATTERN_MEDIUMGRAY => 0x02,
|
||||
Fill::FILL_PATTERN_DARKGRAY => 0x03,
|
||||
Fill::FILL_PATTERN_LIGHTGRAY => 0x04,
|
||||
Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05,
|
||||
Fill::FILL_PATTERN_DARKVERTICAL => 0x06,
|
||||
Fill::FILL_PATTERN_DARKDOWN => 0x07,
|
||||
Fill::FILL_PATTERN_DARKUP => 0x08,
|
||||
Fill::FILL_PATTERN_DARKGRID => 0x09,
|
||||
Fill::FILL_PATTERN_DARKTRELLIS => 0x0A,
|
||||
Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B,
|
||||
Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C,
|
||||
Fill::FILL_PATTERN_LIGHTDOWN => 0x0D,
|
||||
Fill::FILL_PATTERN_LIGHTUP => 0x0E,
|
||||
Fill::FILL_PATTERN_LIGHTGRID => 0x0F,
|
||||
Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
|
||||
Fill::FILL_PATTERN_GRAY125 => 0x11,
|
||||
Fill::FILL_PATTERN_GRAY0625 => 0x12,
|
||||
Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
|
||||
Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
|
||||
];
|
||||
|
||||
public static function style(Fill $fill): int
|
||||
{
|
||||
$fillStyle = $fill->getFillType();
|
||||
|
||||
if (is_string($fillStyle) && array_key_exists($fillStyle, self::$fillStyleMap)) {
|
||||
return self::$fillStyleMap[$fillStyle];
|
||||
}
|
||||
|
||||
return self::$fillStyleMap[Fill::FILL_NONE];
|
||||
}
|
||||
}
|
||||
90
lib/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php
Normal file
90
lib/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Writer\Xls\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
|
||||
class ColorMap
|
||||
{
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
private static array $colorMap = [
|
||||
'#000000' => 0x08,
|
||||
'#FFFFFF' => 0x09,
|
||||
'#FF0000' => 0x0A,
|
||||
'#00FF00' => 0x0B,
|
||||
'#0000FF' => 0x0C,
|
||||
'#FFFF00' => 0x0D,
|
||||
'#FF00FF' => 0x0E,
|
||||
'#00FFFF' => 0x0F,
|
||||
'#800000' => 0x10,
|
||||
'#008000' => 0x11,
|
||||
'#000080' => 0x12,
|
||||
'#808000' => 0x13,
|
||||
'#800080' => 0x14,
|
||||
'#008080' => 0x15,
|
||||
'#C0C0C0' => 0x16,
|
||||
'#808080' => 0x17,
|
||||
'#9999FF' => 0x18,
|
||||
'#993366' => 0x19,
|
||||
'#FFFFCC' => 0x1A,
|
||||
'#CCFFFF' => 0x1B,
|
||||
'#660066' => 0x1C,
|
||||
'#FF8080' => 0x1D,
|
||||
'#0066CC' => 0x1E,
|
||||
'#CCCCFF' => 0x1F,
|
||||
// '#000080' => 0x20,
|
||||
// '#FF00FF' => 0x21,
|
||||
// '#FFFF00' => 0x22,
|
||||
// '#00FFFF' => 0x23,
|
||||
// '#800080' => 0x24,
|
||||
// '#800000' => 0x25,
|
||||
// '#008080' => 0x26,
|
||||
// '#0000FF' => 0x27,
|
||||
'#00CCFF' => 0x28,
|
||||
// '#CCFFFF' => 0x29,
|
||||
'#CCFFCC' => 0x2A,
|
||||
'#FFFF99' => 0x2B,
|
||||
'#99CCFF' => 0x2C,
|
||||
'#FF99CC' => 0x2D,
|
||||
'#CC99FF' => 0x2E,
|
||||
'#FFCC99' => 0x2F,
|
||||
'#3366FF' => 0x30,
|
||||
'#33CCCC' => 0x31,
|
||||
'#99CC00' => 0x32,
|
||||
'#FFCC00' => 0x33,
|
||||
'#FF9900' => 0x34,
|
||||
'#FF6600' => 0x35,
|
||||
'#666699' => 0x36,
|
||||
'#969696' => 0x37,
|
||||
'#003366' => 0x38,
|
||||
'#339966' => 0x39,
|
||||
'#003300' => 0x3A,
|
||||
'#333300' => 0x3B,
|
||||
'#993300' => 0x3C,
|
||||
// '#993366' => 0x3D,
|
||||
'#333399' => 0x3E,
|
||||
'#333333' => 0x3F,
|
||||
];
|
||||
|
||||
public static function lookup(Color $color, int $defaultIndex = 0x00): int
|
||||
{
|
||||
$colorRgb = $color->getRGB();
|
||||
if (is_string($colorRgb) && array_key_exists("#{$colorRgb}", self::$colorMap)) {
|
||||
return self::$colorMap["#{$colorRgb}"];
|
||||
}
|
||||
|
||||
// TODO Try and map RGB value to nearest colour within the define pallette
|
||||
// $red = Color::getRed($colorRgb, false);
|
||||
// $green = Color::getGreen($colorRgb, false);
|
||||
// $blue = Color::getBlue($colorRgb, false);
|
||||
|
||||
// $paletteSpace = 3;
|
||||
// $newColor = ($red * $paletteSpace / 256) * ($paletteSpace * $paletteSpace) +
|
||||
// ($green * $paletteSpace / 256) * $paletteSpace +
|
||||
// ($blue * $paletteSpace / 256);
|
||||
|
||||
return $defaultIndex;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue