How to convert ExL into HTML

Source: Internet
Author: User

This method uses a plug-in: JACOB-1.15-M4, this plug-in can convert office to HTML, here I only introduced one, the conversion of EXL into HTML, the converted HTML border line is 0.5px, in some browsers do not recognize the 0.5px border line, you need to live Into the CSS 0.5px, converted to 1px, in the system if you need to convert a single-case mode, otherwise the conversion of your computer after a few times the memory is blown, the reason is very simple, that every conversion will start a EXL program, the start of the system memory is stained with, so, the proposal is written in a single-case mode, nonsense Not much to say, direct sticker code:

The plugin needs to be downloaded by clicking here to download: http://download.csdn.net/detail/s592652578/8446163


Package com.odon.common.util;

import Java.io.BufferedReader;

import java.io.File;

import Java.io.FileOutputStream;

import Java.io.FileReader;

import java.io.IOException;

import com.jacob.activeX.ActiveXComponent;

import Com.jacob.com.Dispatch;

import com.jacob.com.Variant;

Public class exltohtm {

// single-case mode

private static exltohtm exltohtm=null;

Public static Exltohtm getexltohtm () {

if (exltohtm= =null)

exltohtm=new exltohtm ();

return exltohtm;

}

Public static final int excel_html = 44;

Public static final Activexcomponent App = new activexcomponent ("Excel.Application"); // Start ExL

/** 

* EXCEL Turn HTML

    * @param xlsfile EXCEL file Full path  

    * @param Htmlfile after conversion HTML Storage Path  

    */

Public synchronized void exceltohtml (String xlsfile, stringhtmlfile) {

/ /activexcomponentapp = new Activexcomponent ("Excel.Application");// Start ExL

Try {

app. SetProperty ("Visible",newVariant (false));

Dispatchexcels = app. GetProperty ("Workbooks"). Todispatch ();

Dispatchexcel = Dispatch. Invoke (

Excels

"Open",

Dispatch. Method,

New Object[] {xlsfile,new Variant (false),

New Variant (True)},new int[1]). Todispatch ();

Dispatch. Invoke (Excel,"SaveAs", Dispatch. Method,newobject[] {

Htmlfile,newVariant (excel_html)},newint[1]);

variantf = newVariant (false);

Dispatch. Pager (Excel,"Close", F);

}catch (Exception e) {

E.printstacktrace ();

}finally{

app. Invoke ("Quit",new variant[] {});

}

}

/**

    * Modify CSS style

    * @param FilePath

    * @param Csspath

*/

Public static void readcss (stringfilepath,string csspath) {

BUFFEREDREADERBR = null;

Stringline = null;

Stringbufferbuf = newstringbuffer ();

Stringcontent = null;

filetxt=NewFile (Csspath);

Fileoutputstreamfos = null;

Try {

fos= newfileoutputstream (TXT);

// creating buffered input streams from file paths  

br= NewBufferedReader (newFileReader (FilePath));

// iterate through each line of the file , Modify the rows that need to be modified , put in a buffer object  

while (line = Br.readline ()) =null) {

// the contents of some rows are modified here according to actual needs  

if (Line.indexof (":. 5pt") >-1) {

Line= Line.replace (":. 5pt",": 1pt");

Line= line + "\ r";

}

Buf.append (line);

}

// determine if a file exists

if (!txt.exists ()) {

Txt.createnewfile ();

}

Content= buf.tostring ();

byte bytes[]=newbyte[1024];

Bytes=content.getbytes (); // new Plus.

intb=content.length (); // Change

Fos.write (BYTES,0,B);

}catch(Exception e) {

E.printstacktrace ();

}finally{

// Close the stream  

if (br! =null) {

Try {

Br.close ();

}catch(IOException e) {

br= null;

}

}

if (FOS =null) {

Try {

Fos.close ();

}catch(Exception E2) {

E2.printstacktrace ();

}

}

}

}

}

ExL conversion to HTML

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.