@@ -13,15 +13,23 @@ public static function convertToExcelAddressValue(string $openOfficeAddress): st
13
13
// Cell range 3-d reference
14
14
// As we don't support 3-d ranges, we're just going to take a quick and dirty approach
15
15
// and assume that the second worksheet reference is the same as the first
16
- $ excelAddress = (string ) preg_replace ('/\$?([^\.]+)\.([^\.]+):\$?([^\.]+)\.([^\.]+)/miu ' , '$1!$2:$4 ' , $ excelAddress );
17
- // Cell range reference in another sheet
18
- $ excelAddress = (string ) preg_replace ('/\$?([^\.]+)\.([^\.]+):\.([^\.]+)/miu ' , '$1!$2:$3 ' , $ excelAddress );
19
- // Cell reference in another sheet
20
- $ excelAddress = (string ) preg_replace ('/\$?([^\.]+)\.([^\.]+)/miu ' , '$1!$2 ' , $ excelAddress );
21
- // Cell range reference
22
- $ excelAddress = (string ) preg_replace ('/\.([^\.]+):\.([^\.]+)/miu ' , '$1:$2 ' , $ excelAddress );
23
- // Simple cell reference
24
- $ excelAddress = (string ) preg_replace ('/\.([^\.]+)/miu ' , '$1 ' , $ excelAddress );
16
+ $ excelAddress = (string ) preg_replace (
17
+ [
18
+ '/\$?([^\.]+)\.([^\.]+):\$?([^\.]+)\.([^\.]+)/miu ' ,
19
+ '/\$?([^\.]+)\.([^\.]+):\.([^\.]+)/miu ' , // Cell range reference in another sheet
20
+ '/\$?([^\.]+)\.([^\.]+)/miu ' , // Cell reference in another sheet
21
+ '/\.([^\.]+):\.([^\.]+)/miu ' , // Cell range reference
22
+ '/\.([^\.]+)/miu ' , // Simple cell reference
23
+ ],
24
+ [
25
+ '$1!$2:$4 ' ,
26
+ '$1!$2:$3 ' ,
27
+ '$1!$2 ' ,
28
+ '$1:$2 ' ,
29
+ '$1 ' ,
30
+ ],
31
+ $ excelAddress
32
+ );
25
33
26
34
return $ excelAddress ;
27
35
}
@@ -37,14 +45,21 @@ public static function convertToExcelFormulaValue(string $openOfficeFormula): st
37
45
// Only replace in alternate array entries (i.e. non-quoted blocks)
38
46
// so that conversion isn't done in string values
39
47
if ($ tKey = !$ tKey ) {
40
- // Cell range reference in another sheet
41
- $ value = (string ) preg_replace ('/\[\$?([^\.]+)\.([^\.]+):\.([^\.]+)\]/miu ' , '$1!$2:$3 ' , $ value );
42
- // Cell reference in another sheet
43
- $ value = (string ) preg_replace ('/\[\$?([^\.]+)\.([^\.]+)\]/miu ' , '$1!$2 ' , $ value );
44
- // Cell range reference
45
- $ value = (string ) preg_replace ('/\[\.([^\.]+):\.([^\.]+)\]/miu ' , '$1:$2 ' , $ value );
46
- // Simple cell reference
47
- $ value = (string ) preg_replace ('/\[\.([^\.]+)\]/miu ' , '$1 ' , $ value );
48
+ $ value = (string ) preg_replace (
49
+ [
50
+ '/\[\$?([^\.]+)\.([^\.]+):\.([^\.]+)\]/miu ' , // Cell range reference in another sheet
51
+ '/\[\$?([^\.]+)\.([^\.]+)\]/miu ' , // Cell reference in another sheet
52
+ '/\[\.([^\.]+):\.([^\.]+)\]/miu ' , // Cell range reference
53
+ '/\[\.([^\.]+)\]/miu ' , // Simple cell reference
54
+ ],
55
+ [
56
+ '$1!$2:$3 ' ,
57
+ '$1!$2 ' ,
58
+ '$1:$2 ' ,
59
+ '$1 ' ,
60
+ ],
61
+ $ value
62
+ );
48
63
// Convert references to defined names/formulae
49
64
$ value = str_replace ('$$ ' , '' , $ value );
50
65
0 commit comments