@@ -51,12 +51,22 @@ try {
51
51
$worksheetName = $xlsxFastEditor->getWorksheetName(1);
52
52
$worksheetId1 = $xlsxFastEditor->getWorksheetNumber('Sheet1');
53
53
$worksheetId2 = $xlsxFastEditor->getWorksheetNumber('Sheet2');
54
+ // If you want to force Excel to recalculate formulas on next load:
55
+ $xlsxFastEditor->setFullCalcOnLoad($worksheetId2, true);
54
56
55
- // Direct read access
57
+ // Direct read/write access
56
58
$fx = $xlsxFastEditor->readFormula($worksheetId1, 'A1');
57
59
$f = $xlsxFastEditor->readFloat($worksheetId1, 'B2');
58
60
$i = $xlsxFastEditor->readInt($worksheetId1, 'C3');
59
61
$s = $xlsxFastEditor->readString($worksheetId2, 'D4');
62
+ $xlsxFastEditor->deleteRow($worksheetId1, 5);
63
+ $xlsxFastEditor->writeFormula($worksheetId1, 'A1', '=B2*3');
64
+ $xlsxFastEditor->writeFloat($worksheetId1, 'B2', 3.14);
65
+ $xlsxFastEditor->writeInt($worksheetId1, 'C3', 13);
66
+ $xlsxFastEditor->writeString($worksheetId2, 'D4', 'Hello');
67
+
68
+ // Regex search & replace operating globally on all the worksheets:
69
+ $xlsxFastEditor->textReplace('/Hello/i', 'World');
60
70
61
71
// Navigation methods for existing rows
62
72
$row = $xlsxFastEditor->getFirstRow($worksheetId1);
65
75
$row = $row->getNextRow();
66
76
$row = $xlsxFastEditor->getLastRow($worksheetId1);
67
77
68
- // Read methods for rows
78
+ // Methods for rows
69
79
$rowNumber = $row->number();
70
80
71
81
// Navigation methods for existing cells
@@ -75,12 +85,16 @@ try {
75
85
$cell = $cell->getNextCell();
76
86
$cell = $row->getLastCell();
77
87
78
- // Read methods for cells
88
+ // Methods for cells
79
89
$cellName = $cell->name();
80
90
$fx = $cell->readFormula();
81
91
$f = $cell->readFloat();
82
92
$i = $cell->readInt();
83
93
$s = $cell->readString();
94
+ $cell->writeFormula('=B2*3');
95
+ $cell->writeFloat(3.14);
96
+ $cell->writeInt(13);
97
+ $cell->writeString('Hello');
84
98
85
99
// Iterators for existing rows and cells
86
100
foreach ($xlsxFastEditor->rowsIterator($worksheetId1) as $row) {
@@ -89,19 +103,6 @@ try {
89
103
}
90
104
}
91
105
92
- // If you want to force Excel to recalculate formulas on next load:
93
- $xlsxFastEditor->setFullCalcOnLoad($worksheetId2, true);
94
-
95
- // Direct write access
96
- $xlsxFastEditor->deleteRow($worksheetId1, 5);
97
- $xlsxFastEditor->writeFormula($worksheetId1, 'A1', '=B2*3');
98
- $xlsxFastEditor->writeFloat($worksheetId1, 'B2', 3.14);
99
- $xlsxFastEditor->writeInt($worksheetId1, 'C3', 13);
100
- $xlsxFastEditor->writeString($worksheetId2, 'D4', 'Hello');
101
-
102
- // Regex search & replace operating globally on all the worksheets:
103
- $xlsxFastEditor->textReplace('/Hello/i', 'World');
104
-
105
106
$xlsxFastEditor->save();
106
107
// If you do not want to save, call `close()` instead:
107
108
// $xlsxFastEditor->close();
0 commit comments