mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-26 18:45:08 +00:00
dbff58a532
Fix #850 (marked stale many years ago, but now reopened). User had a typo in their script which would have caused problems no matter what. However, it exposed another problem. Style Alignment Read Order was supported only by the Xlsx Reader and Writer, but it could have been supported pretty easily for most other formats. This PR adds support for the following: - Xls (read and write) - Html (write, and read using inline styles). Html reader does not yet process most classes. - Pdf (write). PhpSpreadsheet does not have a Pdf reader. - Ods (write). PhpSpreadsheet does not yet support reading most Ods styles. - Xml (read). PhpSpreadsheet does not have an Xml writer. - Gnumeric (no change). It appears that the Gnumeric product does not support this attribute. - Csv (no change). Csv does not support any styles. - Slk (no change). Slk does not support non-Latin characters, so this attribute doesn't make sense for it.
53 lines
2.2 KiB
PHP
53 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Writer\Ods;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Ods\Content;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ReadOrderTest extends TestCase
|
|
{
|
|
public function testReadOrder(): void
|
|
{
|
|
$spreadsheet = new Spreadsheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet->setCellValue('A1', '1-' . 'منصور حسين الناصر');
|
|
$sheet->setCellValue('A2', '1-' . 'منصور حسين الناصر');
|
|
$sheet->setCellValue('A3', '1-' . 'منصور حسين الناصر');
|
|
$sheet->getStyle('A1')
|
|
->getAlignment()->setReadOrder(Alignment::READORDER_RTL);
|
|
$sheet->getStyle('A2')
|
|
->getAlignment()->setReadOrder(Alignment::READORDER_LTR);
|
|
$sheet->getStyle('A2')->getFont()->setName('Arial');
|
|
$sheet->getStyle('A3')->getFont()->setName('Times New Roman');
|
|
$content = new Content(new Ods($spreadsheet));
|
|
$xml = $content->write();
|
|
self::assertStringContainsString(
|
|
'<style:table-cell-properties style:vertical-align="bottom" style:rotation-align="none"/>'
|
|
. '<style:paragraph-properties style:writing-mode="rl-tb"/>'
|
|
. '<style:text-properties fo:color="#000000" fo:font-family="Calibri"',
|
|
$xml,
|
|
'explicit rtl direction in paragraph properties'
|
|
);
|
|
self::assertStringContainsString(
|
|
'<style:table-cell-properties style:vertical-align="bottom" style:rotation-align="none"/>'
|
|
. '<style:paragraph-properties style:writing-mode="lr-tb"/>'
|
|
. '<style:text-properties fo:color="#000000" fo:font-family="Arial"',
|
|
$xml,
|
|
'explicit ltr direction in paragraph properties'
|
|
);
|
|
self::assertStringContainsString(
|
|
'<style:table-cell-properties style:vertical-align="bottom" style:rotation-align="none"/>'
|
|
. '<style:text-properties fo:color="#000000" fo:font-family="Times New Roman"',
|
|
$xml,
|
|
'no paragraph properties'
|
|
);
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
}
|