Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
959d8e92
You need to sign in or sign up before continuing.
Commit
959d8e92
authored
Apr 16, 2026
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.7.22-税友excel转图片换插件
parent
def24911
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
8 deletions
+48
-8
pom.xml
yifu-social/yifu-social-biz/pom.xml
+5
-0
TSocialFriendController.java
...us/v1/yifu/social/controller/TSocialFriendController.java
+1
-1
ExcelToImage.java
...com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
+42
-7
No files found.
yifu-social/yifu-social-biz/pom.xml
View file @
959d8e92
...
@@ -117,6 +117,11 @@
...
@@ -117,6 +117,11 @@
<artifactId>
aspose-words
</artifactId>
<artifactId>
aspose-words
</artifactId>
<version>
23.1
</version>
<version>
23.1
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.luhuiguo
</groupId>
<artifactId>
aspose-cells
</artifactId>
<version>
23.1
</version>
</dependency>
</dependencies>
</dependencies>
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/controller/TSocialFriendController.java
View file @
959d8e92
...
@@ -92,7 +92,7 @@ public class TSocialFriendController {
...
@@ -92,7 +92,7 @@ public class TSocialFriendController {
@SysLog
(
"定时任务清理临时文件"
)
@SysLog
(
"定时任务清理临时文件"
)
@Inner
@Inner
public
void
doClearFriend
()
{
public
void
doClearFriend
()
{
tSocialFriendPushService
.
doClearFriend
();
//
tSocialFriendPushService.doClearFriend();
}
}
@Operation
(
description
=
"2定时任务获取税友"
)
@Operation
(
description
=
"2定时任务获取税友"
)
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
View file @
959d8e92
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
util
;
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
util
;
import
com.aspose.cells.ImageOrPrintOptions
;
import
com.aspose.cells.ImageType
;
import
com.aspose.cells.SheetRender
;
import
com.spire.xls.Workbook
;
import
com.spire.xls.Workbook
;
import
com.spire.xls.Worksheet
;
import
com.spire.xls.Worksheet
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
...
@@ -18,7 +21,6 @@ import javax.imageio.ImageIO;
...
@@ -18,7 +21,6 @@ import javax.imageio.ImageIO;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.net.URL
;
...
@@ -35,6 +37,7 @@ import java.util.Base64;
...
@@ -35,6 +37,7 @@ import java.util.Base64;
@Component
@Component
public
class
ExcelToImage
{
public
class
ExcelToImage
{
private
final
static
String
toImag
=
"\\ToImg.png"
;
private
final
static
String
toImag
=
"\\ToImg.png"
;
private
static
final
String
TO_IMAGE_TEMP
=
"\\ToImgTemp.png"
;
private
static
final
String
TO_IMAGE_TEMP
=
"\\ToImgTemp.png"
;
...
@@ -56,14 +59,15 @@ public class ExcelToImage {
...
@@ -56,14 +59,15 @@ public class ExcelToImage {
File
tempFile
=
null
;
File
tempFile
=
null
;
File
compressedTempFile
=
null
;
File
compressedTempFile
=
null
;
//加载Excel工作表
//加载Excel工作表
Workbook
wb
=
new
Workbook
();
//
Workbook wb = new Workbook();
try
{
try
{
/*wb.loadFromHtml(inputStream);
wb
.
loadFromHtml
(
inputStream
);
//获取工作表
//获取工作表
Worksheet sheet = wb.getWorksheets().get(0);
Worksheet sheet = wb.getWorksheets().get(0);
sheet.saveToImage(toImagePath);*/
String
toImagePath
=
projectRoot
+
toImag
;
String
toImagePath
=
projectRoot
+
toImag
;
sheet
.
saveToImage
(
toImagePath
);
createWorksheetImage
(
inputStream
,
toImagePath
);
tempFile
=
new
File
(
toImagePath
);
tempFile
=
new
File
(
toImagePath
);
// 上传税友文件服务器,返回文件路径
// 上传税友文件服务器,返回文件路径
...
@@ -89,9 +93,9 @@ public class ExcelToImage {
...
@@ -89,9 +93,9 @@ public class ExcelToImage {
e
.
printStackTrace
();
e
.
printStackTrace
();
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
toImagConvertError
+
e
.
getMessage
());
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
toImagConvertError
+
e
.
getMessage
());
}
finally
{
}
finally
{
if
(
wb
!=
null
)
{
/*
if (wb != null) {
wb.dispose(); // 重要:释放资源并删除临时文件
wb.dispose(); // 重要:释放资源并删除临时文件
}
}
*/
if
(
tempFile
!=
null
&&
tempFile
.
exists
()){
if
(
tempFile
!=
null
&&
tempFile
.
exists
()){
tempFile
.
delete
();
tempFile
.
delete
();
}
}
...
@@ -262,4 +266,35 @@ public class ExcelToImage {
...
@@ -262,4 +266,35 @@ public class ExcelToImage {
sheet.saveToFile("ToPCL.pcl", String.valueOf(FileFormat.PCL));*/
sheet.saveToFile("ToPCL.pcl", String.valueOf(FileFormat.PCL));*/
}
}
/*public void excelToImageMain(String toImagePath) {
try {
createWorksheetImage(toImagePath);
} catch (Exception e) {
e.printStackTrace();
}
}*/
private
static
void
createWorksheetImage
(
InputStream
inputStream
,
String
toImagePath
)
{
com
.
aspose
.
cells
.
Workbook
workbook
=
null
;
try
{
workbook
=
new
com
.
aspose
.
cells
.
Workbook
(
inputStream
);
// 获取第一个工作表
com
.
aspose
.
cells
.
Worksheet
worksheet
=
workbook
.
getWorksheets
().
get
(
0
);
// 设置为适应内容大小
worksheet
.
getPageSetup
().
setZoom
(
100
);
// 转换为图片
ImageOrPrintOptions
options
=
new
ImageOrPrintOptions
();
options
.
setImageType
(
ImageType
.
PNG
);
options
.
setOnePagePerSheet
(
true
);
SheetRender
render
=
new
SheetRender
(
worksheet
,
options
);
render
.
toImage
(
0
,
toImagePath
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
workbook
!=
null
)
{
workbook
.
dispose
();
}
}
}
}
}
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