@@ -13,15 +13,23 @@ public static function convertToExcelAddressValue(string $openOfficeAddress): st
1313 // Cell range 3-d reference
1414 // As we don't support 3-d ranges, we're just going to take a quick and dirty approach
1515 // 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+ );
2533
2634 return $ excelAddress ;
2735 }
@@ -37,14 +45,21 @@ public static function convertToExcelFormulaValue(string $openOfficeFormula): st
3745 // Only replace in alternate array entries (i.e. non-quoted blocks)
3846 // so that conversion isn't done in string values
3947 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+ );
4863 // Convert references to defined names/formulae
4964 $ value = str_replace ('$$ ' , '' , $ value );
5065
0 commit comments