Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
tianjin-cement
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
竹天卫
tianjin-cement
Commits
529867a9
Commit
529867a9
authored
Apr 01, 2021
by
竹天卫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
word 模板导出
parent
b0deefc5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
201 additions
and
11 deletions
+201
-11
EntrustController.java
...wise/sc/cement/business/controller/EntrustController.java
+13
-0
IEntrustService.java
...a/cn/wise/sc/cement/business/service/IEntrustService.java
+2
-1
EntrustServiceImpl.java
...e/sc/cement/business/service/impl/EntrustServiceImpl.java
+27
-0
ExcelUtil.java
.../main/java/cn/wise/sc/cement/business/util/ExcelUtil.java
+65
-7
checkTeam.ftl
cement-business/src/main/resources/templates/checkTeam.ftl
+94
-3
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/controller/EntrustController.java
View file @
529867a9
...
...
@@ -21,6 +21,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.time.LocalDateTime
;
...
...
@@ -843,6 +844,18 @@ public class EntrustController {
}
@ApiOperation
(
"测试xml转word"
)
@PostMapping
(
"/testXml2Word"
)
public
void
testXml2Word
(
MultipartFile
file
,
HttpServletResponse
response
)
{
try
{
entrustService
.
testXml2Word
(
file
,
response
);
}
catch
(
Exception
e
)
{
log
.
debug
(
"测试xml转word{}"
,
e
);
}
}
}
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/service/IEntrustService.java
View file @
529867a9
...
...
@@ -6,6 +6,7 @@ import cn.wise.sc.cement.business.model.query.*;
import
cn.wise.sc.cement.business.model.vo.*
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
...
...
@@ -178,6 +179,6 @@ public interface IEntrustService extends IService<Entrust> {
String
fileName
,
HttpServletResponse
response
);
void
testXml2Word
(
MultipartFile
file
,
HttpServletResponse
response
);
}
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/EntrustServiceImpl.java
View file @
529867a9
...
...
@@ -37,9 +37,12 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
...
...
@@ -6332,4 +6335,28 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
}
/**
* 测试xml转word
* @param file
* @param response
*/
@Override
public
void
testXml2Word
(
MultipartFile
file
,
HttpServletResponse
response
){
try
{
InputStream
in
=
file
.
getInputStream
();
ExcelUtil
.
readData
((
FileInputStream
)
in
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
cement-business/src/main/java/cn/wise/sc/cement/business/util/ExcelUtil.java
View file @
529867a9
...
...
@@ -20,13 +20,9 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.io.*
;
import
java.text.DecimalFormat
;
import
java.util.*
;
/**
* excel工具类
...
...
@@ -459,6 +455,68 @@ public class ExcelUtil {
return
wb
;
}
/**
* 读取文件
* @param fis
* @return
* @throws Exception
*/
@SuppressWarnings
(
"resource"
)
public
static
List
<
Map
<
Integer
,
String
>>
readData
(
FileInputStream
fis
)
throws
Exception
{
XSSFWorkbook
hwb
=
new
XSSFWorkbook
(
fis
);
List
<
Map
<
Integer
,
String
>>
usermap
=
new
ArrayList
<>();
// 获取第一个sheet页
XSSFSheet
sheetAt
=
hwb
.
getSheetAt
(
0
);
if
(
sheetAt
==
null
)
{
return
usermap
;
}
// 遍历行里面的单元格内容.
for
(
int
i
=
1
;
i
<=
sheetAt
.
getLastRowNum
();
i
++)
{
// User user = new User();
Map
<
Integer
,
String
>
map
=
new
HashMap
<
Integer
,
String
>();
// 得到每一行
XSSFRow
row
=
sheetAt
.
getRow
(
i
);
// 如果为空就跳出
if
(
row
==
null
)
{
continue
;
}
// 遍历列
for
(
int
j
=
0
;
j
<
row
.
getLastCellNum
();
j
++)
{
// 遍历列里面的内容
XSSFCell
cell
=
row
.
getCell
(
j
);
if
(
cell
==
null
)
{
map
.
put
(
j
,
null
);
}
try
{
map
.
put
(
j
,
cell
.
getStringCellValue
());
}
catch
(
Exception
e
)
{
map
.
put
(
j
,
new
DecimalFormat
(
"#0"
).
format
(
cell
.
getNumericCellValue
()).
toString
());
}
}
usermap
.
add
(
map
);
}
return
usermap
;
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
//指定数据存放的位置
OutputStream
outputStream
=
new
FileOutputStream
(
"D:\\test.xlsx"
);
...
...
cement-business/src/main/resources/templates/checkTeam.ftl
View file @
529867a9
This diff is collapsed.
Click to expand it.
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