2013年12月17日星期二

Neighborhoods Supreme WORD document with apache poi read and retain full format method . . .

Demand is so , read the WORD document
to retain images, tables , and text styles , paragraphs, and so on. Eventually can be displayed on the page.
Internet to find a lot of information on the , jacob good. But can not be used under linux.
There are other points in addition to POI hope , basically tragedy.
I also see a lot of similar posts on CSDN, have not been finally resolved
Although I know little hope , or try posting here .
have to know how to get the trouble to inform you, thank you !
------ Solution ---------------------------------------- ----
I have here Forms can be read

can not read pictures
but can not handle
------ Solution ----------------------------- ---------------
I have here a method to load images , you can learn about.

/ **
* Load photos
* @ param patriarch photo editing objects
* @ param wb document
* @ param col column number ( starting from 0 )
* @ param row row number ( starting from 0 )
* @ param accessoryID
* /
private void loadPicture (HSSFPatriarch patriarch, HSSFWorkbook wb, short col, int row, String accessoryID) {
try {

BufferedImage bufferImg = null;
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream ();
bufferImg = ImageIO.read (Attachment.download (accessoryID));
ImageIO.write (bufferImg, "jpg", byteArrayOut);
HSSFClientAnchor anchor = new HSSFClientAnchor (0,0,1000,255, col, row, col, row);
patriarch.createPicture (anchor, wb.addPicture (byteArrayOut.toByteArray (), HSSFWorkbook.PICTURE_TYPE_JPEG)); / / insert pictures
byteArrayOut.close ();
} catch (IOException e) {
e.printStackTrace ();
}
}
------ For reference only --------------------------------- ------
have to know our brothers and sisters help out .
only need to read the line, do not need to edit.
can do to preserve the original format on the line , WORD style too much , but not open source, now estimated to have had no way to retain all styles .
------ For reference only -------------------------------------- -


read out the form can not be displayed ? Can be displayed on the line, do not need to edit .
best to turn into HTM file formats
------ For reference only ------------------------ ---------------
hey , do want to die .
tried a variety of ways , too hard.
also tried directly into FCKeditor, some ideas, but only feasible IE , FF, what song is basically impossible valley .
heard people say simple words with asp.net lot, after all, is microsoft own things.
too tragic .
------ For reference only -------------------------------------- -
now see the landlord stickers, answer seemed too late . But if there are other users experiencing the same problem, I recommend you use PageOffice, although this is a commercial software is very easy to use it is worth , so you no longer worry . It can display the original flavor of the page no matter how complex formatting in word document , excel spreadsheet , pure java call , the server is linux , no problem , unlike jacob, do not install the server-side office.
POI can simply write word, did not do on a Web page to display, edit word functions.
FCKeditor only used to simulate textarea word format , the difference is often very far on a word document and pasted the actual word document format , editing is not finished also wrote back word.
------ For reference only -------------------------------------- -
landlord did not get, I have to do such a function today , seeking relief ..
------ For reference only --------------- ------------------------
latest change jar package poi 3.9

没有评论:

发表评论