使用开放式办公室将Excel(.xlsx)转换为pdf(.pdf)时,缺少工作表和页面大小问题 [英] Missing worksheets and page size issue when excel (.xlsx) convert to pdf (.pdf) using open office

查看:286
本文介绍了使用开放式办公室将Excel(.xlsx)转换为pdf(.pdf)时,缺少工作表和页面大小问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用JodConverterOpen-Office创建了一个将excel(.xlsx)转换为PDF的应用程序,该应用程序运行良好,但我遇到了两个问题

I have created an application using JodConverter and Open-Office for converting an excel(.xlsx) to PDF, The application works fine but i am facing two problems

  1. 输出PDF的页面采用A4大小,因为由于某些工作表的内容已被切开.因为我希望excel的每个工作表都像一页中一样完整,无论大小如何.

  1. The pages of output PDF is in the form of A4 size, since because of that certain worksheet content have been sliced off. since i want each worksheet of the excel as complete as in one page what ever the size.

缺少工作表,例如,如果我的excel有8个工作表,则在PDF输出中我只能得到两个或三个

The no of worksheets were missing, say if my excel has 8 worksheet i am getting only two or three within the PDF output

即使我们试图直接从办公场所转换为pdf,它也会出现上述类似问题

Even if we tried to convert to pdf directly from open-office, its giving the above similar issues

Excel文件- ss1.xlsx

输出PDF - work.pdf

有人可以告诉我一些解决方法

can anyone please tell me some solution for this

我的代码如下所示

public class MyConverter {

    public static void main(String[] args) throws ConnectException {
        File inputFile = new File("C:/Users/Work/Desktop/ss1.xlsx");
        File outputFile = new File("C:/Users/Work/Desktop/work.pdf");

        // connect to an OpenOffice.org instance running on port 8100
        OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
        connection.connect();

        // convert
        DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
        converter.convert(inputFile, outputFile);

        // close the connection
        connection.disconnect();
    }

推荐答案

恐怕我以前的答案不够清楚.所以这就是本质:

I'm afraid my previous answer was not clear enough. So here is the essence:

  • 您的所有工作表除第3张外,其分辨率设置均为600.在第3张工作表中,分辨率保留为空白
  • 将第三张纸的分辨率更改为600
  • 现在将正常生成包含所有图纸的PDF文件.
  • All your worksheets except the 3rd have a resolution setting of 600. In the 3rd sheet the resolution is left blank
  • Change the resolution of the 3rd sheet to 600
  • The PDF file will now be generated normally, containing all sheets.

显然,Excel只能生成所有工作表的页面分辨率都相同的PDF.如果遇到具有不同(空白)分辨率的纸张,它将停止产生输出而不会发出任何警告.恕我直言,这是Excel中的错误.幸运的是,解决方法很容易.

Apparently Excel can only produce PDFs where the page resolutions of all worksheets are the same. If it encounters a sheet with different (of blank) resolution it just stops producing output without giving any warning. IMHO this is a bug in Excel. Fortunately the workaround is easy.

希望这可以澄清我以前的答案.

Hope this clarifies my previous answer.

这篇关于使用开放式办公室将Excel(.xlsx)转换为pdf(.pdf)时,缺少工作表和页面大小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆