Excel转化pdf 以及sheet区域截图,转化的pdf和图片文件,其中文字换行有差异
转化前:
image.png (17.7 KB)
转化后:
image.png (87.5 KB)
Excel区域截图也存在相应问题,望帮忙看一下如何解决
文字的显示的没问题,就是文字跟excel中显示的样式是不一致的。就是原先在excel不换行的文字,在pdf中换行了。在excel中换行的,在pdf中不换行了。。就是两边不是完全一致的。
excel中(第一个换行第二行不换行)
image.png (13.8 KB)
pdf中第一行下面英文自动换行了,第二行的中文后面应该换行,结果英文没换行,
image.png (58.4 KB)
感觉pdf的中的每一个单元格的列宽和excel中的不一致导致的
那导出pdf这个我觉得这边是没有问题的。就是我还想问下,假如我想实现Excel实现区域性截图,同时希望图片上的效果和Excel中看到的保持一致,用Aspose.Cells For Java 怎么实现呢?求教
请尝试使用ImageOrPrintOptions.OnlyArea
属性。
代码:
Workbook wb = new Workbook("test.xlsx");
Worksheet sheet = wb.getWorksheets().get(0);
//set a proper print area
sheet.getPageSetup().setPrintArea("B54:O63");
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();
imgOpt.setImageType(ImageType.PNG);
//To make output be more same as you see in Excel Normal view instead of Print view.
imgOpt.setOnlyArea(true);
SheetRender sr = new SheetRender(sheet, imgOpt);
sr.toImage(0, "output.png");
用以下代码,我们已经复现您的问题,正如你的截图所示,单元格的文字不居中。我们将为您记录问题。
Workbook wb = new Workbook("test.xlsx");
Worksheet sheet = wb.getWorksheets().get(0);
//set a proper print area
sheet.getPageSetup().setPrintArea("B47:O63");
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();
imgOpt.setImageType(ImageType.PNG);
//To make output be more same as you see in Excel Normal view instead of Print view.
imgOpt.setOnlyArea(true);
SheetRender sr = new SheetRender(sheet, imgOpt);
sr.toImage(0, "output.png");
@zicao
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSJAVA-45159
You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.
我们很高兴地通知您,您的问题已经解决。 该修复程序将包含在我们即将发布的下一个版本中,即计划于 2023 年 3 月上半月发布的 Aspose.Cells for .NET v23.3。新版本发布后,您将收到通知。
The issues you have found earlier (filed as CELLSJAVA-45159) have been fixed in Aspose.Cells for Java 23.3.