Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
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
黄营
datax-cloud
Commits
413bfe9a
Commit
413bfe9a
authored
Apr 23, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
a19cf9d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
25 deletions
+40
-25
WordUtil.java
...ce/src/main/java/cn/datax/commo/office/word/WordUtil.java
+40
-25
No files found.
datax-common/datax-common-office/src/main/java/cn/datax/commo/office/word/WordUtil.java
View file @
413bfe9a
...
...
@@ -33,8 +33,23 @@ public class WordUtil {
* 去除水印
*/
static
{
String
license
=
"<License>\n"
+
" <Data>\n"
+
" <Products>\n"
+
" <Product>Aspose.Cells for Java</Product>\n"
+
" <Product>Aspose.Words for Java</Product>\n"
+
" <Product>Aspose.Slides for Java</Product>\n"
+
" </Products>\n"
+
" <EditionType>Enterprise</EditionType>\n"
+
" <SubscriptionExpiry>20991231</SubscriptionExpiry>\n"
+
" <LicenseExpiry>20991231</LicenseExpiry>\n"
+
" <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>\n"
+
" </Data>\n"
+
" <Signature>datax</Signature>\n"
+
"</License>"
;
try
{
new
License
().
setLicense
(
new
ByteArrayInputStream
(
"license"
.
getBytes
(
"UTF-8"
)));
new
License
().
setLicense
(
new
ByteArrayInputStream
(
license
.
getBytes
(
"UTF-8"
)));
}
catch
(
Exception
e
)
{}
}
...
...
@@ -133,29 +148,29 @@ public class WordUtil {
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"companyName"
,
"测试"
);
map
.
put
(
"totalSalary"
,
new
BigDecimal
(
"12.34"
));
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
map1
.
put
(
"name"
,
"测试1"
);
map1
.
put
(
"age"
,
12
);
map1
.
put
(
"sex"
,
"男"
);
map1
.
put
(
"salary"
,
new
BigDecimal
(
"5.0"
));
list
.
add
(
map1
);
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map2
.
put
(
"name"
,
"测试2"
);
map2
.
put
(
"age"
,
14
);
map2
.
put
(
"sex"
,
"女"
);
map2
.
put
(
"salary"
,
new
BigDecimal
(
"7.34"
));
list
.
add
(
map2
);
List
<
String
>
objects1
=
new
ArrayList
<>();
List
<
Object
>
objects2
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
()){
objects1
.
add
(
entry
.
getKey
());
objects2
.
add
(
entry
.
getValue
());
}
WordUtil
.
getInstance
().
fillWordListData
(
objects1
.
toArray
(
new
String
[
objects1
.
size
()]),
objects2
.
toArray
(
new
Object
[
objects2
.
size
()]),
"F:\\test\\模板.docx"
,
"F:\\test\\123.docx"
,
list
,
"workerList"
);
//
WordUtil.getInstance().word2pdf("F:\\test\\审批流提交.docx", "F:\\test\\20200420.pdf");
//
Map<String, Object> map = new HashMap<>();
//
map.put("companyName", "测试");
//
map.put("totalSalary", new BigDecimal("12.34"));
//
List<Map<String, Object>> list = new ArrayList<>();
//
Map<String, Object> map1 = new HashMap<>();
//
map1.put("name", "测试1");
//
map1.put("age", 12);
//
map1.put("sex", "男");
//
map1.put("salary", new BigDecimal("5.0"));
//
list.add(map1);
//
Map<String, Object> map2 = new HashMap<>();
//
map2.put("name", "测试2");
//
map2.put("age", 14);
//
map2.put("sex", "女");
//
map2.put("salary", new BigDecimal("7.34"));
//
list.add(map2);
//
List<String> objects1 = new ArrayList<>();
//
List<Object> objects2 = new ArrayList<>();
//
for(Map.Entry<String, Object> entry : map.entrySet()){
//
objects1.add(entry.getKey());
//
objects2.add(entry.getValue());
//
}
//
WordUtil.getInstance().fillWordListData(objects1.toArray(new String[objects1.size()]), objects2.toArray(new Object[objects2.size()]), "F:\\test\\模板.docx", "F:\\test\\123.docx", list, "workerList");
WordUtil
.
getInstance
().
word2pdf
(
"F:\\test\\审批流提交.docx"
,
"F:\\test\\20200420.pdf"
);
}
}
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