Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dcs-doc-expand
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
INET-TWO
server
dcs-doc-expand
Commits
71f7ef06
Commit
71f7ef06
authored
Oct 12, 2024
by
wangyangyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图册:excel转pdf
parent
ac187bdd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
ExtAutoTaskServiceImpl.java
...cs/document/core/service/impl/ExtAutoTaskServiceImpl.java
+2
-1
ConvertExcelToPdf.java
...a/com/yonde/dcs/document/core/util/ConvertExcelToPdf.java
+31
-0
No files found.
dcs-doc-expand-core/src/main/java/com/yonde/dcs/document/core/service/impl/ExtAutoTaskServiceImpl.java
View file @
71f7ef06
...
@@ -271,7 +271,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
...
@@ -271,7 +271,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
//转pdf
//转pdf
String
pdfName
=
"图册.pdf"
;
String
pdfName
=
"图册.pdf"
;
String
filePdfPath
=
dir
+
File
.
separator
+
pdfName
;
String
filePdfPath
=
dir
+
File
.
separator
+
pdfName
;
ExcelUtils
.
excelToPDF
(
filePath
,
filePdfPath
);
// ExcelUtils.excelToPDF(filePath, filePdfPath);
ConvertExcelToPdf
.
excelToPDF
(
filePath
,
filePdfPath
);
//上传文件到文件服务器
//上传文件到文件服务器
MultipartFile
multipartFile
=
new
MockMultipartFile
(
"file"
,
pdfName
,
com
.
yonde
.
dcs
.
plan
.
common
.
constants
.
Constants
.
CONTENT_TYPE_PDF
,
new
FileInputStream
(
filePdfPath
));
MultipartFile
multipartFile
=
new
MockMultipartFile
(
"file"
,
pdfName
,
com
.
yonde
.
dcs
.
plan
.
common
.
constants
.
Constants
.
CONTENT_TYPE_PDF
,
new
FileInputStream
(
filePdfPath
));
RepoFileVO
fileVO
=
fileManagerFeignService
.
uploadFile
(
multipartFile
,
CommonUtil
.
getBucketIdByAppName
(
com
.
yonde
.
dcs
.
document
.
core
.
constants
.
Constants
.
APPLICATION_DOC_INNER_NAME
));
RepoFileVO
fileVO
=
fileManagerFeignService
.
uploadFile
(
multipartFile
,
CommonUtil
.
getBucketIdByAppName
(
com
.
yonde
.
dcs
.
document
.
core
.
constants
.
Constants
.
APPLICATION_DOC_INNER_NAME
));
...
...
dcs-doc-expand-core/src/main/java/com/yonde/dcs/document/core/util/ConvertExcelToPdf.java
0 → 100644
View file @
71f7ef06
package
com
.
yonde
.
dcs
.
document
.
core
.
util
;
import
com.spire.xls.FileFormat
;
import
com.spire.xls.Workbook
;
public
class
ConvertExcelToPdf
{
/**
* excel转pdf
* @param excelPath xlsx
* @param pdfPath
*/
public
static
void
excelToPDF
(
String
excelPath
,
String
pdfPath
)
{
//创建一个Workbook实例并加载Excel文件
Workbook
workbook
=
new
Workbook
();
workbook
.
loadFromFile
(
excelPath
);
//设置转换后的PDF页面高宽适应工作表的内容大小
workbook
.
getConverterSetting
().
setSheetFitToPage
(
true
);
//将生成的文档保存到指定路径
workbook
.
saveToFile
(
pdfPath
,
FileFormat
.
PDF
);
}
public
static
void
main
(
String
[]
args
)
{
String
dir
=
"C:\\Users\\Lenovo\\Desktop\\test\\"
;
excelToPDF
(
dir
+
"图册.xlsx"
,
dir
+
"图.pdf"
);
}
}
\ No newline at end of file
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