资源简介

完整且无代码,上次被一个6分的哥们骗了,那个根本不能转化,不过让我花了很久给补充完整了。

资源截图

代码片段和文件信息

package org.gfg.test.servlet;



import java.io.File;
import java.net.ConnectException;

import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

import ooo.connector.BootstrapSocketConnector;

public class ExcelTOPdf {

/**
 * ????EXCEL???????????
 * @param rootSourceFilePath
 * @param globalVariable
 */
private static void  convertExcel(String rootSourceFilePath String globalVariableString outputFilePath) {

XComponentLoader xComponentLoader=null;
object doc=null;
try {
// ????OpenOffice
XComponentContext xRemoteContext = BootstrapSocketConnector
.bootstrap(globalVariable);
XMultiComponentFactory xRemoteServiceManager = xRemoteContext
.getServiceManager();
object desktop = xRemoteServiceManager.createInstanceWithContext(
“com.sun.star.frame.Desktop“ xRemoteContext);
 xComponentLoader = (XComponentLoader) UnoRuntime
.queryInterface(XComponentLoader.class desktop);
 PropertyValue[] loadProps = new PropertyValue[1];
 loadProps[0] = new PropertyValue();
 loadProps[0].Name = “Hidden“;
 loadProps[0].Value = new Boolean(true);
 doc = xComponentLoader
.loadComponentFromURL(“file:///“+rootSourceFilePath “_blank“ 0
loadProps);

XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument) UnoRuntime
.queryInterface(XSpreadsheetDocument.class
doc);

com.sun.star.style.XstyleFamiliesSupplier xFamiliesSupplier =
 (com.sun.star.style.XstyleFamiliesSupplier) UnoRuntime.queryInterface(
 com.sun.star.style.XstyleFamiliesSupplier.class xSpreadsheetDocument);

com.sun.star.container.XNameAccess xFamiliesNA = xFamiliesSupplier.getstyleFamilies();

object aPagestylesObj = xFamiliesNA.getByName(“Pagestyles“);

com.sun.star.container.XNameContainer xPagestylesNA = (com.sun.star.container.XNameContainer)
UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class aPagestylesObj);

String []stylename=xPagestylesNA.getElementNames();
for(int j=0;jylename.length;j++){
object style=xPagestylesNA.getByName(stylename[j]);
com.sun.star.style.Xstyle xPagestyleNA = (com.sun.star.style.Xstyle)
UnoRuntime.queryInterface(com.sun.star.style.Xstyle.class style);
if(xPagestyleNA.isInUse()){
XPropertySet xPropSet =

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-06-01 09:31  EXCEL多列转换\
     文件       16332  2015-03-03 11:53  EXCEL多列转换\bootstrapconnector.jar
     文件        4671  2017-08-03 13:52  EXCEL多列转换\ExcelTOPdf.java
     文件       55622  2013-05-09 14:16  EXCEL多列转换\juh-3.0.1.jar
     文件      253610  2013-05-09 14:16  EXCEL多列转换\ridl-3.0.1.jar
     文件     1360160  2013-05-09 14:16  EXCEL多列转换\unoil-3.0.1.jar
     文件        3868  2015-03-02 15:50  EXCEL多列转换\unoloader.jar

评论

共有 条评论