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
bea3477f
Commit
bea3477f
authored
4 years ago
by
shulidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
委托单产值导出方法2
parent
a5b58c15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
263 additions
and
23 deletions
+263
-23
EntrustController.java
...wise/sc/cement/business/controller/EntrustController.java
+3
-1
IEntrustService.java
...a/cn/wise/sc/cement/business/service/IEntrustService.java
+4
-0
EntrustServiceImpl.java
...e/sc/cement/business/service/impl/EntrustServiceImpl.java
+184
-0
ExcelUtil.java
.../main/java/cn/wise/sc/cement/business/util/ExcelUtil.java
+72
-22
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/controller/EntrustController.java
View file @
bea3477f
...
...
@@ -81,10 +81,12 @@ public class EntrustController {
public
void
export
(
String
startDate
,
String
endDate
,
Integer
status
,
Integer
clientId
,
String
projectName
,
String
projectCode
,
String
fileName
,
HttpServletResponse
response
)
{
long
a
=
System
.
currentTimeMillis
();
try
{
entrustService
.
export
(
startDate
,
endDate
,
status
,
entrustService
.
export
Consignation
(
startDate
,
endDate
,
status
,
clientId
,
projectName
,
projectCode
,
fileName
,
response
);
System
.
out
.
println
(
System
.
currentTimeMillis
()-
a
);
}
catch
(
Exception
e
)
{
log
.
debug
(
"委托列表导出{}"
,
e
);
}
...
...
This diff is collapsed.
Click to expand it.
cement-business/src/main/java/cn/wise/sc/cement/business/service/IEntrustService.java
View file @
bea3477f
...
...
@@ -144,6 +144,10 @@ public interface IEntrustService extends IService<Entrust> {
Integer
clientId
,
String
projectName
,
String
projectCode
,
String
fileName
,
HttpServletResponse
response
);
void
exportConsignation
(
String
startDate
,
String
endDate
,
Integer
status
,
Integer
clientId
,
String
projectName
,
String
projectCode
,
String
fileName
,
HttpServletResponse
response
);
BaseResponse
<
EntrustVo
>
getBaseDtail
(
Integer
id
);
BaseResponse
<
EntrustVo
>
getBaseDtailClient
(
Integer
id
);
...
...
This diff is collapsed.
Click to expand it.
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/EntrustServiceImpl.java
View file @
bea3477f
This diff is collapsed.
Click to expand it.
cement-business/src/main/java/cn/wise/sc/cement/business/util/ExcelUtil.java
View file @
bea3477f
package
cn
.
wise
.
sc
.
cement
.
business
.
util
;
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
javax.servlet.http.HttpServletResponse
;
import
cn.afterturn.easypoi.excel.annotation.Excel
;
import
org.apache.poi.hssf.usermodel.HSSFCellStyle
;
import
org.apache.poi.hssf.usermodel.HSSFFont
;
import
org.apache.poi.hssf.usermodel.HSSFRichTextString
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
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.Font
;
import
org.apache.poi.ss.usermodel.FontFormatting
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
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.util.CellRangeAddress
;
import
org.apache.poi.wp.usermodel.Paragraph
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
org.apache.poi.xssf.usermodel.XSSFFont
;
...
...
@@ -26,6 +19,15 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
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
;
/**
* excel工具类
*
...
...
@@ -159,6 +161,42 @@ public class ExcelUtil {
}
}
public
static
void
excelExportNew
(
String
fileName
,
Workbook
workbook
,
HttpServletResponse
response
)
{
if
(
workbook
!=
null
)
{
ByteArrayOutputStream
byteArrayOutputStream
=
null
;
try
{
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
workbook
.
write
(
byteArrayOutputStream
);
String
suffix
=
".xls"
;
response
.
setContentType
(
"application/vnd.ms-excel;charset=utf-8"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
new
String
((
fileName
+
suffix
).
getBytes
(),
"iso-8859-1"
));
OutputStream
outputStream
=
response
.
getOutputStream
();
outputStream
.
write
(
byteArrayOutputStream
.
toByteArray
());
outputStream
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
if
(
byteArrayOutputStream
!=
null
)
{
byteArrayOutputStream
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
workbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
/**
* @param headers 列头
* @param datas 数据
...
...
@@ -244,7 +282,7 @@ public class ExcelUtil {
applyRichStringFontsub
(
value
,
richString
,
xxsfFont
);
cell
.
setCellValue
(
richString
);
// value = cell.getStringCellValue();
}
else
{
}
else
{
cell
.
setCellValue
(
value
);
cell
.
setCellStyle
(
style
);
}
...
...
@@ -259,7 +297,6 @@ public class ExcelUtil {
}*/
}
}
}
...
...
@@ -287,6 +324,19 @@ public class ExcelUtil {
}
}
public
static
XSSFRichTextString
applyFontsub
(
String
sub
,
XSSFFont
xxsfFont
)
{
XSSFRichTextString
richString
=
new
XSSFRichTextString
();
if
(
sub
.
contains
(
"<sub>"
)
||
sub
.
contains
(
"</sub>"
))
{
xxsfFont
.
setTypeOffset
(
FontFormatting
.
SS_SUB
);
richString
.
setString
(
sub
.
replaceAll
(
"</sub>"
,
"<sub>"
).
replaceAll
(
"<sub>"
,
""
));
//提取下标位置
applyRichStringFontsub
(
sub
,
richString
,
xxsfFont
);
}
else
{
richString
.
setString
(
sub
);
}
return
richString
;
}
private
static
void
applyRichStringFontsup
(
String
sup
,
XSSFRichTextString
richString
,
XSSFFont
xxsfFont
)
{
String
[]
split
=
sup
.
replaceAll
(
"</sup>"
,
"<sup>"
).
split
(
"<sup>"
);
String
it_str
=
""
;
...
...
@@ -364,14 +414,14 @@ public class ExcelUtil {
}
/**
* @param infoHeader 委托人信息表头
* @param infoHeader
委托人信息表头
* @param teamsHeader 检测项表头
* @return
*/
private
static
XSSFWorkbook
generatoronsignationWorkbook
(
List
<
String
>
infoHeader
,
List
<
String
>
teamsHeader
)
{
XSSFWorkbook
wb
=
new
XSSFWorkbook
();
XSSFSheet
sheet
=
wb
.
createSheet
(
"sheet1"
);
XSSFCellStyle
style
=
wb
.
createCellStyle
();
XSSFCellStyle
style
=
wb
.
createCellStyle
();
//水平居中
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//垂直居中
...
...
@@ -409,7 +459,7 @@ public class ExcelUtil {
tempCell2
.
setCellValue
(
header
);
tempCell2
.
setCellStyle
(
style
);
//合并表头
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
0
,
0
,
i
-
1
,
i
));
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
0
,
0
,
i
-
1
,
i
));
}
//创建第二行
XSSFRow
row1
=
sheet
.
createRow
(
rownum
++);
...
...
@@ -434,7 +484,7 @@ public class ExcelUtil {
tempCell
.
setCellStyle
(
style
);
}
//处理检测项信息表头
for
(
int
i
=
teamsHeader
.
size
()
+
1
+
infoHeader
.
size
();
i
<
infoHeader
.
size
()+
1
+
teamsHeader
.
size
()
*
3
;
i
++)
{
for
(
int
i
=
teamsHeader
.
size
()
+
1
+
infoHeader
.
size
();
i
<
infoHeader
.
size
()
+
1
+
teamsHeader
.
size
()
*
3
;
i
++)
{
XSSFCell
tempCell1
=
row1
.
createCell
(
i
);
tempCell1
.
setCellValue
(
"单价"
);
tempCell1
.
setCellStyle
(
style
);
...
...
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