Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
d5af27e9
Commit
d5af27e9
authored
Nov 05, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
1d87feb8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
FormulaHelper.java
.../main/java/com/yanzuoguang/util/helper/FormulaHelper.java
+3
-3
TestFormulaHelper.java
yzg-util-base/src/test/java/helper/TestFormulaHelper.java
+7
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/FormulaHelper.java
View file @
d5af27e9
...
@@ -18,11 +18,11 @@ public class FormulaHelper {
...
@@ -18,11 +18,11 @@ public class FormulaHelper {
private
static
final
String
REGEX_DOUBLE
=
"^[-+]?[0-9]*\\.?[0-9]+$"
;
private
static
final
String
REGEX_DOUBLE
=
"^[-+]?[0-9]*\\.?[0-9]+$"
;
private
static
final
String
REGEX_QUOT
=
"(^.*?)\\((.+?)\\)(.*?$)"
;
private
static
final
String
REGEX_QUOT
=
"(^.*?)\\((.+?)\\)(.*?$)"
;
private
static
final
String
REGEX_CALC_ADD_PLUS
=
"(^.*
?
)([+\\-])(.*?$)"
;
private
static
final
String
REGEX_CALC_ADD_PLUS
=
"(^.*)([+\\-])(.*?$)"
;
private
static
final
String
REGEX_CALC_MULTIPLY_MOD
=
"(^.*?)([*/])(.*?$)"
;
private
static
final
String
REGEX_CALC_MULTIPLY_MOD
=
"(^.*?)([*/])(.*?$)"
;
private
static
final
String
REGEX_CALC_TAG
=
"[+\\-*/()]+"
;
private
static
final
String
REGEX_CALC_TAG
=
"[+\\-*/()]+"
;
private
static
final
String
EMPTY_CHAR
=
" "
;
private
static
final
String
EMPTY_CHAR
=
" "
;
p
ublic
static
String
TEMP_VAR_NAME
=
"@temp"
;
p
rivate
static
final
String
TEMP_VAR_NAME
=
"@temp"
;
private
static
FormulaHelper
calcInstance
=
new
FormulaHelper
();
private
static
FormulaHelper
calcInstance
=
new
FormulaHelper
();
...
@@ -49,7 +49,7 @@ public class FormulaHelper {
...
@@ -49,7 +49,7 @@ public class FormulaHelper {
public
static
final
int
getExcelIndex
(
String
columnName
)
{
public
static
final
int
getExcelIndex
(
String
columnName
)
{
columnName
=
columnName
.
toLowerCase
();
columnName
=
columnName
.
toLowerCase
();
if
(!
columnName
.
matches
(
"^[a-z]+$"
))
{
if
(!
columnName
.
matches
(
"^[a-z]+$"
))
{
throw
YzgError
.
getRuntimeException
(
"013"
,
columnName
);
throw
YzgError
.
getRuntimeException
(
"013"
,
columnName
);
}
}
// 从名称转换列序号
// 从名称转换列序号
int
formulaColumnIndex
=
0
;
int
formulaColumnIndex
=
0
;
...
...
yzg-util-base/src/test/java/helper/TestFormulaHelper.java
View file @
d5af27e9
...
@@ -24,6 +24,13 @@ public class TestFormulaHelper {
...
@@ -24,6 +24,13 @@ public class TestFormulaHelper {
}));
}));
}
}
@Test
public
void
testMul
()
{
// System.out.println(FormulaHelper.calc("(100-0)-2"));
System
.
out
.
println
(
FormulaHelper
.
calc
(
"100-0-2"
));
}
@Test
@Test
public
void
test1
()
{
public
void
test1
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment