找回密码
 立即注册

QQ登录

只需一步,快速开始

Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-10-17 09:35:31
11#
请确认一下发的demo是否有问题。
你发的demo在我这边无法正常解压
image.png913260192.png
回复 使用道具 举报
孙志强讲师达人认证
金牌服务用户   /  发表于:2022-10-17 10:54:05
12#
Clark.Pan 发表于 2022-10-17 09:35
请确认一下发的demo是否有问题。
你发的demo在我这边无法正常解压

已上传

gcexcel.zip

179.18 KB, 下载次数: 177

回复 使用道具 举报
Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-10-17 14:00:34
13#
你这边的java都是加密的我没办法排查,请提供原始的文件。
image.png108341368.png
回复 使用道具 举报
孙志强讲师达人认证
金牌服务用户   /  发表于:2022-10-17 14:20:08
14#
Clark.Pan 发表于 2022-10-17 14:00
你这边的java都是加密的我没办法排查,请提供原始的文件。

package com.seamwhole.gcexcel.controller;

import com.grapecity.documents.excel.IWorksheet;
import com.grapecity.documents.excel.PdfSaveOptions;
import com.grapecity.documents.excel.SaveFileFormat;
import com.grapecity.documents.excel.Workbook;
import com.grapecity.documents.excel.drawing.IBackgroundPicture;
import com.grapecity.documents.excel.drawing.ImageLayout;
import com.grapecity.documents.excel.drawing.ImageType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

@RestController
@RequestMapping("/gc-excel")
public class GCExcelController {

    @GetMapping("load")
    public void loadPdf(){
        Path path = Paths.get("E:\\download\\aau.ssjson");
        StringBuilder sb = new StringBuilder();
        try (Stream<String> stream = Files.lines(path)) {
            stream.forEach(s -> sb.append(s).append("\n"));
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        String json= sb.toString();
        Workbook workbook=new Workbook();
        workbook.fromJson(json);

        FileOutputStream outputStream = null;
        IBackgroundPicture picture = null;
        try {
            //InputStream stream = getResourceStream("logo.png");
            //IWorksheet worksheet = workbook.getWorksheets().get(0);
            //worksheet.getRange("C40").setValue("对方水电费");
            // worksheet.getShapes().addPictureInPixel(stream, ImageType.PNG, 10, 20, 500, 370);
            //picture = worksheet.getBackgroundPictures().addPicture(stream, ImageType.PNG, 12, 18, 144, 167);
            //Set image layout
            //picture.setBackgroundImageLayout(ImageLayout.Zoom);
            outputStream = new FileOutputStream("E:\\download\\au.pdf");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        workbook.save(outputStream, SaveFileFormat.Pdf);

// Close the file stream
        try {
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private InputStream getResourceStream(String resource) throws Exception {
        return GCExcelController.class.getClassLoader().getResourceAsStream(resource);
    }
}


==================================================================================================
package com.seamwhole.gcexcel;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class GcexcelApplication {

    public static void main(String[] args) {
        SpringApplication.run(GcexcelApplication.class, args);
    }

}




回复 使用道具 举报
Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-10-17 14:23:38
15#
看了你发的代码,没有看到我上面要求你用autofitheight去自适应行高的代码,所以你这边有问题还是回归到我之前说的是因为第一行的行高不够,建议用autofitheight去自适应调整第一行的行高。
回复 使用道具 举报
孙志强讲师达人认证
金牌服务用户   /  发表于:2022-10-17 15:39:02
16#
Clark.Pan 发表于 2022-10-17 14:23
看了你发的代码,没有看到我上面要求你用autofitheight去自适应行高的代码,所以你这边有问题还是回归到我 ...

自适应行高会将多选的那些隐藏掉  所以这个不是最优解, 所以就没有加那段代码
回复 使用道具 举报
Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-10-17 15:46:53
17#
我说的是9楼的回复,并不是你认为的5楼的回复, 参考我9楼的回复给第一行设置自适应行高。问题的原因就是你第一行的行高不够。你弄高点就好了
回复 使用道具 举报
孙志强讲师达人认证
金牌服务用户   /  发表于:2022-10-17 16:12:37
18#
Clark.Pan 发表于 2022-10-17 15:46
我说的是9楼的回复,并不是你认为的5楼的回复, 参考我9楼的回复给第一行设置自适应行高。问题的原因就是你 ...

用这个方法确实可以将数据展示, 但是我们这边的需求是SpreadJS那边怎么展示  我这个pdf就应该怎么展示, 但是现在两边的效果不一致


image.png930874023.png image.png477657775.png image.png177799681.png
回复 使用道具 举报
Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-10-17 17:45:59
19#
这个没办法做到,设计就是如此,设计器保持跟Excel一致的。由于SpreadJS与Excel的行高列宽存在已知差异所以如需导出与Excel显示一致,需要单独手动调整,如前面9楼所示方法,在导出之前单独调整。
回复 使用道具 举报
12
您需要登录后才可以回帖 登录 | 立即注册
返回顶部