|
10 | 10 | use alexandrainst\XlsxFastEditor\XlsxFastEditor;
|
11 | 11 | use alexandrainst\XlsxFastEditor\XlsxFastEditorException;
|
12 | 12 |
|
13 |
| -copy(__DIR__ . '/test.xlsx', __DIR__ . '/copy.xlsx'); |
| 13 | +copy(__DIR__ . '/test.xlsx', __DIR__ . '/_copy.xlsx'); |
14 | 14 |
|
15 | 15 | try {
|
16 |
| - $xlsxFastEditor = new XlsxFastEditor(__DIR__ . '/copy.xlsx'); |
| 16 | + $xlsxFastEditor = new XlsxFastEditor(__DIR__ . '/_copy.xlsx'); |
17 | 17 |
|
18 | 18 | $sheet1 = $xlsxFastEditor->getWorksheetNumber('Sheet1');
|
19 | 19 | assert($sheet1 === 1);
|
|
39 | 39 | assert($xlsxFastEditor->getFirstRow($sheet1)?->number() === 1);
|
40 | 40 | assert($xlsxFastEditor->getRow($sheet1, 1)?->getFirstCell()?->name() === 'A1');
|
41 | 41 | assert($xlsxFastEditor->getRow($sheet1, 2)?->number() === 2);
|
42 |
| - assert($xlsxFastEditor->getRow($sheet1, 3)?->getLastCell()?->name() === 'D3'); |
| 42 | + assert($xlsxFastEditor->getRow($sheet1, 3)?->getLastCell()?->name() === 'E3'); |
43 | 43 | assert($xlsxFastEditor->getRow($sheet1, 4)?->getCell('D4')?->name() === 'D4');
|
44 | 44 | assert($xlsxFastEditor->getLastRow($sheet1)?->number() === 4);
|
45 | 45 |
|
|
52 | 52 | $nb++;
|
53 | 53 | }
|
54 | 54 | }
|
55 |
| - assert($nb === 16); |
| 55 | + assert($nb === 20); |
56 | 56 |
|
57 | 57 | // Writing existing cells
|
58 | 58 | $xlsxFastEditor->writeFormula($sheet1, 'c2', '=2*3');
|
|
81 | 81 | // Regex
|
82 | 82 | assert($xlsxFastEditor->textReplace('/Hello/i', 'World') > 0);
|
83 | 83 |
|
| 84 | + $xlsxFastEditor->setFullCalcOnLoad($sheet1, true); |
| 85 | + |
84 | 86 | $xlsxFastEditor->save();
|
85 | 87 |
|
86 | 88 | // Verify all the changes
|
87 |
| - $xlsxFastEditor = new XlsxFastEditor(__DIR__ . '/copy.xlsx'); |
| 89 | + $xlsxFastEditor = new XlsxFastEditor(__DIR__ . '/_copy.xlsx'); |
88 | 90 |
|
89 | 91 | assert($xlsxFastEditor->readFormula($sheet1, 'c2') === '=2*3');
|
90 | 92 | assert($xlsxFastEditor->readString($sheet1, 'B4') === 'α');
|
|
96 | 98 | assert($xlsxFastEditor->readInt($sheet2, 'C3') === -7);
|
97 | 99 | assert($xlsxFastEditor->readFloat($sheet2, 'D3') === 273.15);
|
98 | 100 |
|
99 |
| - $xlsxFastEditor->setFullCalcOnLoad($sheet2, true); |
100 |
| - |
101 | 101 | assert($xlsxFastEditor->readFormula($sheet2, 'I2') === '=7*3');
|
102 | 102 | assert($xlsxFastEditor->readString($sheet2, 'F2') === 'γ');
|
103 | 103 | assert($xlsxFastEditor->readInt($sheet2, 'G3') === -7);
|
|
112 | 112 |
|
113 | 113 | $xlsxFastEditor->close();
|
114 | 114 |
|
115 |
| - // Verify by hand that the resulting file opens without warning in Microsoft Excel |
| 115 | + // Verify by hand that the resulting file opens without warning in Microsoft Excel. |
| 116 | + // Verify by hand that the cell Sheet1!E4 has its formula recalculated (to -999) when opening in Excel. |
116 | 117 | // unlink(__DIR__ . '/copy.xlsx');
|
117 | 118 | } catch (XlsxFastEditorException $xlsxe) {
|
118 | 119 | die($xlsxe);
|
|
0 commit comments