Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
3c25556f
Commit
3c25556f
authored
Jun 22, 2018
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
POI test file
parent
a7a8d2f0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
14 deletions
+21
-14
ReportController.java
...in/java/pwc/taxtech/atms/controller/ReportController.java
+1
-1
POITest.java
atms-api/src/test/java/pwc/taxtech/atms/common/POITest.java
+11
-10
TmpFunction.java
...pi/src/test/java/pwc/taxtech/atms/common/TmpFunction.java
+9
-3
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/ReportController.java
View file @
3c25556f
...
@@ -16,7 +16,7 @@ import java.util.List;
...
@@ -16,7 +16,7 @@ import java.util.List;
@RestController
@RestController
@RequestMapping
(
value
=
"api/v1/Report"
)
@RequestMapping
(
value
=
"api/v1/Report"
)
public
class
ReportController
{
public
class
ReportController
{
@Autowired
@Autowired
ReportService
reportService
;
ReportService
reportService
;
@RequestMapping
(
value
=
"template/{organizationID}/{period}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
@RequestMapping
(
value
=
"template/{organizationID}/{period}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
...
...
atms-api/src/test/java/pwc/taxtech/atms/common/POITest.java
View file @
3c25556f
...
@@ -19,20 +19,26 @@ public class POITest {
...
@@ -19,20 +19,26 @@ public class POITest {
try
{
try
{
FileInputStream
fis
=
new
FileInputStream
(
workbookFile
);
FileInputStream
fis
=
new
FileInputStream
(
workbookFile
);
Workbook
workbook
=
WorkbookFactory
.
create
(
fis
);
Workbook
workbook
=
WorkbookFactory
.
create
(
fis
);
String
[]
functionNames
=
{
"TmpFunction"
};
String
[]
functionNames
=
{
"TmpFunction"
};
FreeRefFunction
[]
functionImpls
=
{
new
TmpFunction
()};
FreeRefFunction
[]
functionImpls
=
{
new
TmpFunction
()};
UDFFinder
udfs
=
new
DefaultUDFFinder
(
functionNames
,
functionImpls
);
UDFFinder
udfs
=
new
DefaultUDFFinder
(
functionNames
,
functionImpls
);
UDFFinder
udfToolpack
=
new
AggregatingUDFFinder
(
udfs
);
UDFFinder
udfToolpack
=
new
AggregatingUDFFinder
(
udfs
);
workbook
.
addToolPack
(
udfToolpack
);
workbook
.
addToolPack
(
udfToolpack
);
FormulaEvaluator
evaluator
=
workbook
.
getCreationHelper
().
createFormulaEvaluator
();
FormulaEvaluator
evaluator
=
workbook
.
getCreationHelper
().
createFormulaEvaluator
();
int
sheetNum
=
workbook
.
getNumberOfSheets
();
int
sheetNum
=
workbook
.
getNumberOfSheets
();
Sheet
st1
=
workbook
.
getSheetAt
(
0
);
Sheet
st1
=
workbook
.
getSheetAt
(
0
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
if
(
st1
.
getRow
(
i
)
==
null
)
{
st1
.
createRow
(
i
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
if
(
st1
.
getRow
(
i
).
getCell
(
j
)
==
null
)
{
st1
.
getRow
(
i
).
createCell
(
j
).
setCellFormula
(
"TmpFunction(\"g2\","
+
j
+
")+B5-TmpFunction(\"g2\","
+
i
+
")"
);
}
}
}
}
st1
.
getRow
(
1
).
getCell
(
0
).
setCellType
(
CellType
.
NUMERIC
);
st1
.
getRow
(
1
).
getCell
(
0
).
setCellType
(
CellType
.
NUMERIC
);
st1
.
getRow
(
1
).
getCell
(
0
).
setCellValue
(
15
);
st1
.
getRow
(
1
).
getCell
(
0
).
setCellValue
(
15
);
evaluator
.
evaluateAll
();
evaluator
.
evaluateAll
();
...
@@ -58,14 +64,9 @@ public class POITest {
...
@@ -58,14 +64,9 @@ public class POITest {
}
}
FileOutputStream
excelFileOutPutStream
=
new
FileOutputStream
(
"C:\\source\\test - Copy.xlsx"
);
FileOutputStream
excelFileOutPutStream
=
new
FileOutputStream
(
"C:\\source\\test - Copy.xlsx"
);
workbook
.
write
(
excelFileOutPutStream
);
workbook
.
write
(
excelFileOutPutStream
);
excelFileOutPutStream
.
flush
();
excelFileOutPutStream
.
flush
();
excelFileOutPutStream
.
close
();
excelFileOutPutStream
.
close
();
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
InvalidFormatException
e
)
{
}
catch
(
InvalidFormatException
e
)
{
...
...
atms-api/src/test/java/pwc/taxtech/atms/common/TmpFunction.java
View file @
3c25556f
...
@@ -5,6 +5,9 @@ import org.apache.poi.ss.formula.eval.*;
...
@@ -5,6 +5,9 @@ import org.apache.poi.ss.formula.eval.*;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
org.apache.poi.ss.util.CellReference
;
import
org.apache.poi.ss.util.CellReference
;
/*
TmpFunction("g2",5)
*/
public
class
TmpFunction
implements
FreeRefFunction
{
public
class
TmpFunction
implements
FreeRefFunction
{
@Override
@Override
public
ValueEval
evaluate
(
ValueEval
[]
valueEvals
,
OperationEvaluationContext
operationEvaluationContext
)
{
public
ValueEval
evaluate
(
ValueEval
[]
valueEvals
,
OperationEvaluationContext
operationEvaluationContext
)
{
...
@@ -22,10 +25,13 @@ public class TmpFunction implements FreeRefFunction {
...
@@ -22,10 +25,13 @@ public class TmpFunction implements FreeRefFunction {
String
val1
=
OperandResolver
.
coerceValueToString
(
v1
);
String
val1
=
OperandResolver
.
coerceValueToString
(
v1
);
int
val2
=
OperandResolver
.
coerceValueToInt
(
v2
);
int
val2
=
OperandResolver
.
coerceValueToInt
(
v2
);
CellReference
reference
=
new
CellReference
(
val1
);
CellReference
reference
=
new
CellReference
(
val1
);
int
referenceSheetIndex
=
operationEvaluationContext
.
getWorkbook
().
getSheetIndex
(
reference
.
getSheetName
());
return
new
NumberEval
(
operationEvaluationContext
.
getWorkbook
()
return
new
NumberEval
(
operationEvaluationContext
.
getWorkbook
().
getSheet
(
0
)
.
getSheet
(
referenceSheetIndex
)
.
getCell
(
reference
.
getRow
(),
reference
.
getCol
()).
getNumericCellValue
()
+
val2
);
.
getCell
(
reference
.
getRow
(),
reference
.
getCol
())
.
getNumericCellValue
()
+
val2
);
}
catch
(
EvaluationException
e
)
{
}
catch
(
EvaluationException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
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