Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
data_management_system
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
张伯涛
data_management_system
Commits
96c855de
Commit
96c855de
authored
Dec 01, 2022
by
gaoyingwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 导入模板设置文本格式
parent
ad580498
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
38 deletions
+49
-38
FcryController.java
.../java/com/ruoyi/web/controller/system/FcryController.java
+3
-1
GldryController.java
...java/com/ruoyi/web/controller/system/GldryController.java
+3
-3
HscjController.java
.../java/com/ruoyi/web/controller/system/HscjController.java
+3
-2
YcsbController.java
.../java/com/ruoyi/web/controller/system/YcsbController.java
+3
-2
YxryController.java
.../java/com/ruoyi/web/controller/system/YxryController.java
+3
-1
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+34
-29
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/FcryController.java
View file @
96c855de
...
@@ -226,7 +226,9 @@ public class FcryController extends BaseController
...
@@ -226,7 +226,9 @@ public class FcryController extends BaseController
// List<String> fcList = fkqkService.selectFc();
// List<String> fcList = fkqkService.selectFc();
// String[] fc = fcList.toArray(new String[]{});
// String[] fc = fcList.toArray(new String[]{});
// ExcelUtil.setClassExcelAttribute( clazz,"fcPlace","combo",fc);
// ExcelUtil.setClassExcelAttribute( clazz,"fcPlace","combo",fc);
util
.
importTemplateExcel
(
response
,
"方舱人员导入模板"
);
//设置文本格式表头在第几列
String
columes
=
"3"
;
util
.
importTemplateExcelSetHead
(
response
,
"方舱人员导入模板"
,
columes
);
}
}
/**
/**
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/GldryController.java
View file @
96c855de
...
@@ -135,9 +135,9 @@ public class GldryController extends BaseController
...
@@ -135,9 +135,9 @@ public class GldryController extends BaseController
// String[] streetTown=street_town.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
// String[] streetTown=street_town.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
// ExcelUtil.setClassExcelAttribute(clazz,"street","combo",streetTown);
// ExcelUtil.setClassExcelAttribute(clazz,"street","combo",streetTown);
//
//
// 设置 居委会 下拉框(暂无该数据字典)
//设置文本格式表头在第几列
String
columes
=
"3"
;
util
.
importTemplateExcel
(
response
,
"隔离点人员数据导入空模板"
);
util
.
importTemplateExcel
SetHead
(
response
,
"隔离点人员数据导入空模板"
,
columes
);
}
}
@Log
(
title
=
"导入隔离点人员数据"
,
businessType
=
BusinessType
.
IMPORT
)
@Log
(
title
=
"导入隔离点人员数据"
,
businessType
=
BusinessType
.
IMPORT
)
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/HscjController.java
View file @
96c855de
...
@@ -102,8 +102,9 @@ public class HscjController extends BaseController
...
@@ -102,8 +102,9 @@ public class HscjController extends BaseController
// 设置 检测结果 下拉框
// 设置 检测结果 下拉框
String
[]
resList
=
new
String
[]{
"阳性"
,
"阴性"
};
String
[]
resList
=
new
String
[]{
"阳性"
,
"阴性"
};
ExcelUtil
.
setClassExcelAttribute
(
clazz
,
"cjResult"
,
"combo"
,
resList
);
ExcelUtil
.
setClassExcelAttribute
(
clazz
,
"cjResult"
,
"combo"
,
resList
);
//设置文本格式表头在第几列
util
.
importTemplateExcel
(
response
,
"核酸采集导入空模板"
);
String
columes
=
"7,8,10"
;
util
.
importTemplateExcelSetHead
(
response
,
"核酸采集导入空模板"
,
columes
);
}
}
@Log
(
title
=
"导入核算采集数据"
,
businessType
=
BusinessType
.
IMPORT
)
@Log
(
title
=
"导入核算采集数据"
,
businessType
=
BusinessType
.
IMPORT
)
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/YcsbController.java
View file @
96c855de
...
@@ -160,8 +160,9 @@ public class YcsbController extends BaseController
...
@@ -160,8 +160,9 @@ public class YcsbController extends BaseController
// 是否做核酸
// 是否做核酸
String
[]
hasAcid
=
new
String
[]{
"是"
,
"否"
};
String
[]
hasAcid
=
new
String
[]{
"是"
,
"否"
};
ExcelUtil
.
setClassExcelAttribute
(
clazz
,
"hasAcid"
,
"combo"
,
hasAcid
);
ExcelUtil
.
setClassExcelAttribute
(
clazz
,
"hasAcid"
,
"combo"
,
hasAcid
);
//设置文本格式表头在第几列
util
.
importTemplateExcel
(
response
,
"抗原异常上报"
);
String
columes
=
"3"
;
util
.
importTemplateExcelSetHead
(
response
,
"抗原异常上报"
,
columes
);
}
}
/**
/**
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/YxryController.java
View file @
96c855de
...
@@ -164,7 +164,9 @@ public class YxryController extends BaseController
...
@@ -164,7 +164,9 @@ public class YxryController extends BaseController
// ExcelUtil.setClassExcelAttribute( clazz,"isControl","combo",isControl);
// ExcelUtil.setClassExcelAttribute( clazz,"isControl","combo",isControl);
ExcelUtil
.
setClassExcelAttribute
(
clazz
,
"isHome"
,
"combo"
,
isHome
);
ExcelUtil
.
setClassExcelAttribute
(
clazz
,
"isHome"
,
"combo"
,
isHome
);
// ExcelUtil.setClassExcelAttribute( clazz,"glPlace","combo",glPlace);
// ExcelUtil.setClassExcelAttribute( clazz,"glPlace","combo",glPlace);
util
.
importTemplateExcel
(
response
,
"阳性人员"
);
//设置文本格式表头在第几列
String
columes
=
"12"
;
util
.
importTemplateExcelSetHead
(
response
,
"阳性人员"
,
columes
);
}
}
@Log
(
title
=
"导入阳性人员"
,
businessType
=
BusinessType
.
IMPORT
)
@Log
(
title
=
"导入阳性人员"
,
businessType
=
BusinessType
.
IMPORT
)
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
View file @
96c855de
...
@@ -32,27 +32,7 @@ import org.apache.poi.hssf.usermodel.HSSFShape;
...
@@ -32,27 +32,7 @@ import org.apache.poi.hssf.usermodel.HSSFShape;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ooxml.POIXMLDocumentPart
;
import
org.apache.poi.ooxml.POIXMLDocumentPart
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.CellType
;
import
org.apache.poi.ss.usermodel.ClientAnchor
;
import
org.apache.poi.ss.usermodel.DataValidation
;
import
org.apache.poi.ss.usermodel.DataValidationConstraint
;
import
org.apache.poi.ss.usermodel.DataValidationHelper
;
import
org.apache.poi.ss.usermodel.DateUtil
;
import
org.apache.poi.ss.usermodel.Drawing
;
import
org.apache.poi.ss.usermodel.FillPatternType
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.IndexedColors
;
import
org.apache.poi.ss.usermodel.Name
;
import
org.apache.poi.ss.usermodel.PictureData
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.WorkbookFactory
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddressList
;
import
org.apache.poi.ss.util.CellRangeAddressList
;
import
org.apache.poi.util.IOUtils
;
import
org.apache.poi.util.IOUtils
;
...
@@ -531,7 +511,7 @@ public class ExcelUtil<T>
...
@@ -531,7 +511,7 @@ public class ExcelUtil<T>
response
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
response
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
this
.
init
(
list
,
sheetName
,
title
,
Type
.
EXPORT
);
this
.
init
(
list
,
sheetName
,
title
,
Type
.
EXPORT
);
exportExcel
(
response
);
exportExcel
(
response
,
StringUtils
.
EMPTY
);
}
}
/**
/**
...
@@ -566,7 +546,18 @@ public class ExcelUtil<T>
...
@@ -566,7 +546,18 @@ public class ExcelUtil<T>
*/
*/
public
void
importTemplateExcel
(
HttpServletResponse
response
,
String
sheetName
)
public
void
importTemplateExcel
(
HttpServletResponse
response
,
String
sheetName
)
{
{
importTemplateExcel
(
response
,
sheetName
,
StringUtils
.
EMPTY
);
importTemplateExcel
(
response
,
sheetName
,
StringUtils
.
EMPTY
,
StringUtils
.
EMPTY
);
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param sheetName 工作表的名称
* @return 结果
*/
public
void
importTemplateExcelSetHead
(
HttpServletResponse
response
,
String
sheetName
,
String
columes
)
{
importTemplateExcel
(
response
,
sheetName
,
StringUtils
.
EMPTY
,
columes
);
}
}
/**
/**
...
@@ -576,12 +567,12 @@ public class ExcelUtil<T>
...
@@ -576,12 +567,12 @@ public class ExcelUtil<T>
* @param title 标题
* @param title 标题
* @return 结果
* @return 结果
*/
*/
public
void
importTemplateExcel
(
HttpServletResponse
response
,
String
sheetName
,
String
title
)
public
void
importTemplateExcel
(
HttpServletResponse
response
,
String
sheetName
,
String
title
,
String
columes
)
{
{
response
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
response
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
this
.
init
(
null
,
sheetName
,
title
,
Type
.
IMPORT
);
this
.
init
(
null
,
sheetName
,
title
,
Type
.
IMPORT
);
exportExcel
(
response
);
exportExcel
(
response
,
columes
);
}
}
/**
/**
...
@@ -589,11 +580,11 @@ public class ExcelUtil<T>
...
@@ -589,11 +580,11 @@ public class ExcelUtil<T>
*
*
* @return 结果
* @return 结果
*/
*/
public
void
exportExcel
(
HttpServletResponse
response
)
public
void
exportExcel
(
HttpServletResponse
response
,
String
columes
)
{
{
try
try
{
{
writeSheet
();
writeSheet
(
columes
);
wb
.
write
(
response
.
getOutputStream
());
wb
.
write
(
response
.
getOutputStream
());
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
...
@@ -616,7 +607,7 @@ public class ExcelUtil<T>
...
@@ -616,7 +607,7 @@ public class ExcelUtil<T>
OutputStream
out
=
null
;
OutputStream
out
=
null
;
try
try
{
{
writeSheet
();
writeSheet
(
StringUtils
.
EMPTY
);
String
filename
=
encodingFilename
(
sheetName
);
String
filename
=
encodingFilename
(
sheetName
);
out
=
new
FileOutputStream
(
getAbsoluteFile
(
filename
));
out
=
new
FileOutputStream
(
getAbsoluteFile
(
filename
));
wb
.
write
(
out
);
wb
.
write
(
out
);
...
@@ -637,7 +628,7 @@ public class ExcelUtil<T>
...
@@ -637,7 +628,7 @@ public class ExcelUtil<T>
/**
/**
* 创建写入数据到Sheet
* 创建写入数据到Sheet
*/
*/
public
void
writeSheet
()
public
void
writeSheet
(
String
columes
)
{
{
// 取出一共有多少个sheet.
// 取出一共有多少个sheet.
int
sheetNo
=
Math
.
max
(
1
,
(
int
)
Math
.
ceil
(
list
.
size
()
*
1.0
/
sheetSize
));
int
sheetNo
=
Math
.
max
(
1
,
(
int
)
Math
.
ceil
(
list
.
size
()
*
1.0
/
sheetSize
));
...
@@ -671,6 +662,20 @@ public class ExcelUtil<T>
...
@@ -671,6 +662,20 @@ public class ExcelUtil<T>
fillExcelData
(
index
,
row
);
fillExcelData
(
index
,
row
);
addStatisticsRow
();
addStatisticsRow
();
}
}
if
(
Type
.
IMPORT
.
equals
(
type
))
{
String
[]
colume
=
columes
.
split
(
","
);
for
(
String
c
:
colume
)
{
CellStyle
textStyle
=
wb
.
createCellStyle
();
DataFormat
format
=
wb
.
createDataFormat
();
//设置文本格式
textStyle
.
setDataFormat
(
format
.
getFormat
(
"@"
));
textStyle
.
setWrapText
(
true
);
textStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//水平居中
textStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
//垂直居中
sheet
.
setDefaultColumnStyle
(
Integer
.
parseInt
(
c
),
textStyle
);
}
}
}
}
}
}
...
...
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