Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
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
4 years ago
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;
...
@@ -21,6 +21,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -843,6 +844,18 @@ public class EntrustController {
...
@@ -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
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
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.*;
...
@@ -6,6 +6,7 @@ import cn.wise.sc.cement.business.model.query.*;
import
cn.wise.sc.cement.business.model.vo.*
;
import
cn.wise.sc.cement.business.model.vo.*
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.List
;
...
@@ -178,6 +179,6 @@ public interface IEntrustService extends IService<Entrust> {
...
@@ -178,6 +179,6 @@ public interface IEntrustService extends IService<Entrust> {
String
fileName
,
HttpServletResponse
response
);
String
fileName
,
HttpServletResponse
response
);
void
testXml2Word
(
MultipartFile
file
,
HttpServletResponse
response
);
}
}
This diff is collapsed.
Click to expand it.
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;
...
@@ -37,9 +37,12 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
...
@@ -6332,4 +6335,28 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
...
@@ -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
();
}
}
}
}
This diff is collapsed.
Click to expand it.
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;
...
@@ -20,13 +20,9 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.*
;
import
java.io.File
;
import
java.text.DecimalFormat
;
import
java.io.FileOutputStream
;
import
java.util.*
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.Arrays
;
import
java.util.List
;
/**
/**
* excel工具类
* excel工具类
...
@@ -459,6 +455,68 @@ public class ExcelUtil {
...
@@ -459,6 +455,68 @@ public class ExcelUtil {
return
wb
;
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
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
//指定数据存放的位置
//指定数据存放的位置
OutputStream
outputStream
=
new
FileOutputStream
(
"D:\\test.xlsx"
);
OutputStream
outputStream
=
new
FileOutputStream
(
"D:\\test.xlsx"
);
...
...
This diff is collapsed.
Click to expand it.
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